From 290971ca7a28eb579dc2d40c9653b9e160253634 Mon Sep 17 00:00:00 2001 From: E Rasche Date: Mon, 18 Sep 2017 10:32:49 +0200 Subject: [PATCH] more review comments --- cron/build_chrom_db.py | 2 +- cron/parse_builds.py | 1 + lib/galaxy/datatypes/text.py | 2 +- lib/galaxy/jobs/transfer_manager.py | 2 +- scripts/data_libraries/build_lucene_index.py | 1 + scripts/edam_mapping.py | 1 + scripts/microbes/harvest_bacteria.py | 2 +- scripts/tool_shed/api/export.py | 21 ++++++-------------- 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/cron/build_chrom_db.py b/cron/build_chrom_db.py index d3cba98b8dc..4775897548f 100644 --- a/cron/build_chrom_db.py +++ b/cron/build_chrom_db.py @@ -15,9 +15,9 @@ from __future__ import print_function import fileinput import os -import requests import sys +import requests from six.moves.urllib.parse import urlencode import parse_builds diff --git a/cron/parse_builds.py b/cron/parse_builds.py index 2e4149fce57..243440a331b 100644 --- a/cron/parse_builds.py +++ b/cron/parse_builds.py @@ -11,6 +11,7 @@ import xml.etree.ElementTree as ElementTree import requests + def getbuilds(url): try: text = requests.get(url).text diff --git a/lib/galaxy/datatypes/text.py b/lib/galaxy/datatypes/text.py index 3b72e3d48b0..12235e566c4 100644 --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -155,7 +155,7 @@ class Ipynb(Json): ofilename = '%s.html' % ofilename except subprocess.CalledProcessError: ofilename = dataset.file_name - log.exception('Command "%s" failed. Could not convert the Jupyter Notebook to HTML, defaulting to plain text.', map(shlex_quote, cmd)) + log.exception('Command "%s" failed. Could not convert the Jupyter Notebook to HTML, defaulting to plain text.', ' '.join(map(shlex_quote, cmd))) return open(ofilename) def set_meta(self, dataset, **kwd): diff --git a/lib/galaxy/jobs/transfer_manager.py b/lib/galaxy/jobs/transfer_manager.py index 6bca709af3b..8e06024832c 100644 --- a/lib/galaxy/jobs/transfer_manager.py +++ b/lib/galaxy/jobs/transfer_manager.py @@ -70,7 +70,7 @@ class TransferManager(object): # The transfer script should daemonize fairly quickly - if this is # not the case, this process will need to be moved to a # non-blocking method. - cmd = self.command.append(tj.id) + cmd = self.command + [tj.id] log.debug('Transfer command is: %s', ' '.join(map(shlex_quote, cmd))) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() diff --git a/scripts/data_libraries/build_lucene_index.py b/scripts/data_libraries/build_lucene_index.py index 710747068be..b3f787e8b02 100644 --- a/scripts/data_libraries/build_lucene_index.py +++ b/scripts/data_libraries/build_lucene_index.py @@ -14,6 +14,7 @@ import csv import os import sys import urllib + import requests sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'lib'))) diff --git a/scripts/edam_mapping.py b/scripts/edam_mapping.py index 7e70c5467cd..bb5e495aa46 100644 --- a/scripts/edam_mapping.py +++ b/scripts/edam_mapping.py @@ -17,6 +17,7 @@ from __future__ import print_function import os import sys import requests + from xml import etree sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py index 175ce70cb0d..3226dec78ce 100644 --- a/scripts/microbes/harvest_bacteria.py +++ b/scripts/microbes/harvest_bacteria.py @@ -8,9 +8,9 @@ import os import sys import time from ftplib import FTP -import requests from urllib import urlretrieve +import requests from BeautifulSoup import BeautifulSoup from util import get_bed_from_genbank, get_bed_from_glimmer3, get_bed_from_GeneMarkHMM, get_bed_from_GeneMark diff --git a/scripts/tool_shed/api/export.py b/scripts/tool_shed/api/export.py index 68005de0746..6a5d030c6a0 100644 --- a/scripts/tool_shed/api/export.py +++ b/scripts/tool_shed/api/export.py @@ -11,6 +11,7 @@ import argparse import os import sys import tempfile + import requests sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'lib')) @@ -98,21 +99,11 @@ def main(options): download_url = export_dict['download_url'] download_dir = os.path.abspath(options.download_dir) file_path = os.path.join(download_dir, repositories_archive_filename) - src = None - dst = None - try: - src = requests.get(download_url, stream=True) - with open(file_path, 'wb') as handle: - for chunk in src.iter_content(chunk_size=CHUNK_SIZE): - if chunk: - handle.write(chunk) - except: - raise - finally: - if src: - src.close() - if dst: - dst.close() + src = requests.get(download_url, stream=True) + with open(file_path, 'wb') as dst: + for chunk in src.iter_content(chunk_size=CHUNK_SIZE): + if chunk: + dst.write(chunk) print "Successfully exported revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner print "to location ", file_path else: