def _execute(self, options, args): from pull import Command as pull from push import Command as push # this looks funny, because we first create a Command object # and then we execute it pull()(None) push()(None)
def pull(self): return pull(self)
import subprocess import time import pull run = True pull.clone() while run: result = subprocess.run(['git', 'pull'], capture_output=True) if result.stdout != "Already up to date.\n": print("No need to run") else: pull.pull() time.sleep(5)
destination_path = destination_path.replace('//', '/') elif sys.argv[3] in ['--ignore', '--no_track', '--copy_all']: pass else: raise FileNotFoundError( "Could not find the file/folder: {}".format(sys.argv[3])) if os.path.isdir(destination_path): params = {'ignore': False, 'track_first': True, 'copy_all': False} if '--ignore' in sys.argv: params['ignore'] = True if '--copy_all' in sys.argv: params['copy_all'] = True if '--no_track' in sys.argv: # may cause errors params['track_first'] = False os.chdir(destination_path) errors = pull(pull_path, destination_path, **params) if len(errors) > 0: print() print( "There was an error in copying the following files/folders:" ) for error in errors: print(error) os.chdir(current_wd) else: raise AttributeError( "Can back-up to a directory only. Cannot back-up to a file.") elif sys.argv[1] == 'print': base_path = current_wd params = {'track_first': True, 'raw': False, 'ignore': False}
util_path = os.path.join(sys_dir, "util") sys.path.append(util_path) import pull import pushtest import register import lstest if __name__ == "__main__": count = 100 test_file_name = "test" username, password = str(raw_input("Username Password <")).split() #register.run_daemon() pushtest.push_test(username, password, "pushFolder", test_file_name, count) print lstest.ls(username, password) pullFolder = pushtest.make_directory("pullFolder") pushFolder = pushtest.make_directory("pushFolder") for i in range(1, count): fName = test_file_name + str(i) pull.pull(username, password, fName, pullFolder) pullHash = pull.get_md5(pullFolder + "/" + fName) pushHash = pull.get_md5(pushFolder + "/" + fName) if pullHash == pushHash: print "File " + fName + " passed" else: print "Hash failed for file " + fName print "Test Finished"