def md5sum(self, remote, directory, extra_args=[], no_error=False): logging.debug('running lsjson for ' + remote + directory) command_with_args = [] command_with_args.append(self._rclone_exe) command_with_args.append("md5sum") for extra_arg in extra_args: command_with_args.append(extra_arg) if self._config_file is not None: command_with_args.append("--config") command_with_args.append(self._config_file) command_with_args.append("--auto-confirm") command_with_args.append("--retries") command_with_args.append(self._rclone_retries) command_with_args.append(remote + directory) result = common.execute(command_with_args, no_error) logging.debug('result: ' + str(result)[0:128]) if result['error'] is not '': if no_error is False: #logging.error('error getting remotes objects') if result['error'].find("directory not found") != -1: raise exceptions.FileNotFoundException(result['error']) else: raise Exception('error getting remote object. ' + result['error']) if 'out' in result and result['out'] == '[\n': lsjson = '[]' else: lsjson = result['out'] logging.debug('returning ' + str(lsjson)[0:128]) return lsjson
def get_remotes(self, extra_args=[]): logging.debug('listing remotes') command_with_args = [] command_with_args.append(self._rclone_exe) command_with_args.append("listremotes") for extra_arg in extra_args: command_with_args.append(extra_arg) if self._config_file is not None: command_with_args.append("--config") command_with_args.append(self._config_file) command_with_args.append("--auto-confirm") command_with_args.append("--retries") command_with_args.append(self._rclone_retries) result = common.execute(command_with_args) logging.debug('result: ' + str(result)) if result['code'] == -20: logging.error( "rclone executable not found. Please make sure it's in the PATH or in the config file" ) raise Exception( "rclone executable not found. Please make sure it's in the PATH or in the config file" ) if result['error'] is not '': logging.error('error getting remotes objects') raise Exception('error getting remote object. ' + result['error']) remotes = result['out'].splitlines() return remotes
def copy(self, src, dst, extra_args=[], no_error=False): logging.debug('running copy from ' + src + " to " + dst) command_with_args = [] command_with_args.append(self._rclone_exe) command_with_args.append("copy") for extra_arg in extra_args: command_with_args.append(extra_arg) if self._config_file is not None: command_with_args.append("--config") command_with_args.append(self._config_file) command_with_args.append("--auto-confirm") command_with_args.append("--retries") command_with_args.append(self._rclone_retries) command_with_args.append(src) command_with_args.append(dst) logging.debug('command args: ' + str(command_with_args)) result = common.execute(command_with_args, no_error) logging.debug('result: ' + str(result)) if result['error'] is not '': if no_error is False: logging.error('error getting remotes objects') raise Exception('error getting remote object. ' + result['error']) out = result['out'].splitlines() logging.debug('returning ' + str(out)) return out
def get_version(self): logging.debug('running version') command_with_args = [self._rclone_exe, "version"] result = common.execute(command_with_args) logging.debug('result: ' + str(result)) if result['error'] is not '': logging.error('error getting remotes objects') raise Exception('error getting remote object. ' + result['error']) out = result['out'].splitlines() logging.debug('returning ' + str(out)) return out
def delete(self, remote, file): logging.debug('running delete for ' + remote + ":" + file) command_with_args = [] command_with_args.append(self._rclone_exe) command_with_args.append("delete") if self._config_file is not None: command_with_args.append("--config") command_with_args.append(self._config_file) command_with_args.append("--auto-confirm") command_with_args.append("--retries") command_with_args.append(self._rclone_retries) command_with_args.append(remote + file) result = common.execute(command_with_args) logging.debug('result: ' + str(result)) if result['error'] is not '': logging.error('error getting remotes objects') raise Exception('error getting remote object. ' + result['error']) out = result['out'].splitlines() logging.debug('returning ' + str(out)) return out
def get_about(self, remote): logging.debug('running about for ' + remote) command_with_args = [] command_with_args.append(self._rclone_exe) command_with_args.append("about") command_with_args.append("--json") if self._config_file is not None: command_with_args.append("--config") command_with_args.append(self._config_file) command_with_args.append("--auto-confirm") command_with_args.append("--retries") command_with_args.append(self._rclone_retries) command_with_args.append(remote) result = common.execute(command_with_args) logging.debug('result: ' + str(result)) if result['error'] is not '': logging.error('error getting remotes objects') raise Exception('error getting remote object. ' + result['error']) aboutjson = result['out'].splitlines() logging.debug('returning ' + str(aboutjson)) return aboutjson