示例#1
0
 def __pipe(self, git_cmd, *cmd_args, **kw):
     kw.setdefault('stdin', PIPE)
     kw.setdefault('stdout', PIPE)
     kw.setdefault('stderr', PIPE)
     return Popen(self.__build_git_cmd(git_cmd, *cmd_args),
                  close_fds=close_fds,
                  **kw)
示例#2
0
 def _spawn_git(self, *args, **kwargs):
     args = map(to_utf8, (self.git_bin,) + args)
     kwargs.setdefault('stdin', PIPE)
     kwargs.setdefault('stdout', PIPE)
     kwargs.setdefault('stderr', PIPE)
     kwargs.setdefault('cwd', self.repos_path)
     return Popen(args, close_fds=close_fds, **kwargs)
示例#3
0
 def test_python_with_optimizations_returns_error(self):
     """Error is returned when a command is executed in interpreter
     with optimizations enabled.
     """
     with Popen((sys.executable, '-O', '-m', 'trac.admin.console', 'help'),
                stdin=PIPE, stdout=PIPE, stderr=PIPE,
                close_fds=close_fds) as proc:
         stdout, stderr = proc.communicate(input='')
     self.assertEqual(2, proc.returncode)
     self.assertEqual("Python with optimizations is not supported.",
                      stderr.strip())
示例#4
0
文件: main.py 项目: hanotch/trac
 def test_python_with_optimizations_raises_environment_error(self):
     """EnvironmentError exception is raised when dispatching request
     with optimizations enabled.
     """
     with Popen((sys.executable, '-O', '-c',
                 'from trac.web.main import dispatch_request; '
                 'dispatch_request({}, None)'), stdin=PIPE,
                stdout=PIPE, stderr=PIPE, close_fds=close_fds) as proc:
         stdout, stderr = proc.communicate()
     self.assertEqual(1, proc.returncode)
     self.assertIn("EnvironmentError: Python with optimizations is not "
                   "supported.", stderr)
示例#5
0
文件: env.py 项目: hanotch/trac
    def _create_env(self, env_path, dburi):
        parser = RawConfigParser()
        parser.read(self.env.config_file_path)
        options = dict(((section, name), value)
                       for section in parser.sections()
                       for name, value in parser.items(section))
        options[('trac', 'database')] = dburi
        options = sorted((section, name, value)
                         for (section, name), value in options.iteritems())

        class MigrateEnvironment(Environment):
            abstract = True
            required = False

            def is_component_enabled(self, cls):
                name = self._component_name(cls)
                if not any(
                        name.startswith(mod) for mod in ('trac.', 'tracopt.')):
                    return False
                return Environment.is_component_enabled(self, cls)

        # create an environment without plugins
        env = MigrateEnvironment(env_path, create=True, options=options)
        env.shutdown()
        # copy plugins directory
        os.rmdir(env.plugins_dir)
        shutil.copytree(self.env.plugins_dir, env.plugins_dir)
        # create tables for plugins to upgrade in other process
        with Popen(
            (sys.executable, '-m', 'trac.admin.console', env_path, 'upgrade'),
                stdin=PIPE,
                stdout=PIPE,
                stderr=PIPE,
                close_fds=close_fds) as proc:
            stdout, stderr = proc.communicate(input='')
        if proc.returncode != 0:
            raise TracError("upgrade command failed (stdout %r, stderr %r)" %
                            (stdout, stderr))
        return Environment(env_path)