if not self.localhost and not self.get("username"):
msg = "Can't resolve OS, insufficient data "
self.error(msg)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
out = self.get_os()
trace = traceback.format_exc()
msg = "Deploy failed. Unresponsive node {} -- traceback {}".format(self.get("hostname"), trace)
self.error(msg)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
self.find_home()
# adding the avoided pids filtered above (avoid_kill) to allow users keep process
# alive when using besides ssh connections
kill_pids = set(pids_temp.items()) - set(pids.items())
- kill_pids = ' '.join(dict(kill_pids).keys())
+ kill_pids = ' '.join(list(dict(kill_pids).keys()))
# removing pids from beside connections and its process
kill_pids = kill_pids.split(' ')
# If dst files should not be overwritten, check that the files do not
# exits already
if isinstance(src, str):
- src = map(str.strip, src.split(";"))
+ src = list(map(str.strip, src.split(";")))
if overwrite == False:
src = self.filter_existing_files(src, dst)
msg = "{} out: {} err: {}".format(msg, out, err)
if raise_on_error:
- raise RuntimeError, msg
+ raise RuntimeError(msg)
return ((out, err), proc)
self.error(msg, out, err)
if raise_on_error:
- raise RuntimeError, msg
+ raise RuntimeError(msg)
return ((out, err), proc)
else:
msg = "Error installing packages ( OS not known ) "
self.error(msg, self.os)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
return command
else:
msg = "Error removing packages ( OS not known ) "
self.error(msg)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
run_home = run_home or home
if isinstance(paths, str):
paths = [paths]
- cmd = " ; ".join(map(lambda path: "rm -rf {}".format(path), paths))
+ cmd = " ; ".join(["rm -rf {}".format(path) for path in paths])
return self.execute(cmd, with_lock = True)
msg = " Failed to run command '{}' ".format(command)
self.error(msg, out, err)
if raise_on_error:
- raise RuntimeError, msg
+ raise RuntimeError(msg)
# Wait for pid file to be generated
pid, ppid = self.wait_pid(
self.error(msg, eout, err)
if raise_on_error:
- raise RuntimeError, msg
+ raise RuntimeError(msg)
(out, oerr), proc = self.check_output(home, stdout)
pid = ppid = None
delay = 1.0
- for i in xrange(2):
+ for i in range(2):
pidtuple = self.getpid(home = home, pidfile = pidfile)
if pidtuple:
self.error(msg)
if raise_on_error:
- raise RuntimeError, msg
+ raise RuntimeError(msg)
return pid, ppid
if not self._home_dir:
self.error(msg)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
def filter_existing_files(self, src, dst):
""" Removes files that already exist in the Linux host from src list
if len(src) > 1 else {dst: src[0]}
command = []
- for d in dests.keys():
+ for d in list(dests.keys()):
command.append(" [ -f {dst} ] && echo '{dst}' ".format(dst=d) )
command = ";".join(command)
(out, err), proc = self.execute(command, retry = 1, with_lock = True)
- for d in dests.keys():
+ for d in list(dests.keys()):
if out.find(d) > -1:
del dests[d]
if not dests:
return []
- return dests.values()
+ return list(dests.values())