def test_create_ssh_wrapper(self): filename = os.path.join(appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper') create_ssh_wrapper() with open(filename, 'r') as handle: data = handle.read() self.assertTrue(ssh_file('known_hosts') in data) self.assertTrue(ssh_file('id_rsa') in data) self.assertTrue(appsettings.DATA_DIR in data) self.assertTrue(os.access(filename, os.X_OK))
def test_create_ssh_wrapper(self): filename = os.path.join( appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper' ) create_ssh_wrapper() with open(filename, 'r') as handle: data = handle.read() self.assertTrue(ssh_file('known_hosts') in data) self.assertTrue(ssh_file('id_rsa') in data) self.assertTrue(appsettings.DATA_DIR in data) self.assertTrue( os.access(filename, os.X_OK) )
def test_create_ssh_wrapper(self): check_data_writable() filename = os.path.join(settings.DATA_DIR, 'ssh', SSH_WRAPPER) create_ssh_wrapper() with open(filename, 'r') as handle: data = handle.read() self.assertTrue(ssh_file('known_hosts') in data) self.assertTrue(ssh_file('id_rsa') in data) self.assertTrue(settings.DATA_DIR in data) self.assertTrue(os.access(filename, os.X_OK)) # Second run should not touch the file timestamp = os.stat(filename).st_mtime create_ssh_wrapper() self.assertEqual(timestamp, os.stat(filename).st_mtime)
def test_create_ssh_wrapper(self): try: backup_dir = appsettings.DATA_DIR appsettings.DATA_DIR = self._tempdir filename = os.path.join(appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper') create_ssh_wrapper() with open(filename, 'r') as handle: data = handle.read() self.assertTrue(ssh_file('known_hosts') in data) self.assertTrue(ssh_file('id_rsa') in data) self.assertTrue(self._tempdir in data) self.assertTrue(os.access(filename, os.X_OK)) finally: appsettings.DATA_DIR = backup_dir
def test_create_ssh_wrapper(self): try: backup_dir = appsettings.DATA_DIR appsettings.DATA_DIR = self._tempdir filename = os.path.join( appsettings.DATA_DIR, 'ssh', 'ssh-weblate-wrapper' ) create_ssh_wrapper() with open(filename, 'r') as handle: data = handle.read() self.assertTrue(ssh_file('known_hosts') in data) self.assertTrue(ssh_file('id_rsa') in data) self.assertTrue(self._tempdir in data) self.assertTrue( os.access(filename, os.X_OK) ) finally: appsettings.DATA_DIR = backup_dir
def _getenv(): """Generates environment for process execution.""" env = {'GIT_SSH': ssh_file(SSH_WRAPPER)} # Add path to config if it exists userconfig = os.path.expanduser('~/.config/hub') if os.path.exists(userconfig): env['HUB_CONFIG'] = userconfig return get_clean_env(env)
def _getenv(): """Generates environment for process execution.""" env = {"GIT_SSH": ssh_file(SSH_WRAPPER)} # Add path to config if it exists userconfig = os.path.expanduser("~/.config/hub") if os.path.exists(userconfig): env["HUB_CONFIG"] = userconfig return get_clean_env(env)
def _popen(cls, args, cwd=None): ''' Executes the command using popen. ''' if args is None: raise RepositoryException(0, 'Not supported functionality', '') args = [cls._cmd] + args process = subprocess.Popen( args, cwd=cwd, env=get_clean_env({'GIT_SSH': ssh_file(SSH_WRAPPER)}), stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) output, output_err = process.communicate() retcode = process.poll() if retcode: raise RepositoryException(retcode, output_err, output) return output
def check_config(self): """ Checks VCS configuration. """ # We directly set config as it takes same time as reading it self.set_config('ui.ssh', ssh_file(SSH_WRAPPER))
def _getenv(): """Generates environment for process execution.""" return get_clean_env({'GIT_SSH': ssh_file(SSH_WRAPPER)})
def _getenv(): """Generates environment for process execution.""" return get_clean_env({"GIT_SSH": ssh_file(SSH_WRAPPER)})