def get_settings(): command_username = '******' command_email = 'git config --global user.email' settings = [] output_username = getoutput(command_username) output_email = getoutput(command_email) save_log(command_username, output_username) save_log(command_email, output_email) settings.append(output_username) settings.append(output_email) return settings
def get_commits(): command = 'git log --graph --pretty=format:"%h\n%s\n%an\n%ad"' output = getoutput_lines(command) save_log(command, output[0]) commits = [] i = 0 commit = [] for line in output[1]: j = 0 for char in line: if char == '*' or char == '|' or char == '\\' or char == '/' or char == '_' or char == ' ': j += 1 else: break commit.append(line[j:]) i += 1 if i == 4: i = 0 commits.append(commit) commit = [] i = 0 while i < len(commits): command = 'git branch -r --contains ' + commits[i][0] output = getoutput(command) if output != '': break commits[i][1] = '[not pushed] ' + commits[i][1] i += 1 return commits
def clone_repository(window, source, destination): cloning_timeout = 5 command = 'git clone %s %s' % (source, destination) child = pexpect.spawn(command) try: child.expect("Username*", timeout=cloning_timeout) dialog = AuthorizationWrapper(window) dialog.exec_() child.sendline(dialog.username) child.expect("Password*", timeout=cloning_timeout) child.sendline(dialog.password) child.expect(pexpect.EOF) info = child.before except (pexpect.TIMEOUT, pexpect.EOF): rm_command = 'rm -rf ' + destination system(rm_command) try: child.expect("Password*", timeout=cloning_timeout) dialog = AuthorizationWrapper(window) dialog.ui.Username_lineEdit.setText("Not needed") dialog.ui.Username_lineEdit.setReadOnly(True) dialog.exec_() child.sendline(dialog.password) child.expect(pexpect.EOF) info = child.before except (pexpect.TIMEOUT, pexpect.EOF): system(rm_command) if source.startswith('https://') and '@' in source: return (False, 'Timeout error!') else: info = getoutput(command) save_log(command, info) return (True, info)
def push(window, additional_args=None): child = pexpect.spawn('git push') try: child.expect("Username*", timeout=2) dialog = AuthorizationWrapper(window) dialog.exec_() child.sendline(dialog.username) child.expect("Password*", timeout=2) child.sendline(dialog.password) child.expect(pexpect.EOF) info = child.before except (pexpect.TIMEOUT, pexpect.EOF): try: child.expect("Password*", timeout=2) dialog = AuthorizationWrapper(window) dialog.ui.Username_lineEdit.setText("Not needed") dialog.ui.Username_lineEdit.setReadOnly(True) dialog.exec_() child.sendline(dialog.password) child.expect(pexpect.EOF) info = child.before except (pexpect.TIMEOUT, pexpect.EOF): if get_url().startswith('https://'): info = 'Timeout error!' else: info = getoutput('git push') save_log('git push', info) return info
def check_repository(path): chdir(path) command = 'git rev-parse --git-dir' output = getoutput(command) save_log(command, output) if 'fatal' in output: return False return True
def create_branch(window, branch): command = 'git checkout -b ' + branch save_log(command, getoutput(command)) url = get_url() additional_args = [] if url.startswith("git@"): additional_args.append('origin') additional_args.append(branch) return push(window, additional_args)
def predict(self): with tf.Session() as sess: encoder_inputs, decoder_inputs, target_weights, outputs, loss, update, saver, learning_rate_decay_op, learning_rate = get_model( feed_previous=True) saver.restore(sess, self.output_dir) input_seq = getinput() if self.judge(input_seq): input_seq = input_seq.strip() input_id_list = self.get_id_list_from(input_seq) if (len(input_id_list)): sample_encoder_inputs, sample_decoder_inputs, sample_target_weights = self.seq_to_encoder( ' '.join([str(v) for v in input_id_list])) input_feed = {} for l in range(self.input_seq_len): input_feed[ encoder_inputs[l].name] = sample_encoder_inputs[l] for l in range(self.output_seq_len): input_feed[ decoder_inputs[l].name] = sample_decoder_inputs[l] input_feed[ target_weights[l].name] = sample_target_weights[l] input_feed[decoder_inputs[ self.output_seq_len].name] = np.zeros([2], dtype=np.int32) outputs_seq = sess.run(outputs, input_feed) outputs_seq = [ int(np.argmax(logit[0], axis=0)) for logit in outputs_seq ] if self.EOS_ID in outputs_seq: outputs_seq = outputs_seq[:outputs_seq.index(self. EOS_ID)] outputs_seq = [ self.wordToken.id2word(v) for v in outputs_seq ] text = " ".join(outputs_seq) return text else: pass else: return getoutput(input_seq)
def diff(filename): command = 'git diff ' + filename output = getoutput(command) save_log(command, output) return output
def clean(file): command = 'git clean -f ' + file output = getoutput(command) save_log(command, output)
def stash(): command = 'git stash' output = getoutput(command) save_log(command, output) return output
def drop_stash(stash): command = 'git stash drop ' + stash output = getoutput(command) save_log(command, output) return output
def apply_stash(stash): command = 'git stash apply ' + stash save_log(command, getoutput(command))
def change_local_branch(branch): command = 'git checkout ' + branch save_log(command, getoutput(command))
def commit_amend(message): command = 'git commit --amend -m "%s"' % message output = getoutput(command) save_log(command, output) return output
def git_rm(file): command = 'git rm ' + file output = getoutput(command) save_log(command, output)
def cherry_pick(window, branch, commit): change_branch(branch) command = 'git cherry-pick ' + commit output = getoutput(command) save_log(command, output) return output
def delete_branch(branch): command = 'git branch -d ' + branch output = getoutput(command) save_log(command, output) return output
def change_remote_branch(branch, new_name): command = 'git checkout -b %s %s' % (new_name, branch) output = getoutput(command) save_log(command, output) return output
def git_check_out(file): command = 'git checkout -- ' + file output = getoutput(command) save_log(command, output)
def get_url(): command = "git config --get remote.origin.url" output = getoutput(command) save_log(command, output) return output
def git_add(file): command = 'git add ' + file output = getoutput(command) save_log(command, output)
def to_string(files, command): strfiles = " ".join(files) command += strfiles output = getoutput(command) save_log(command, output)