Пример #1
0
 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))
Пример #2
0
 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)
     )
Пример #3
0
 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)
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
 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
Пример #9
0
 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
Пример #10
0
 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))
Пример #11
0
 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))
Пример #12
0
 def _getenv():
     """Generates environment for process execution."""
     return get_clean_env({'GIT_SSH': ssh_file(SSH_WRAPPER)})
Пример #13
0
 def _getenv():
     """Generates environment for process execution."""
     return get_clean_env({"GIT_SSH": ssh_file(SSH_WRAPPER)})