def push(self, username=None, password=None): if not self.repo_is_defined: error("No Git repository found for the current directory.") self.repo.git.push() return try: pexpect.spawnu('git push') except: try: self.repo.git.push() print("Push was successful") except Exception as e: error("Git push failed!") print(type(e)) return try: g.logfile_read = sys.stdout if not username: username = '' if not password: password = '' while True: i = g.expect([u'Username for .*', u'Password for .*', pexpect.EOF]) if(i == 0): g.send(username+'\n') elif(i == 1): # Python 2 # g.send(codecs.decode(password, 'base64')+'\n') # End Python 2 # Python 3 g.send(str(codecs.decode(password.encode(), 'base64'), 'utf-8')+'\n') # End Python 3 else: break except: print("Notice: Auto-credentials currently not operational") '''
def push(self, username=None, password=None): username = self.conf_parser.get('main', 'git_username') password = self.conf_parser.get('main', 'git_password') if not self.repo_is_defined: if not (self.repo_exists()): error("No Git repository found for the current directory.") return try: g = pexpect.spawnu('git push') except: try: self.repo.git.push() print("Push was successful") except Exception as e: error("Git push failed!") print(type(e)) return try: g.logfile_read = sys.stdout while True: i = g.expect([u'Username for .*', u'Password for .*', pexpect.EOF]) if(i == 0): g.send(username+'\n') elif(i == 1): # Python 2 # g.send(codecs.decode(password, 'base64')+'\n') # End Python 2 # Python 3 g.send(str(codecs.decode(password.encode(), 'base64'), 'utf-8')+'\n') # End Python 3 else: break except Exception as e: print("Notice: Auto-credentials currently not operational") '''
def repo_exists(self, repo_directory=os.getcwd()): while repo_directory and repo_directory != "" and not (os.path.isdir(repo_directory + "/.git")): repo_directory = repo_directory.split(os.sep)[:-1] repo_directory = (os.sep).join(repo_directory) if not repo_directory or repo_directory == "": error("No Git repository found for the current directory.") return False else: self.repo_directory = repo_directory return True
def repo_exists(self, repo_directory=os.getcwd()): while repo_directory and repo_directory != "" and not (os.path.isdir(repo_directory + os.sep+".git")): repo_directory = repo_directory.split(os.sep)[:-1] repo_directory = (os.sep).join(repo_directory) if not repo_directory or repo_directory == "": error("No Git repository found for the current directory.") return False else: self.repo_directory = repo_directory self.initialize_repo() return True
def commit(self, message): if not self.repo_is_defined: error("No Git repository found for the current directory.") return message.rstrip(' ') self.repo.index.commit("Translations updated for " + message)
def add_file(self, file_name): if not self.repo_is_defined: error("No Git repository found for the current directory.") return self.repo.git.add(file_name)