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]
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]
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
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
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))
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))