diff --git a/jdownie/repo/repo b/jdownie/repo/repo index 51a2f08..2285c19 100755 --- a/jdownie/repo/repo +++ b/jdownie/repo/repo @@ -9,6 +9,10 @@ import json import time from pathlib import Path +def rm(p): + if os.path.exists(p): + os.remove(p) + def filepath(f): ret = os.path.join(os.environ.get("XDG_CACHE_HOME"), f"repo.{f}") return ret @@ -61,13 +65,13 @@ def perform_action(action, key, item, silent = False): if not silent: print("{0} {1}...".format(lbl, key)) output = execute_command(cmd) - os.remove(filepath("status")) + rm(filepath("status")) elif action == "sync": if not silent: print("{0} {1}...".format(lbl, key)) perform_action("pull", key, item, silent=True) perform_action("push", key, item, silent=True) - os.remove(filepath("status")) + rm(filepath("status")) elif action == "lcs": if not silent: print("{0} {1}...".format(lbl, key)) @@ -75,7 +79,7 @@ def perform_action(action, key, item, silent = False): perform_action("lc", key, item, silent=True) perform_action("pull", key, item, silent=True) perform_action("push", key, item, silent=True) - os.remove(filepath("status")) + rm(filepath("status")) elif action == "lc": cmd = "git -C \"{0}\" status --porcelain".format(os.path.expanduser(item["path"])) output = execute_command(cmd).split("\n") @@ -85,7 +89,7 @@ def perform_action(action, key, item, silent = False): output = execute_command(cmd) cmd = "git -C \"{0}\" commit -m \"Lazy commit on {1}.\"".format(os.path.expanduser(item["path"]), hostname) output = execute_command(cmd) - os.remove(filepath("status")) + rm(filepath("status")) return output if __name__ == "__main__":