def _Debug(host, env): try: if env == "eclipse": if portable.isUnix(): sys.path.append( "/opt/eclipseCPy/plugins/org.python.pydev_2.7.1.2012100913/pysrc" ) else: sys.path.append( "C:\Program Files\eclipsePython\plugins\org.python.pydev_2.7.1.2012100913\pysrc" ) import pydevd as pydevd elif env == "intellij": if portable.isUnix(): sys.path.append( "/home/mputz/.IntelliJIdea12/config/plugins/python/helpers/pydev" ) sys.path.append( "/home/mputz/.IntelliJIdea12/config/plugins/python/pycharm-debug-py3k.egg" ) else: sys.path.append( "C:\\Users\mputz\.IntelliJIdea12\config\plugins\python\pycharm-debug-py3k.egg" ) sys.path.append( "C:\\Users\mputz\.IntelliJIdea12\config\plugins\python\helpers\pydev" ) import pydevd pydevd.settrace(host, port=19499, stdoutToServer=True, stderrToServer=True) except ImportError: traceback.print_exc(file=sys.stdout) sys.stderr.write( "Error: you must add pydevd in a pysrc folder (e.g. in eclipse plugin) to your PYTHONPATH.\n" ) sys.exit(1)
def _Debug(host, env): try: if env == "eclipse": if portable.isUnix(): sys.path.append("/opt/eclipseCPy/plugins/org.python.pydev_2.7.1.2012100913/pysrc") else: sys.path.append("C:\Program Files\eclipsePython\plugins\org.python.pydev_2.7.1.2012100913\pysrc") import pydevd as pydevd elif env == "intellij": if portable.isUnix(): sys.path.append("/home/mputz/.IntelliJIdea12/config/plugins/python/helpers/pydev") sys.path.append("/home/mputz/.IntelliJIdea12/config/plugins/python/pycharm-debug-py3k.egg") else: sys.path.append("C:\\Users\mputz\.IntelliJIdea12\config\plugins\python\pycharm-debug-py3k.egg") sys.path.append("C:\\Users\mputz\.IntelliJIdea12\config\plugins\python\helpers\pydev") import pydevd pydevd.settrace(host, port=19499, stdoutToServer=True, stderrToServer=True) except ImportError: traceback.print_exc(file=sys.stdout) sys.stderr.write("Error: you must add pydevd in a pysrc folder (e.g. in eclipse plugin) to your PYTHONPATH.\n") sys.exit(1)
def Execute(self, opt, args): if not opt.command: self.Usage() cmd = [opt.command[0]] shell = True if re.compile(r'^[a-z0-9A-Z_/\.-]+$').match(cmd[0]): shell = False if shell and portable.isPosix(): cmd.append(cmd[0]) cmd.extend(opt.command[1:]) if opt.project_header \ and not shell \ and cmd[0] == 'git': # If this is a direct git command that can enable colorized # output and the user prefers coloring, add --color into the # command line because we are going to wrap the command into # a pipe and git won't know coloring should activate. # for cn in cmd[1:]: if not cn.startswith('-'): break else: cn = None # pylint: disable=W0631 if cn and cn in _CAN_COLOR: class ColorCmd(Coloring): def __init__(self, config, cmd): Coloring.__init__(self, config, cmd) if ColorCmd(self.manifest.manifestProject.config, cn).is_on: cmd.insert(cmd.index(cn) + 1, '--color') # pylint: enable=W0631 mirror = self.manifest.IsMirror out = ForallColoring(self.manifest.manifestProject.config) out.redirect(sys.stdout) rc = 0 first = True for project in self.GetProjects(args): env = os.environ.copy() def setenv(name, val): if val is None: val = '' env[name] = val setenv('REPO_PROJECT', project.name) setenv('REPO_PATH', project.relpath) setenv('REPO_REMOTE', project.remote.name) setenv('REPO_LREV', project.GetRevisionId()) setenv('REPO_RREV', project.revisionExpr) for a in project.annotations: setenv("REPO__%s" % (a.name), a.value) if mirror: setenv('GIT_DIR', project.gitdir) cwd = project.gitdir else: cwd = project.worktree if not os.path.exists(cwd): if (opt.project_header and opt.verbose) \ or not opt.project_header: print('skipping %s/' % project.relpath, file=sys.stderr) continue if opt.project_header: stdin = subprocess.PIPE stdout = subprocess.PIPE stderr = subprocess.PIPE else: stdin = None stdout = None stderr = None if not portable.isUnix(): if type(cmd) is list: cmd = " ".join(cmd) if IsTrace(): Trace("execute command: %s" % str(cmd).replace("%", "%%")) Trace("environment is: %s" % str(env)) p = subprocess.Popen(cmd, cwd=cwd, shell=shell, env=env, stdin=stdin, stdout=stdout, stderr=stderr) if opt.project_header: class sfd(object): def __init__(self, fd, dest): self.fd = fd self.dest = dest def fileno(self): return self.fd.fileno() # empty = True # errbuf = '' # # p.stdin.close() # s_in = [sfd(p.stdout, sys.stdout), # sfd(p.stderr, sys.stderr)] # # for s in s_in: # flags = fcntl.fcntl(s.fd, fcntl.F_GETFL) # fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) # # while s_in: # in_ready, _out_ready, _err_ready = select.select(s_in, [], []) # for s in in_ready: # buf = s.fd.read(4096) # if not buf: # s.fd.close() # s_in.remove(s) # continue # # if not opt.verbose: # if s.fd != p.stdout: # errbuf += buf # continue # # if empty: # if first: # first = False # else: # out.nl() # out.project('project %s/', project.relpath) # out.nl() # out.flush() # if errbuf: # sys.stderr.write(errbuf) # sys.stderr.flush() # errbuf = '' # empty = False # # s.dest.write(buf) # s.dest.flush() r = p.wait() if r != 0: if r != rc: rc = r if opt.abort_on_errors: print("error: %s: Aborting due to previous error" % project.relpath, file=sys.stderr) sys.exit(r) if rc != 0: sys.exit(rc)