From 27fae9db2fff21f84052c8c5b25d5a9b82d8cf27 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Tue, 16 Apr 2019 14:58:57 +0000 Subject: [PATCH] SW-658: python3 adaptation --- .../LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py | 9 +++++---- LTA/ltastorageoverview/lib/scraper.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py b/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py index c0b36f7e98b..7bb3c84851b 100755 --- a/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py +++ b/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py @@ -24,6 +24,7 @@ from lofar.common.subprocess_utils import PipeReader, communicate_returning_stri from lofar.lta.ingest.common.config import hostnameToIp from lofar.lta.ingest.server.config import GLOBUS_TIMEOUT from lofar.lta.ingest.common.srm import * +from lofar.common.subprocess_utils import communicate_returning_strings logger = logging.getLogger() @@ -142,7 +143,7 @@ class LtaCp: self.started_procs[proc] = cmd # block until find is finished - proc.communicate() + communicate_returning_strings(proc) del self.started_procs[proc] logger.info('ltacp %s: source %s %s' % (self.logId, path, 'exists' if proc.returncode==0 else 'does not exist')) @@ -165,7 +166,7 @@ class LtaCp: self.started_procs[proc] = cmd # block until find is finished - proc.communicate() + communicate_returning_strings(proc) del self.started_procs[proc] logger.info("ltacp %s: '%s' of path '%s' %s" % (self.logId, root_dir, path, 'is mounted' if proc.returncode==0 else 'is not mounted')) @@ -617,13 +618,13 @@ class LtaCp: '''remove a file (or fifo) on a remote host. Test if file exists before deleting.''' cmd_remote_ls = self.ssh_cmd + ['ls %s' % (self.remote_data_fifo,)] p_remote_ls = Popen(cmd_remote_ls, stdout=PIPE, stderr=PIPE) - p_remote_ls.communicate() + communicate_returning_strings(p_remote_ls) if p_remote_ls.returncode == 0: cmd_remote_rm = self.ssh_cmd + ['rm %s' % (self.remote_data_fifo,)] logger.info('ltacp %s: removing remote fifo. executing: %s' % (self.logId, ' '.join(cmd_remote_rm))) p_remote_rm = Popen(cmd_remote_rm, stdout=PIPE, stderr=PIPE) - p_remote_rm.communicate() + communicate_returning_strings(p_remote_rm) if p_remote_rm.returncode != 0: logger.error("Could not remove remote fifo %s@%s:%s\n%s" % (self.src_user, self.src_host, self.remote_data_fifo, p_remote_rm.stderr)) diff --git a/LTA/ltastorageoverview/lib/scraper.py b/LTA/ltastorageoverview/lib/scraper.py index b677b8a337a..0d16bba59dc 100755 --- a/LTA/ltastorageoverview/lib/scraper.py +++ b/LTA/ltastorageoverview/lib/scraper.py @@ -35,6 +35,7 @@ import threading import multiprocessing from lofar.lta.ltastorageoverview import store from lofar.common.util import humanreadablesize +from lofar.common.subprocess_utils import communicate_returning_strings from random import random, randint logger = logging.getLogger() @@ -142,7 +143,7 @@ class Location: logger.debug(' '.join(cmd)) p = subprocess.Popen(cmd, stdin=open('/dev/null'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) - logs = p.communicate() + logs = communicate_returning_strings(p) # logger.debug('Shell command for %s exited with code %s' % (self.path(), p.returncode)) loglines = logs[0].split('\n') -- GitLab