From 4973d18034e44e1b4c062347f403a19180d33dde Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 16 Jan 2022 23:41:29 -0500 Subject: [PATCH] ~/.config is created if it does not already exist --- bin/sshync.py | 8 +++----- bin/sshyp | 5 +---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bin/sshync.py b/bin/sshync.py index d40c794..8fef98b 100755 --- a/bin/sshync.py +++ b/bin/sshync.py @@ -4,19 +4,17 @@ # external modules -from os import system, remove, mkdir, walk +from os import mkdir, path, remove, system, walk from os.path import getmtime, join, expanduser from sys import exit as s_exit +from pathlib import Path # utility functions def get_titles_mods(_directory, _destination, _user_data): _title_list, _mod_list = [], [] - try: # create config directory - mkdir(expanduser('~/.config/sshync'), 0o700) - except FileExistsError: - pass + Path(path.expanduser('~/.config/sshync')).mkdir(0o700, parents=True, exist_ok=True) # create config directory # local fetching if _destination == 'l': remove(expanduser('~/.config/sshync/database')) # assumed to exist because remote runs first diff --git a/bin/sshyp b/bin/sshyp index 27316c5..8b8cbda 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -52,10 +52,7 @@ def tweak(): # runs configuration wizard mkdir(path.expanduser('~/.password-pasture'), 0o700) except FileExistsError: pass - try: - mkdir(path.expanduser('~/.config/sshyp'), 0o700) - except FileExistsError: - pass + Path(path.expanduser('~/.config/sshyp')).mkdir(0o700, parents=True, exist_ok=True) if not Path(f"{path.expanduser('~/.config/sshyp/tmp')}").exists(): if Path("/data/data/com.termux").exists(): system(f"ln -s '/data/data/com.termux/files/usr/tmp' {path.expanduser('~/.config/sshyp/tmp')}")