Example #1
0
 def _tracadmin(self, *args):
     """Internal utility method for calling trac-admin"""
     proc = Popen([sys.executable, os.path.join(self.trac_src, 'trac',
                   'admin', 'console.py'), self.tracdir],
                  stdin=PIPE, stdout=PIPE, stderr=STDOUT,
                  close_fds=close_fds, cwd=self.command_cwd)
     if args:
         if any('\n' in arg for arg in args):
             raise Exception(
                 "trac-admin in interactive mode doesn't support "
                 "arguments with newline characters: %r" % (args,))
         # Don't quote first token which is sub-command name
         input = ' '.join(('"%s"' % to_utf8(arg) if idx else arg)
                          for idx, arg in enumerate(args))
     else:
         input = None
     out = proc.communicate(input=input)[0]
     if proc.returncode:
         print(out)
         logfile.write(out)
         raise Exception("Failed while running trac-admin with arguments %r.\n"
                         "Exitcode: %s \n%s"
                         % (args, proc.returncode, out))
     else:
         # trac-admin is started in interactive mode, so we strip away
         # everything up to the to the interactive prompt
         return re.split(r'\r?\nTrac \[[^]]+\]> ', out, 2)[1]
Example #2
0
 def _tracadmin(self, *args):
     """Internal utility method for calling trac-admin"""
     proc = Popen([
         sys.executable,
         os.path.join(self.trac_src, 'trac', 'admin', 'console.py'),
         self.tracdir
     ],
                  stdin=PIPE,
                  stdout=PIPE,
                  stderr=STDOUT,
                  close_fds=close_fds,
                  cwd=self.command_cwd)
     if args:
         if any('\n' in arg for arg in args):
             raise Exception(
                 "trac-admin in interactive mode doesn't support "
                 "arguments with newline characters: %r" % (args, ))
         # Don't quote first token which is sub-command name
         input = ' '.join(('"%s"' % to_utf8(arg) if idx else arg)
                          for idx, arg in enumerate(args))
     else:
         input = None
     out = proc.communicate(input=input)[0]
     if proc.returncode:
         print(out)
         logfile.write(out)
         raise Exception(
             "Failed while running trac-admin with arguments %r.\n"
             "Exitcode: %s \n%s" % (args, proc.returncode, out))
     else:
         # trac-admin is started in interactive mode, so we strip away
         # everything up to the to the interactive prompt
         return re.split(r'\r?\nTrac \[[^]]+\]> ', out, 2)[1]
Example #3
0
 def call_in_dir(self, dir, args, environ=None):
     proc = Popen(args, stdout=PIPE, stderr=logfile,
                  close_fds=close_fds, cwd=dir, env=environ)
     (data, _) = proc.communicate()
     if proc.wait():
         raise Exception('Unable to run command %s in %s' %
                         (args, dir))
     logfile.write(data)
     return data
Example #4
0
 def call_in_dir(self, dir, args, environ=None):
     proc = Popen(args, stdout=PIPE, stderr=logfile,
         close_fds=close_fds, cwd=dir, env=environ)
     (data, _) = proc.communicate()
     if proc.wait():
         raise Exception('Unable to run command %s in %s' %
                         (args, dir))
     logfile.write(data)
     return data
Example #5
0
    def call_in_workdir(self, args):
        proc = Popen(args, stdout=PIPE, stderr=logfile,
                     close_fds=close_fds, cwd=self.work_dir())
        (data, _) = proc.communicate()
        if proc.wait():
            raise Exception('Unable to run command %s in %s' %
                            (args, self.work_dir()))

        logfile.write(data)
        return data
Example #6
0
 def _tracadmin(self, *args):
     """Internal utility method for calling trac-admin"""
     proc = Popen([sys.executable, os.path.join(self.trac_src, 'trac',
                   'admin', 'console.py'), self.tracdir]
                   + list(args), stdout=PIPE, stderr=STDOUT,
                   close_fds=close_fds, cwd=self.command_cwd)
     out = proc.communicate()[0]
     if proc.returncode:
         print(out)
         logfile.write(out)
         raise Exception('Failed with exitcode %s running trac-admin ' \
                         'with %r' % (proc.returncode, args))
Example #7
0
 def _tracadmin(self, *args):
     """Internal utility method for calling trac-admin"""
     proc = Popen([sys.executable, os.path.join(self.trac_src, 'trac',
                   'admin', 'console.py'), self.tracdir]
                   + list(args), stdout=PIPE, stderr=STDOUT,
                   close_fds=close_fds, cwd=self.command_cwd)
     out = proc.communicate()[0]
     if proc.returncode:
         print(out)
         logfile.write(out)
         raise Exception("Failed while running trac-admin with arguments %r.\n"
                         "Exitcode: %s \n%s"
                         % (args, proc.returncode, out))