diff --git a/SAS/DataManagement/Cleanup/CleanupService/service.py b/SAS/DataManagement/Cleanup/CleanupService/service.py index 63a56a9d6cee0767d33b5c615dd46ffbef09d487..59969e3af9ee0eb4fc87a94ca8d2f485d27e3382 100644 --- a/SAS/DataManagement/Cleanup/CleanupService/service.py +++ b/SAS/DataManagement/Cleanup/CleanupService/service.py @@ -16,6 +16,7 @@ from lofar.messaging.Service import MessageHandlerInterface from lofar.messaging import setQpidLogLevel from lofar.common.util import waitForInterrupt, convertIntKeysToString from lofar.common.util import humanreadablesize +from lofar.common.subprocess_utils import communicate_returning_strings from lofar.sas.datamanagement.common.config import CEP4_DATA_MOUNTPOINT from lofar.sas.datamanagement.common.path import PathResolver @@ -337,7 +338,7 @@ class CleanupHandler(MessageHandlerInterface): cmd = ['ssh', 'lofarsys@head01.cep4.control.lofar'] + cmd logger.info(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode == 0: message = "Deleted %s in '%s'" % (du_result.get('disk_usage_readable', '?B'), path) diff --git a/SAS/DataManagement/DataManagementCommon/path.py b/SAS/DataManagement/DataManagementCommon/path.py index cee10e5e5fe7ba03743e793f98039b39dc1632bd..ee580f6ddc2186eb70044473ec03230ba9b3a25a 100644 --- a/SAS/DataManagement/DataManagementCommon/path.py +++ b/SAS/DataManagement/DataManagementCommon/path.py @@ -7,6 +7,7 @@ import socket import subprocess from lofar.common import isProductionEnvironment, isTestEnvironment +from lofar.common.subprocess_utils import communicate_returning_strings from lofar.sas.datamanagement.common.config import CEP4_DATA_MOUNTPOINT @@ -171,7 +172,7 @@ class PathResolver: cmd = ['ssh', 'lofarsys@head.cep4.control.lofar'] + cmd logger.debug(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode != 0: # lfs puts it's error message in stdout @@ -193,7 +194,7 @@ class PathResolver: cmd = ['ssh', 'lofarsys@head.cep4.control.lofar'] + cmd logger.debug(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode != 0 and 'No such file or directory' in err: return False diff --git a/SAS/DataManagement/StorageQueryService/diskusage.py b/SAS/DataManagement/StorageQueryService/diskusage.py index 77fbb8b67c03d32e6bf294731f59571bc5127db7..6c7b0a2b24a2c6f14907c936bcfa42502c535281 100644 --- a/SAS/DataManagement/StorageQueryService/diskusage.py +++ b/SAS/DataManagement/StorageQueryService/diskusage.py @@ -7,6 +7,7 @@ import socket import os.path from optparse import OptionParser from lofar.common.util import humanreadablesize +from lofar.common.subprocess_utils import communicate_returning_strings from lofar.sas.datamanagement.common.config import CEP4_DATA_MOUNTPOINT from lofar.sas.datamanagement.common.path import PathResolver @@ -40,7 +41,7 @@ def getDiskUsageForPath_rbh_du(path): logger.info(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode == 0: # example of out @@ -94,7 +95,7 @@ def getDiskUsageForPath_du(path): logger.info(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode == 0: # example of out @@ -145,7 +146,7 @@ def getDiskFreeSpaceForMountpoint(mountpoint=CEP4_DATA_MOUNTPOINT): logger.info(' '.join(cmd) + ' ...waiting for result...') proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode != 0: logger.error(out + err) diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py index d90f25dbe21f5c206dd8f886e63e59a4f134911e..e05f0e299fdca53c9eed0b54c6029afd958b4582 100755 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py @@ -68,6 +68,7 @@ from lofar.lta.ingest.common.config import DEFAULT_INGEST_NOTIFICATION_BUSNAME from lofar.lta.ingest.common.config import DEFAULT_INGEST_NOTIFICATION_SUBJECTS from lofar.common import isProductionEnvironment, isTestEnvironment from lofar.common.util import humanreadablesize +from lofar.common.subprocess_utils import communicate_returning_strings from lofar.common import dbcredentials from lofar.sas.resourceassignment.database.radb import RADatabase @@ -990,7 +991,7 @@ def getTaskLogHtml(task_id): logger.info(' '.join(cmd)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = proc.communicate() + out, err = communicate_returning_strings(proc) if proc.returncode == 0: return out, 200, {'Content-Type': 'text/plain; charset=utf-8'} else: