# 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())
+ # py2/py3 : keep it simple
+ kill_pids = ' '.join(kill_pids)
# removing pids from beside connections and its process
kill_pids = kill_pids.split(' ')
if text and not os.path.isfile(src):
# src is text input that should be uploaded as file
# create a temporal file with the content to upload
- f = tempfile.NamedTemporaryFile(delete=False)
+ # in python3 we need to open in binary mode if str is bytes
+ mode = 'w' if isinstance(src, str) else 'wb'
+ f = tempfile.NamedTemporaryFile(mode=mode, delete=False)
f.write(src)
f.close()
src = f.name
# If dst files should not be overwritten, check that the files do not
- # exits already
+ # exist already
if isinstance(src, str):
- src = map(str.strip, src.split(";"))
+ src = [s.strip() for s in src.split(";")]
if overwrite == False:
src = self.filter_existing_files(src, dst)
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)
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:
if len(src) > 1 else {dst: src[0]}
command = []
- for d in dests.keys():
+ for d in dests:
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 dests:
if out.find(d) > -1:
del dests[d]