try:
import json
-except ImportError, e:
+except ImportError as e:
import simplejson as json
import re
try:
body = get_url_as_text(str(libraryUrn.uri), 'GET')
rdfaParser.parse_string_into_model(model, body, libraryUrn.uri)
- except httplib2.HttpLib2ErrorWithResponse, e:
+ except httplib2.HttpLib2ErrorWithResponse as e:
LOGGER.error(str(e))
elif len(results) == 1:
pass # Assuming that a loaded dataset has one record
from datetime import datetime, timedelta
try:
import json
-except ImportError, e:
+except ImportError as e:
import simplejson as json
import os
"""
try:
fc = FlowCell.objects.get(flowcell_id__startswith=flowcell_id)
- except FlowCell.DoesNotExist, e:
+ except FlowCell.DoesNotExist as e:
return None
lane_set = {}
try:
result = lanes_for(username)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
raise Http404
#convert query set to python structure
default_pM = 5
try:
default_pM = int(settings.DEFAULT_PM)
-except AttributeError, e:
+except AttributeError as e:
LOGGER.error("invalid value for default_pm")
# how many days to wait before trying to re-import a runfolder
try:
saveConfigFile(flowcell, options.url, cfg_filepath)
conf_info.config_filepath = cfg_filepath
- except FlowCellNotFound, e:
+ except FlowCellNotFound as e:
LOGGER.error(e)
return False
- except WebError404, e:
+ except WebError404 as e:
LOGGER.error(e)
return False
- except IOError, e:
+ except IOError as e:
LOGGER.error(e)
return False
- except Exception, e:
+ except Exception as e:
LOGGER.error(e)
return False
def get(self, key, default=None):
try:
return self[key]
- except KeyError, e:
+ except KeyError as e:
return default
def keys(self):
lanes = [x.tag.split('_')[1] for x in container.getchildren()]
try:
index = lanes.index(self._lane_id)
- except ValueError, e:
+ except ValueError as e:
return None
element = container[index]
return element.text
try:
apipayload = urllib.urlencode(apidata)
web = urllib2.urlopen(url, apipayload)
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
errmsg = 'URLError: %d %s' % (e.code, e.msg)
LOGGER.error(errmsg)
LOGGER.error('opened %s' % (url,))
p.bustard = b
p.gerald = g
runs.append(p)
- except IOError, e:
+ except IOError as e:
LOGGER.error("Ignoring " + str(e))
return len(runs) - start
variable_name = tags[element.tag]
setattr(self, variable_name,
parse_summary_element(element))
- except KeyError, e:
+ except KeyError as e:
LOGGER.warn('Unrecognized tag %s' % (element.tag,))
"""
try:
v = int(v)
- except ValueError, e:
+ except ValueError as e:
v = float(v)
return v
try:
import json
-except ImportError, e:
+except ImportError as e:
import simplejson as json
from django.test import TestCase
LOGGER.info("Importing %s from %s" % (lib_id, result_dir))
try:
self.import_submission_dir(result_dir, lib_id)
- except MetadataLookupException, e:
+ except MetadataLookupException as e:
LOGGER.error("Skipping %s: %s" % (lib_id, str(e)))
def import_submission_dir(self, submission_dir, library_id):
LOGGER.debug("Found: %s" % (literal_re,))
try:
filename_re = re.compile(literal_re)
- except re.error, e:
+ except re.error as e:
LOGGER.error("Unable to compile: %s" % (literal_re,))
patterns[literal_re] = view_name
return patterns
LOGGER.info("Importing %s from %s" % (lib_id, result_dir))
try:
self.import_analysis_dir(result_dir, lib_id)
- except MetadataLookupException, e:
+ except MetadataLookupException as e:
LOGGER.error("Skipping %s: %s" % (lib_id, str(e)))
def import_analysis_dir(self, analysis_dir, library_id):
LOGGER.debug("Importing %s" % (lane.uri,))
try:
parser.parse_into_model(self.model, lane.uri)
- except RDF.RedlandError, e:
+ except RDF.RedlandError as e:
LOGGER.error("Error accessing %s" % (lane.uri,))
raise e
LOGGER.debug("Found: %s" % (literal_re,))
try:
filename_re = re.compile(literal_re)
- except re.error, e:
+ except re.error as e:
LOGGER.error("Unable to compile: %s" % (literal_re,))
patterns[literal_re] = view_name
return patterns
request = urllib2.urlopen(request_url)
file_index = parse_ucsc_file_index(request, base_url)
return file_index
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
err = e
pass
try:
apipayload = urllib.urlencode(apidata)
web = urllib2.urlopen(url, apipayload)
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
if hasattr(e, 'code') and e.code == 404:
LOGGER.info("%s was not found" % (url,))
return None
"""return key suitable for use as secret key"""
try:
source = random.SystemRandom()
- except AttributeError, e:
+ except AttributeError as e:
source = random.random()
bits = source.getrandbits(size)
chars = []
ini_stream = open(self.filename, 'w')
self.write(ini_stream)
ini_stream.close()
- except IOError, e:
+ except IOError as e:
LOGGER.info("Error saving setting: %s" % (str(e)))
# the 2nd of which is the serial number
return data.strip('\x00').split()[1]
-except ImportError, e:
+except ImportError as e:
print >>sys.stderr, "hdquery requires py_sg"
def get_hd_serial_num(device):
elif value_type in ('dateTime'):
try:
return datetime.strptime(literal, ISOFORMAT_MS)
- except ValueError, _:
+ except ValueError:
return datetime.strptime(literal, ISOFORMAT_SHORT)
return literal
statements = rdf_parser.parse_as_stream(url, ns)
retries = 0
succeeded = True
- except RDF.RedlandError, e:
+ except RDF.RedlandError as e:
errmsg = "RDF.RedlandError: {0} {1} tries remaining"
logger.error(errmsg.format(str(e), retries))
try:
from xml.etree import ElementTree
-except ImportError, e:
+except ImportError as e:
from elementtree import ElementTree
from htsworkflow.util.ethelp import indent, flatten
self.assertTrue(model.contains_statement(s))
-except ImportError, e:
+except ImportError as e:
print "Unable to test rdfhelp"
def suite():
version = None
try:
import pkg_resources
- except ImportError, e:
+ except ImportError as e:
LOGGER.error("Can't find version number, please install setuptools")
raise e
try:
version = pkg_resources.get_distribution("htsworkflow")
- except pkg_resources.DistributionNotFound, e:
+ except pkg_resources.DistributionNotFound as e:
LOGGER.error("Package not installed")
return version
try:
import uuid
-except ImportError, e:
+except ImportError as e:
# Some systems are using python 2.4, which doesn't have uuid
# this is a stub
LOGGER.warning('Real uuid is not available, initializing fake uuid module')
try:
import json
-except ImportError, e:
+except ImportError as e:
import simplejson as json
INVENTORY_CONTEXT_DEFAULTS = {
"""
try:
item = Item.objects.get(barcode_id=barcode_id)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
item = None
return item_summary_by_uuid(request, None, msg, item)
if item is None:
try:
item = Item.objects.get(uuid=uuid)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
item = None
context_dict = {
"""
try:
item = Item.objects.get(uuid=uuid)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
item = None
msg = "Item with UUID %s does not exist" % (uuid)
# Retrieve Storage Device
try:
sd = Item.objects.get(barcode_id=serial)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
msg = "Item with barcode_id of %s not found." % (serial)
raise ObjectDoesNotExist(msg)
# Retrieve FlowCell
try:
fc = FlowCell.objects.get(flowcell_id__startswith=flowcell)
- except ObjectDoesNotExist, e:
+ except ObjectDoesNotExist as e:
msg = "FlowCell with flowcell_id of %s not found." % (flowcell)
raise ObjectDoesNotExist(msg)
if user.check_password(password):
return user
#except self.user_class.DoesNotExist:
- except Exception, e:
+ except Exception as e:
logger.error(str(e))
return None
try:
return self.user_class.objects.get(pk=user_id)
#except self.user_class.DoesNotExist:
- except Exception, e:
+ except Exception as e:
logger.error(str(e))
return None
adapter_type = self.library_type.id,
multiplex_id = multiplex_id)
return multiplex.sequence
- except MultiplexIndex.DoesNotExist, e:
+ except MultiplexIndex.DoesNotExist as e:
return None
def index_sequence_text(self, seperator=' '):
libNS = RDF.NS("http://jumpgate.caltech.edu/wiki/LibraryOntology#")
from htsworkflow.util.rdfhelp import dump_model
-except ImportError,e:
+except ImportError as e:
HAVE_RDF = False
try:
import json
-except ImportError, e:
+except ImportError as e:
import simplejson as json
from django.views.decorators.csrf import csrf_exempt
summary_list.append(eland_summary)
- #except Exception, e:
+ #except Exception as e:
# summary_list.append("Summary report needs to be updated.")
# LOGGER.error("Exception: " + str(e))
"""
try:
lib = Library.objects.get(id=library_id)
- except Library.DoesNotExist, e:
+ except Library.DoesNotExist as e:
return None
#lane_info = lane_information(lib.lane_set)