diff --git a/api/api.py b/api/api.py index e83ccbaf98c7760ca014fc23697bc0c42df186d3..f18db054b141fc9058d1dd3bc9a1a36ed5b10ceb 100644 --- a/api/api.py +++ b/api/api.py @@ -13,14 +13,14 @@ from . import config from . import centralclient from . import download from . import upload -from api.handlers import listhandler -from api.handlers import userhandler -from api.handlers import grouphandler -from api.handlers import containerhandler -from api.handlers import collectionshandler -from api.handlers import searchhandler -from api.handlers import schemahandler -from api.handlers import reporthandler +from .handlers import listhandler +from .handlers import userhandler +from .handlers import grouphandler +from .handlers import containerhandler +from .handlers import collectionshandler +from .handlers import searchhandler +from .handlers import schemahandler +from .handlers import reporthandler log = config.log diff --git a/api/base.py b/api/base.py index a5354088c59d31143fd761eb9103d6c73265f988..1e2a01ce86946957daacaedfa079731b4d9291b4 100644 --- a/api/base.py +++ b/api/base.py @@ -225,7 +225,7 @@ class RequestHandler(webapp2.RequestHandler): # Upsert device record, with last-contacted time. # In the future, consider merging any keys into self.origin? - device_record = config.db['devices'].find_one_and_update({ + config.db['devices'].find_one_and_update({ '_id': self.origin['id'] }, { '$set': { diff --git a/api/centralclient.py b/api/centralclient.py index 7625aa4468966a4afafa55fc790c24122486c089..711289fd3df2dde865a2e93f8d1faee5f6507df5 100644 --- a/api/centralclient.py +++ b/api/centralclient.py @@ -14,9 +14,6 @@ import requests from . import base from . import config -import logging -import logging.config - log = config.log fail_count = 0 diff --git a/api/placer.py b/api/placer.py index c89c4620f3ec41ae9823cb40d24876c7012bbee3..5e894500e79274229370a0378a9e4a23d5481a38 100644 --- a/api/placer.py +++ b/api/placer.py @@ -23,10 +23,10 @@ class Placer(object): Interface for a placer, which knows how to process files and place them where they belong - on disk and database. """ - def __init__(self, container_type, container, id, metadata, timestamp, origin, context): + def __init__(self, container_type, container, id_, metadata, timestamp, origin, context): self.container_type = container_type self.container = container - self.id = id #pylint: disable=redefined-builtin + self.id = id_ #pylint: disable=redefined-builtin self.metadata = metadata self.timestamp = timestamp @@ -126,8 +126,8 @@ class UIDPlacer(Placer): metadata_schema = 'uidupload.json' create_hierarchy = staticmethod(hierarchy.upsert_bottom_up_hierarchy) - def __init__(self, container_type, container, id, metadata, timestamp, origin, context): - super(UIDPlacer, self).__init__(container_type, container, id, metadata, timestamp, origin, context) + def __init__(self, container_type, container, id_, metadata, timestamp, origin, context): + super(UIDPlacer, self).__init__(container_type, container, id_, metadata, timestamp, origin, context) self.metadata_for_file = {} @@ -228,8 +228,8 @@ class TokenPlacer(Placer): Intended for use with a token that tracks where the files will be stored. """ - def __init__(self, container_type, container, id, metadata, timestamp, origin, context): - super(TokenPlacer, self).__init__(container_type, container, id, metadata, timestamp, origin, context) + def __init__(self, container_type, container, id_, metadata, timestamp, origin, context): + super(TokenPlacer, self).__init__(container_type, container, id_, metadata, timestamp, origin, context) self.paths = [] self.folder = None @@ -268,8 +268,8 @@ class PackfilePlacer(Placer): A placer that can accept N files, save them into a zip archive, and place the result on an acquisition. """ - def __init__(self, container_type, container, id, metadata, timestamp, origin, context): - super(PackfilePlacer, self).__init__(container_type, container, id, metadata, timestamp, origin, context) + def __init__(self, container_type, container, id_, metadata, timestamp, origin, context): + super(PackfilePlacer, self).__init__(container_type, container, id_, metadata, timestamp, origin, context) # This endpoint is an SSE endpoint self.sse = True @@ -282,9 +282,10 @@ class PackfilePlacer(Placer): self.permissions = {} self.folder = None + self.dir_ = None self.name = None self.path = None - self.zip = None + self.zip_ = None self.ziptime = None @@ -339,8 +340,8 @@ class PackfilePlacer(Placer): self.ziptime = int(dateutil.parser.parse(stamp).strftime('%s')) # The zipfile is a santizied acquisition label - self.dir = util.sanitize_string_to_filename(self.a_label) - self.name = self.dir + '.zip' + self.dir_ = util.sanitize_string_to_filename(self.a_label) + self.name = self.dir_ + '.zip' # Make a tempdir to store zip until moved # OPPORTUNITY: this is also called in files.py. Could be a util func. @@ -348,7 +349,7 @@ class PackfilePlacer(Placer): # Create a zip in the tempdir that later gets moved into the CAS. self.path = os.path.join(tempdir.name, 'temp.zip') - self.zip = zipfile.ZipFile(self.path, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) + self.zip_ = zipfile.ZipFile(self.path, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) # OPPORTUNITY: add zip comment # self.zip.comment = json.dumps(metadata, default=metadata_encoder) @@ -356,7 +357,7 @@ class PackfilePlacer(Placer): # Bit of a silly hack: write our tempdir directory into the zip (not including its contents). # Creates an empty directory entry in the zip which will hold all the files inside. # This way, when you expand a zip, you'll get folder/things instead of a thousand dicoms splattered everywhere. - self.zip.write(tempdir.name, self.dir) + self.zip_.write(tempdir.name, self.dir_) def process_file_field(self, field, info): # Should not be called with any files @@ -376,7 +377,7 @@ class PackfilePlacer(Placer): os.utime(p, (self.ziptime, self.ziptime)) # Place file into the zip folder we created before - self.zip.write(p, os.path.join(self.dir, os.path.basename(path))) + self.zip_.write(p, os.path.join(self.dir_, os.path.basename(path))) # Report progress complete += 1 @@ -385,7 +386,7 @@ class PackfilePlacer(Placer): 'data': { 'done': complete, 'total': total, 'percent': (complete / float(total)) * 100 }, }) - self.zip.close() + self.zip_.close() # Remove the folder created by TokenPlacer shutil.rmtree(self.folder) diff --git a/api/tempdir.py b/api/tempdir.py index 347277e25a23252a6d387283d871e7e171177976..a3ce7911f4f0398b3569ab08baca25bf2091e3ed 100644 --- a/api/tempdir.py +++ b/api/tempdir.py @@ -22,7 +22,7 @@ class TemporaryDirectory(object): Upon exiting the context, the directory and everything contained in it are removed. """ - #pylint: disable=redefinded-builtin + # pylint: disable=redefined-builtin def __init__(self, suffix="", prefix=template, dir=None): self._closed = False diff --git a/api/upload.py b/api/upload.py index 37edf85885b4c30bedda9fa55f5c325dfdfedb59..36d872c77f2abb5ca364e2c5f479664266fe2570 100644 --- a/api/upload.py +++ b/api/upload.py @@ -206,9 +206,9 @@ class Upload(base.RequestHandler): if level == 'analysis': context = {'job_id': self.get_param('job')} - return process_upload(self.request, Strategy.analysis_job, origin=self.origin, container_type=level, id=cid, context=context) + return process_upload(self.request, Strategy.analysis_job, origin=self.origin, container_type=level, id_=cid, context=context) else: - return process_upload(self.request, Strategy.engine, container_type=level, id=cid, origin=self.origin) + return process_upload(self.request, Strategy.engine, container_type=level, id_=cid, origin=self.origin) def clean_packfile_tokens(self): """ diff --git a/api/validators.py b/api/validators.py index cae400dd139441fdccb4b09ee0193eaa3ef1d9a1..497d7885ff282c2891c9bcfb0d807b81142c03fd 100644 --- a/api/validators.py +++ b/api/validators.py @@ -70,8 +70,7 @@ def _resolve_schema(schema_url): resolvers[base_uri] = RefResolver(base_uri, None) return resolvers[base_uri].resolve(schema_name)[1], resolvers[base_uri] -def no_op(g, *args): - #pylint disable=unused-argument +def no_op(g, *args): # pylint: disable=unused-argument return g def schema_uri(type_, schema_name):