Commit cf0518e7 authored by Thomas Uram's avatar Thomas Uram

Migrate to Python 2+3

parent 3897a04f
from django.conf import settings
_temp = __import__('schedulers.'+settings.BALSAM_SCHEDULER_CLASS, globals(), locals(),
['submit','get_job_status','postprocess'], -1)
#_temp = __import__('schedulers.'+settings.BALSAM_SCHEDULER_CLASS, globals(), locals(),
#['submit','get_job_status','postprocess'], -1)
from importlib import import_module
_temp = import_module('balsam.schedulers.'+settings.BALSAM_SCHEDULER_CLASS)
submit = _temp.submit
#status = _temp.status
#get_queue_state = _temp.get_queue_state
......
......@@ -181,7 +181,7 @@ class MessageInterface:
body = message_body,
properties = properties,
)
except Exception,e:
except Exception as e:
logger.exception('exception received while trying to send message')
raise Exception('exception received while trying to send message' + str(e))
......
......@@ -2,7 +2,10 @@ from django.conf import settings
import subprocess
import logging
import os,sys,traceback
import urlparse
try:
import urlparse
except ImportError:
import urllib.parse as urlparse
# temporary
import shutil
......@@ -24,13 +27,13 @@ class GridFTPHandler:
try:
p = subprocess.Popen(command.split(' '),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err = p.communicate()
except OSError,e:
except OSError as e:
logger.error('command failed with OSError, exception: ' + str(e))
raise Exception('Error in pre_stage_hook, OSError raised')
except ValueError,e:
except ValueError as e:
logger.error('command failed with ValueError, exception: ' + str(e))
raise Exception('Error in pre_stage_hook, ValueError raised')
except Exception,e:
except Exception as e:
logger.error('command failed, exception traceback: \n' + traceback.format_exc() )
raise Exception('Error in stage_in, unknown exception raised')
......@@ -51,13 +54,13 @@ class GridFTPHandler:
try:
p = subprocess.Popen(command.split(' '),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err = p.communicate()
except OSError,e:
except OSError as e:
logger.error('command failed with OSError, exception: ' + str(e))
raise Exception('Error in stage_in, OSError raised')
except ValueError,e:
except ValueError as e:
logger.error('command failed with ValueError, exception: ' + str(e))
raise Exception('Error in stage_in, ValueError raised')
except Exception,e:
except Exception as e:
logger.error('command failed, exception traceback: \n' + traceback.format_exc() )
raise Exception('Error in stage_in, unknown exception raised')
if p.returncode:
......@@ -75,13 +78,13 @@ class GridFTPHandler:
try:
p = subprocess.Popen(command.split(' '),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err = p.communicate()
except OSError,e:
except OSError as e:
logger.error('command failed with OSError, exception: ' + str(e))
raise Exception('Error in stage_out, OSError raised')
except ValueError,e:
except ValueError as e:
logger.error('command failed with ValueError, exception: ' + str(e))
raise Exception('Error in stage_out, ValueError raised')
except Exception,e:
except Exception as e:
logger.error('command failed, exception traceback: \n' + traceback.format_exc() )
raise Exception('Error in stage_out, unknown exception raised')
......@@ -124,7 +127,7 @@ class SCPHandler:
def stage_in( self, source_url, destination_directory ):
parts = urlparse.urlparse( source_url )
command = 'scp -p -r %s:%s %s' % (source_url, destination_directory)
print 'transfer.stage_in: command=' + command
print('transfer.stage_in: command=' + command )
ret = os.system(command)
if ret:
raise Exception("Error in stage_in: %d" % ret)
......@@ -132,7 +135,7 @@ class SCPHandler:
def stage_out( self, source_directory, destination_url ):
# ensure that source and destination each have a trailing '/'
command = 'scp -p -r %s %s' % (source_directory, destination_url)
print 'transfer.stage_out: command=' + command
print('transfer.stage_out: command=' + command)
ret = os.system(command)
if ret:
raise Exception("Error in stage_out: %d" % ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment