def annex_ssh_add(self, username, host, path): print('git annex add ' + path) password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git annex add ." cmdAnswer, cmdErr = connection.git_Command2(command) print(cmdAnswer)
def annex_ssh_indirect(self, username, host, path): password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git annex indirect" cmdAnswer, cmdErr = connection.git_Command2(command) print(cmdErr) print(cmdAnswer)
def annex_init(self, if_ssh): self.init(if_ssh) if (if_ssh == 1): username, host, path = split_data(self.path) password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git annex init " + path cmdAnswer = connection.git_Command(command) lines = cmdAnswer.split(" ") for line in lines: if ("ok" in line): print('Annex repository initialized') else: print(line + " ") else: p = Popen(['git', 'annex', 'init', self.path], cwd=self.path, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=1) for line in p.stdout: line = line.decode('UTF-8')[:-1] if "ok" in line: if self.logs == 1: print('Annex repository initialized') #return 0 else: print(line)
def annex_ssh_drop(self, username, host, path_local, path='.'): password = [] connection = Ssh(host, username, password) command = "cd " + path_local + " && git annex drop " + path cmdAnswer, cmdErr = connection.git_Command2(command) print(cmdErr) print(cmdAnswer) print('getting finished') return 0
def annex_ssh_get(self, username, host, path_local, source, path='.'): print('git annex get -f ' + source.name + ' ' + path) password = [] connection = Ssh(host, username, password) command = "cd " + path_local + " && git annex get -f " + source.name + " " + path cmdAnswer, cmdErr = connection.git_Command2(command) print(cmdErr) print(cmdAnswer) print('getting finished')
def annex_ssh_sync(self, username, host, path, remote): print("annex synccccccccccc") password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git annex sync " + remote.name cmdAnswer, cmdErr = connection.git_Command2(command) print(cmdErr) print(cmdAnswer) return 0
def sshActions(): global host, username, ssh_path,dirs if request.method == 'POST': password = [] host = request.form['hostname'] username = request.form['username'] if ssh_path == '': connection = Ssh(host, username, password) ssh_path=connection.send_path("pwd") connection = Ssh(host, username, password) folders = connection.sendCommand("ls -d */") folders=folders[:-1] return render_template('sshActions.html', folders=folders,ssh_path=ssh_path) else: print(ssh_path+" "+host+" "+username) password = [] req=request.args.get('dirname') if req!= '..': dirs.append(request.args.get('dirname')) path='/'.join(dirs) else: if len(dirs)>0: del dirs[-1] path = '/'.join(dirs) else: path='.' connection = Ssh(host, username, password) command="cd "+path+" && ls -d */" folders = connection.sendCommand(command) folders = folders[:-1] return render_template('sshActions.html', folders=folders,ssh_path=ssh_path+"/"+path)
def annex_ssh_sync(new_repo, remote): print('git annex sync ' + remote.name) username, host, path = split_data(new_repo.path) password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git annex sync " + remote.name cmdAnswer, cmdErr = connection.git_Command2(command) if (cmdAnswer[:-1] == '') & (cmdErr == ''): print('Repo synced') else: print('Failed repo synced') return 0
def remote_ssh_add(new_repo, local_repo): name = local_repo.name if name not in new_repo.remote_names: local_user = getpass.getuser() username, host, path = split_data(new_repo.path) password = [] hostname = socket.gethostname() ip = socket.gethostbyname(hostname) connection = Ssh(host, username, password) command = "cd " + path + " && git remote add " + name + " ssh://" + local_user + "@" + ip + local_repo.path cmdAnswer, cmdErr = connection.git_Command2(command) if (cmdAnswer[:-1] == '') & (cmdErr == ''): print('Remote added') new_repo.remotes.append(local_repo) new_repo.remote_names.append(name) return 0 return 1
def init(self, if_ssh): if (if_ssh == 1): username, host, path = split_data(self.path) password = [] connection = Ssh(host, username, password) command = "cd " + path + " && git init " + path cmdAnswer = connection.git_Command(command) else: cmdAnswer = check_output(['git', 'init', self.path]).decode('UTF-8') print(cmdAnswer) if cmdAnswer[:32] == 'Initialized empty Git repository': if self.logs == 1: print('Repository initialized') #return 0 elif cmdAnswer[:37] == 'Reinitialized existing Git repository': if self.logs == 1: print('Repository reinitialized') #return 0 else: if self.logs == 1: print('Initialization failed')