Show More
@@ -165,17 +165,11 b' def testpid(pid):' | |||
|
165 | 165 | return inst.errno != errno.ESRCH |
|
166 | 166 | |
|
167 | 167 | def explain_exit(code): |
|
168 |
"""return a 2-tuple (desc, code) describing a process |
|
|
169 | if os.WIFEXITED(code): | |
|
170 | val = os.WEXITSTATUS(code) | |
|
171 |
return _("exited with status %d") % |
|
|
172 | elif os.WIFSIGNALED(code): | |
|
173 | val = os.WTERMSIG(code) | |
|
174 | return _("killed by signal %d") % val, val | |
|
175 | elif os.WIFSTOPPED(code): | |
|
176 | val = os.WSTOPSIG(code) | |
|
177 | return _("stopped by signal %d") % val, val | |
|
178 | raise ValueError(_("invalid exit code")) | |
|
168 | """return a 2-tuple (desc, code) describing a subprocess status | |
|
169 | (codes from kill are negative - not os.system/wait encoding)""" | |
|
170 | if code >= 0: | |
|
171 | return _("exited with status %d") % code, code | |
|
172 | return _("killed by signal %d") % -code, -code | |
|
179 | 173 | |
|
180 | 174 | def isowner(st): |
|
181 | 175 | """Return True if the stat object st is from the current user.""" |
@@ -357,21 +357,14 b' def system(cmd, environ={}, cwd=None, on' | |||
|
357 | 357 | if val is True: |
|
358 | 358 | return '1' |
|
359 | 359 | return str(val) |
|
360 | oldenv = {} | |
|
361 | for k in environ: | |
|
362 | oldenv[k] = os.environ.get(k) | |
|
363 | if cwd is not None: | |
|
364 | oldcwd = os.getcwd() | |
|
365 | 360 | origcmd = cmd |
|
366 | 361 | if os.name == 'nt': |
|
367 | 362 | cmd = '"%s"' % cmd |
|
368 | try: | |
|
369 |
|
|
|
370 | os.environ[k] = py2shell(v) | |
|
371 | os.environ['HG'] = hgexecutable() | |
|
372 | if cwd is not None and oldcwd != cwd: | |
|
373 | os.chdir(cwd) | |
|
374 | rc = os.system(cmd) | |
|
363 | env = dict(os.environ) | |
|
364 | env.update((k, py2shell(v)) for k, v in environ.iteritems()) | |
|
365 | env['HG'] = hgexecutable() | |
|
366 | rc = subprocess.call(cmd, shell=True, close_fds=closefds, | |
|
367 | env=env, cwd=cwd) | |
|
375 | 368 |
|
|
376 | 369 |
|
|
377 | 370 |
|
@@ -384,14 +377,6 b' def system(cmd, environ={}, cwd=None, on' | |||
|
384 | 377 |
|
|
385 | 378 |
|
|
386 | 379 |
|
|
387 | finally: | |
|
388 | for k, v in oldenv.iteritems(): | |
|
389 | if v is None: | |
|
390 | del os.environ[k] | |
|
391 | else: | |
|
392 | os.environ[k] = v | |
|
393 | if cwd is not None and oldcwd != cwd: | |
|
394 | os.chdir(oldcwd) | |
|
395 | 380 | |
|
396 | 381 | def checksignature(func): |
|
397 | 382 | '''wrap a function with code to check for calling errors''' |
General Comments 0
You need to be logged in to leave comments.
Login now