diff --git a/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py b/LTA/LTAIngest/LTAIngestServer/LTAIngestTransferServer/lib/ltacp.py index c0b36f7e98b3b5d7c95d1f0626cd7ba15ee5c7ad..7bb3c84851ba3f5579737e8162c8e736cec7d878 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 b677b8a337a55528b9728a6c522df331a84fffb8..0d16bba59dc75205e7927d654aa3fc058200e478 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')