diff --git a/rwm.py b/rwm.py index 49e3c5d6d676b0f06606eecb4ad5b7af93e4b486..8a41a9d64017dc57ac6dcfa3bf00e65a5e513a83 100755 --- a/rwm.py +++ b/rwm.py @@ -68,12 +68,19 @@ class RWM: # aws cli does not have endpoint-url as env config option return subrun(["aws", "--endpoint-url", self.config["S3_ENDPOINT_URL"]] + args, env=env, check=False).returncode - def rclone_cmd(self, args): - """rclone wrapper""" + @staticmethod + def _rclone_validate_args(args): + """rclone args helper""" - # ensure command uses expected backend if (not any(x.startswith("rwmbe:") for x in args)) and all(x != "help" for x in args): logging.error("rclone command missing 'rwmbe:' backend specification") + return False + return True + + def rclone_cmd(self, args): + """rclone wrapper""" + + if not self._rclone_validate_args(args): return 1 env = { @@ -95,9 +102,7 @@ class RWM: * https://rclone.org/crypt/ """ - # ensure command uses expected backend - if not any(x.startswith("rwmbe:") for x in args): - logging.error("rclone command missing 'rwmbe:' backend specification") + if not self._rclone_validate_args(args): return 1 env = {