Просмотр исходного кода

fix rclone command formatting on windows + use more explicit chosen file storage location

Noah Vogt 2 лет назад
Родитель
Сommit
d67fc251bc

+ 5 - 3
README.md

@@ -304,9 +304,11 @@ The slides are placed in subdirectories of `OBS_SLIDES_DIR` with the following n
 
 First, install a reasonably new version of
 
-- git
-- imagemagick (If you are a windows user, select the c/c++ developer headers. Also you may need vcredist for imagemagick to work.)
-- python3
+- [git](https://git-scm.com/)
+- [fzf](https://github.com/junegunn/fzf)
+- printf (Provided by coreutils. Windows user should download gnuwin32.)
+- [imagemagick](https://imagemagick.org/script/download.php) (If you are a windows user, select the c/c++ developer headers. Also you may need vcredist for imagemagick to work.)
+- [python3](https://www.python.org/)
 - some python packages that are not in the standard library using:
 
     pip install -r requirements.txt

+ 1 - 1
config/default_config.py

@@ -82,7 +82,7 @@ RCLONE_LOCAL_DIR = ""
 SSYNC_CACHE_DIR = ""
 SSYNC_CHECKFILE_NAMING = "slidegen-checkfile.txt"
 SSYNC_CACHEFILE_NAMING = "slidegen-cachefile.txt"
-SSYNC_CHOSEN_FILE_NAMING = ".chosen-file.txt"
+SSYNC_CHOSEN_FILE_NAMING = "chosen-file.txt"
 
 OBS_SLIDES_DIR = ""
 OBS_SUBDIR_NAMING = ""

+ 14 - 4
input/slide_selection_iterator.py

@@ -55,7 +55,9 @@ def slide_selection_iterator(
         os.system(
             'printf "{}" | fzf > {}'.format(
                 get_file_list_inside(rclone_local_dir),
-                const.SSYNC_CHOSEN_FILE_NAMING,
+                os.path.join(
+                    const.SSYNC_CACHE_DIR, const.SSYNC_CHOSEN_FILE_NAMING
+                ),
             )
         )
 
@@ -149,8 +151,14 @@ def get_file_list_inside(rclone_local_dir):
 
 def remove_chosenfile() -> None:
     try:
-        if os.path.isfile(const.SSYNC_CHOSEN_FILE_NAMING):
-            os.remove(const.SSYNC_CHOSEN_FILE_NAMING)
+        if os.path.isfile(
+            os.path.join(const.SSYNC_CACHE_DIR, const.SSYNC_CHOSEN_FILE_NAMING)
+        ):
+            os.remove(
+                os.path.join(
+                    const.SSYNC_CACHE_DIR, const.SSYNC_CHOSEN_FILE_NAMING
+                ),
+            )
     except (FileNotFoundError, PermissionError, IOError) as error:
         error_msg("Failed to remove chosenfile. Reason: {}".format(error))
 
@@ -166,7 +174,9 @@ def create_and_get_dest_dir(obs_slides_dir, index) -> str:
 
 def read_chosen_song_file() -> str:
     with open(
-        const.SSYNC_CHOSEN_FILE_NAMING, encoding="utf-8", mode="r"
+        os.path.join(const.SSYNC_CACHE_DIR, const.SSYNC_CHOSEN_FILE_NAMING),
+        encoding="utf-8",
+        mode="r",
     ) as tempfile_file_opener:
         chosen_song_file = tempfile_file_opener.read()[:-1].strip()
     return chosen_song_file

+ 1 - 1
sync/save_new_checkfile.py

@@ -28,7 +28,7 @@ def save_new_checkfile() -> None:
     cache_dir = expand_dir(const.SSYNC_CACHE_DIR)
     log("saving new checkfile...")
     system(
-        'rclone md5sum {} > "{}"'.format(
+        'rclone md5sum "{}" > "{}"'.format(
             const.RCLONE_REMOTE_DIR,
             path.join(cache_dir, const.SSYNC_CHECKFILE_NAMING),
         )

+ 1 - 1
sync/sync_slide_repo.py

@@ -25,7 +25,7 @@ import config as const
 def sync_slide_repo() -> None:
     log("syncing with remote slide repository...")
     system(
-        "rclone sync -v {} {}".format(
+        'rclone sync -v "{}" "{}"'.format(
             const.RCLONE_REMOTE_DIR, const.RCLONE_LOCAL_DIR
         )
     )

+ 1 - 1
sync/syncing_needed.py

@@ -33,7 +33,7 @@ def syncing_needed(offline_flag_enabled: bool) -> bool:
 
     log("checking for remote changes...")
     os.system(
-        "rclone md5sum {} --checkfile {} > {} 2> {}".format(
+        'rclone md5sum "{}" --checkfile "{}" > "{}" 2> "{}"'.format(
             const.RCLONE_REMOTE_DIR,
             os.path.join(const.SSYNC_CACHE_DIR, const.SSYNC_CHECKFILE_NAMING),
             os.devnull,