Commit 267823ce authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Julien Muchembled

Various fixups for Python 3

parent e80ca878
......@@ -252,7 +252,7 @@ class Babel:
unidentified = set(n)
self.neighbours = neighbours = {}
a = len(self.network)
logging.info("Routes: %r", routes)
logging.debug("Routes: %r", routes)
for route in routes:
assert route.flags & 1, route # installed
if route.prefix.startswith(b'\0\0\0\0\0\0\0\0\0\0\xff\xff'):
......
......@@ -8,15 +8,6 @@ HMAC_LEN = len(hashlib.sha1(b'').digest())
class ReexecException(Exception):
pass
try:
subprocess.CalledProcessError(0, '', '')
except TypeError: # BBB: Python < 2.7
def __init__(self, returncode, cmd, output=None):
self.returncode = returncode
self.cmd = cmd
self.output = output
subprocess.CalledProcessError.__init__ = __init__
logging_levels = logging.WARNING, logging.INFO, logging.DEBUG, 5
class FileHandler(logging.FileHandler):
......@@ -167,17 +158,19 @@ class Popen(subprocess.Popen):
def send_signal(self, sig):
logging.info('Sending signal %s to pid %s %r',
sig, self.pid, self._args)
super(Popen, self).send_signal(sig)
# We don't need the change from https://bugs.python.org/issue38630
# and it would complicate stop()
assert self.returncode is None
os.kill(self.pid, sig)
def stop(self):
if self.pid and self.returncode is None:
self.terminate()
t = threading.Timer(5, self.kill)
t.start()
r = os.waitid(os.P_PID, self.pid, os.WNOWAIT)
os.waitid(os.P_PID, self.pid, os.WEXITED | os.WNOWAIT)
t.cancel()
self.poll()
return r
def setCloexec(fd):
......
......@@ -6,15 +6,9 @@ def _git_call(*args):
return _S.call(("git", "-c", "safe.directory=" + _d) + args, cwd=_d)
def _git_output(*args):
p = _S.Popen(
return _S.check_output(
("git", "-c", "safe.directory=" + _d) + args,
cwd=_d,
stdout=_S.PIPE,
stderr=_S.PIPE)
out, err = p.communicate()
if p.returncode:
raise _S.CalledProcessError(p.returncode, "git", err)
return out.strip()
cwd=_d, text=True).strip()
_git_call("update-index", "-q", "--refresh")
dirty = _git_call("diff-index", "--quiet", "HEAD", "--")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment