Skip to content
Snippets Groups Projects
Commit 27fae9db authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-658: python3 adaptation

parent b65b2c9d
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ from lofar.common.subprocess_utils import PipeReader, communicate_returning_stri ...@@ -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.common.config import hostnameToIp
from lofar.lta.ingest.server.config import GLOBUS_TIMEOUT from lofar.lta.ingest.server.config import GLOBUS_TIMEOUT
from lofar.lta.ingest.common.srm import * from lofar.lta.ingest.common.srm import *
from lofar.common.subprocess_utils import communicate_returning_strings
logger = logging.getLogger() logger = logging.getLogger()
...@@ -142,7 +143,7 @@ class LtaCp: ...@@ -142,7 +143,7 @@ class LtaCp:
self.started_procs[proc] = cmd self.started_procs[proc] = cmd
# block until find is finished # block until find is finished
proc.communicate() communicate_returning_strings(proc)
del self.started_procs[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')) 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: ...@@ -165,7 +166,7 @@ class LtaCp:
self.started_procs[proc] = cmd self.started_procs[proc] = cmd
# block until find is finished # block until find is finished
proc.communicate() communicate_returning_strings(proc)
del self.started_procs[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')) 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: ...@@ -617,13 +618,13 @@ class LtaCp:
'''remove a file (or fifo) on a remote host. Test if file exists before deleting.''' '''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,)] 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 = Popen(cmd_remote_ls, stdout=PIPE, stderr=PIPE)
p_remote_ls.communicate() communicate_returning_strings(p_remote_ls)
if p_remote_ls.returncode == 0: if p_remote_ls.returncode == 0:
cmd_remote_rm = self.ssh_cmd + ['rm %s' % (self.remote_data_fifo,)] 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))) 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 = Popen(cmd_remote_rm, stdout=PIPE, stderr=PIPE)
p_remote_rm.communicate() communicate_returning_strings(p_remote_rm)
if p_remote_rm.returncode != 0: 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)) 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))
......
...@@ -35,6 +35,7 @@ import threading ...@@ -35,6 +35,7 @@ import threading
import multiprocessing import multiprocessing
from lofar.lta.ltastorageoverview import store from lofar.lta.ltastorageoverview import store
from lofar.common.util import humanreadablesize from lofar.common.util import humanreadablesize
from lofar.common.subprocess_utils import communicate_returning_strings
from random import random, randint from random import random, randint
logger = logging.getLogger() logger = logging.getLogger()
...@@ -142,7 +143,7 @@ class Location: ...@@ -142,7 +143,7 @@ class Location:
logger.debug(' '.join(cmd)) logger.debug(' '.join(cmd))
p = subprocess.Popen(cmd, stdin=open('/dev/null'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) 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)) # logger.debug('Shell command for %s exited with code %s' % (self.path(), p.returncode))
loglines = logs[0].split('\n') loglines = logs[0].split('\n')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment