From 0fa287f76a675c49c2702681ac4404f050b77130 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 17 Aug 2017 11:57:53 -0400 Subject: [PATCH] Add autopep8 script to help rebasing branches after #4440. Fixes a few more PEP8 issues as part of the autopep8'ing as well. --- .ci/autopep8.sh | 2 + lib/galaxy/actions/admin.py | 1 + lib/galaxy/app.py | 1 + lib/galaxy/datatypes/dataproviders/base.py | 1 + lib/galaxy/datatypes/dataproviders/chunk.py | 1 + lib/galaxy/datatypes/dataproviders/dataset.py | 7 ++ .../datatypes/dataproviders/exceptions.py | 2 + .../datatypes/dataproviders/external.py | 4 ++ .../datatypes/dataproviders/hierarchy.py | 1 + lib/galaxy/datatypes/dataproviders/line.py | 1 + lib/galaxy/datatypes/genetics.py | 10 ++- lib/galaxy/datatypes/graph.py | 2 + lib/galaxy/datatypes/molecules.py | 2 +- lib/galaxy/datatypes/mothur.py | 1 + lib/galaxy/datatypes/neo4j.py | 1 + lib/galaxy/datatypes/text.py | 1 + lib/galaxy/datatypes/util/gff_util.py | 2 + lib/galaxy/jobs/__init__.py | 5 ++ lib/galaxy/jobs/deferred/__init__.py | 1 + lib/galaxy/jobs/handler.py | 11 +-- lib/galaxy/jobs/manager.py | 1 + lib/galaxy/jobs/runners/godocker.py | 1 + .../jobs/runners/util/drmaa/__init__.py | 1 + lib/galaxy/jobs/transfer_manager.py | 1 + lib/galaxy/managers/deletable.py | 2 + lib/galaxy/model/__init__.py | 1 + lib/galaxy/model/item_attrs.py | 2 + lib/galaxy/model/metadata.py | 4 ++ .../model/orm/logging_connection_proxy.py | 1 + lib/galaxy/model/search.py | 5 ++ lib/galaxy/objectstore/__init__.py | 1 + lib/galaxy/objectstore/azure_blob.py | 1 + lib/galaxy/objectstore/pithos.py | 1 + lib/galaxy/objectstore/rods.py | 1 + lib/galaxy/objectstore/s3.py | 1 + lib/galaxy/queue_worker.py | 3 +- lib/galaxy/quota/__init__.py | 2 + lib/galaxy/security/__init__.py | 6 +- lib/galaxy/tools/__init__.py | 13 ++-- lib/galaxy/tools/actions/__init__.py | 2 + lib/galaxy/tools/deps/__init__.py | 1 + lib/galaxy/tools/deps/brew_exts.py | 2 +- lib/galaxy/tools/deps/mulled/mulled_search.py | 1 + lib/galaxy/tools/deps/requirements.py | 2 + lib/galaxy/tools/deps/resolvers/modules.py | 2 + lib/galaxy/tools/imp_exp/__init__.py | 8 ++- lib/galaxy/tools/parameters/basic.py | 12 ++++ .../tools/parameters/dynamic_options.py | 10 +++ lib/galaxy/tools/parameters/validation.py | 2 + lib/galaxy/tools/parser/interface.py | 3 + lib/galaxy/tools/wrappers.py | 5 ++ lib/galaxy/util/__init__.py | 28 ++++---- lib/galaxy/util/bunch.py | 1 + lib/galaxy/util/heartbeat.py | 1 + lib/galaxy/util/odict.py | 1 + lib/galaxy/util/pastescript/loadwsgi.py | 1 + lib/galaxy/util/simplegraph.py | 3 + lib/galaxy/util/sleeper.py | 1 + lib/galaxy/util/ucsc.py | 1 + .../visualization/data_providers/genome.py | 1 + .../data_providers/phyloviz/baseparser.py | 1 + lib/galaxy/visualization/genomes.py | 1 + .../visualization/plugins/config_parser.py | 1 + lib/galaxy/visualization/plugins/plugin.py | 1 + lib/galaxy/visualization/plugins/utils.py | 1 + lib/galaxy/web/form_builder.py | 4 ++ lib/galaxy/web/framework/base.py | 6 ++ lib/galaxy/web/framework/formbuilder.py | 4 ++ lib/galaxy/web/framework/helpers/grids.py | 70 +++++++++++-------- .../web/framework/middleware/request_id.py | 1 + lib/galaxy/web/framework/middleware/sentry.py | 1 + .../web/framework/middleware/translogger.py | 8 +-- .../framework/middleware/xforwardedhost.py | 1 + lib/galaxy/web/framework/webapp.py | 1 + lib/galaxy/webapps/galaxy/api/provenance.py | 1 + lib/galaxy/webapps/galaxy/api/remote_files.py | 14 ++-- .../galaxy/controllers/admin_toolshed.py | 14 ++-- .../galaxy/controllers/requests_common.py | 14 ++-- lib/galaxy/webapps/galaxy/controllers/root.py | 1 + .../webapps/galaxy/controllers/userskeys.py | 12 ++-- lib/galaxy/webapps/reports/app.py | 1 + .../webapps/tool_shed/util/ratings_util.py | 1 + lib/galaxy/workflow/extract.py | 1 + .../grids/admin_toolshed_grids.py | 16 ++--- test/casperjs/casperjs_runner.py | 5 ++ test/galaxy_selenium/driver_factory.py | 2 +- .../functional/test_0060_workflows.py | 1 + .../test_0400_repository_component_reviews.py | 1 + ...ository_component_review_access_control.py | 1 + ...test_0420_citable_urls_for_repositories.py | 1 + ...stall_repository_with_tool_dependencies.py | 1 + ...t_1060_install_repository_with_workflow.py | 1 + .../functional/test_1070_invalid_tool.py | 1 + tools/data_source/upload.py | 66 ++++++++--------- 94 files changed, 309 insertions(+), 140 deletions(-) create mode 100755 .ci/autopep8.sh diff --git a/.ci/autopep8.sh b/.ci/autopep8.sh new file mode 100755 index 00000000000..6a2b8cf328a --- /dev/null +++ b/.ci/autopep8.sh @@ -0,0 +1,2 @@ +exclude=$(sed -e 's|^|./|' -e 's|/$||' .ci/flake8_blacklist.txt | paste -s -d ',' - ) +autopep8 -i -r --exclude $exclude --select E11,E101,E127,E201,E202,E22,E301,E302,E303,E304,E306,E711,W291,W292,W293,W391 ./lib/ ./test/ diff --git a/lib/galaxy/actions/admin.py b/lib/galaxy/actions/admin.py index d3e0d808811..3879f6b794e 100644 --- a/lib/galaxy/actions/admin.py +++ b/lib/galaxy/actions/admin.py @@ -13,6 +13,7 @@ class AdminActions(object): """ Mixin for controllers that provide administrative functionality. """ + def _create_quota(self, params, decode_id=None): if params.amount.lower() in ('unlimited', 'none', 'no limit'): create_amount = None diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index 813470caac3..803727def09 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -44,6 +44,7 @@ app = None class UniverseApplication(object, config.ConfiguresGalaxyMixin): """Encapsulates the state of a Universe application""" + def __init__(self, **kwargs): if not log.handlers: # Paste didn't handle it, so we need a temporary basic log diff --git a/lib/galaxy/datatypes/dataproviders/base.py b/lib/galaxy/datatypes/dataproviders/base.py index 35cba1a5111..6fb3fb5850b 100644 --- a/lib/galaxy/datatypes/dataproviders/base.py +++ b/lib/galaxy/datatypes/dataproviders/base.py @@ -291,6 +291,7 @@ class MultiSourceDataProvider(DataProvider): An iterator over iterators. """ + def __init__(self, source_list, **kwargs): """ :param source_list: an iterator of iterables diff --git a/lib/galaxy/datatypes/dataproviders/chunk.py b/lib/galaxy/datatypes/dataproviders/chunk.py index 8cd0ca32c96..ac3c529e730 100644 --- a/lib/galaxy/datatypes/dataproviders/chunk.py +++ b/lib/galaxy/datatypes/dataproviders/chunk.py @@ -74,6 +74,7 @@ class Base64ChunkDataProvider(ChunkDataProvider): """ Data provider that yields chunks of base64 encoded data from its file. """ + def encode(self, chunk): """ Return chunks encoded in base 64. diff --git a/lib/galaxy/datatypes/dataproviders/dataset.py b/lib/galaxy/datatypes/dataproviders/dataset.py index 51994802be7..2d77ccc2de5 100644 --- a/lib/galaxy/datatypes/dataproviders/dataset.py +++ b/lib/galaxy/datatypes/dataproviders/dataset.py @@ -44,6 +44,7 @@ class DatasetDataProvider(base.DataProvider): and conv. methods for using dataset metadata to set up and control how the data is provided. """ + def __init__(self, dataset, **kwargs): """ :param dataset: the Galaxy dataset whose file will be the source @@ -164,6 +165,7 @@ class ConvertedDatasetDataProvider(DatasetDataProvider): Class that uses the file contents of a dataset after conversion to a different format. """ + def __init__(self, dataset, **kwargs): raise NotImplementedError('Abstract class') self.original_dataset = dataset @@ -185,6 +187,7 @@ class DatasetColumnarDataProvider(column.ColumnarDataProvider): dataset's metadata to buuild settings for the ColumnarDataProvider it's inherited from. """ + def __init__(self, dataset, **kwargs): """ All kwargs are inherited from ColumnarDataProvider. @@ -208,6 +211,7 @@ class DatasetDictDataProvider(column.DictDataProvider): dataset's metadata to buuild settings for the DictDataProvider it's inherited from. """ + def __init__(self, dataset, **kwargs): """ All kwargs are inherited from DictDataProvider. @@ -575,6 +579,7 @@ class DatasetSubprocessDataProvider(external.SubprocessDataProvider): for the process). """ # TODO: below should be a subclass of this and not RegexSubprocess + def __init__(self, dataset, *args, **kwargs): """ :param args: the list of strings used to build commands. @@ -690,6 +695,7 @@ class BcftoolsDataProvider(line.RegexLineDataProvider): This can be piped through other providers (column, map, genome region, etc.). """ + def __init__(self, dataset, **kwargs): # TODO: as samtools raise NotImplementedError() @@ -702,6 +708,7 @@ class BGzipTabixDataProvider(base.DataProvider): This can be piped through other providers (column, map, genome region, etc.). """ + def __init__(self, dataset, **kwargs): # TODO: as samtools - need more info on output format raise NotImplementedError() diff --git a/lib/galaxy/datatypes/dataproviders/exceptions.py b/lib/galaxy/datatypes/dataproviders/exceptions.py index 1212ceecbb6..2c7906c4da5 100644 --- a/lib/galaxy/datatypes/dataproviders/exceptions.py +++ b/lib/galaxy/datatypes/dataproviders/exceptions.py @@ -7,6 +7,7 @@ class InvalidDataProviderSource(TypeError): """ Raised when a unusable source is passed to a provider. """ + def __init__(self, source=None, msg=''): msg = msg or 'Invalid source for provider: %s' % (source) super(InvalidDataProviderSource, self).__init__(msg) @@ -25,6 +26,7 @@ class NoProviderAvailable(TypeError): Meant to be used within a class that builds dataproviders (e.g. a Datatype) """ + def __init__(self, factory_source, format_requested=None, msg=''): self.factory_source = factory_source self.format_requested = format_requested diff --git a/lib/galaxy/datatypes/dataproviders/external.py b/lib/galaxy/datatypes/dataproviders/external.py index 517b0a30bbb..888fe2a3905 100644 --- a/lib/galaxy/datatypes/dataproviders/external.py +++ b/lib/galaxy/datatypes/dataproviders/external.py @@ -31,6 +31,7 @@ class SubprocessDataProvider(base.DataProvider): subprocess as its data source. """ # TODO: need better ways of checking returncode, stderr for errors and raising + def __init__(self, *args, **kwargs): """ :param args: the list of strings used to build commands. @@ -80,6 +81,7 @@ class RegexSubprocessDataProvider(line.RegexLineDataProvider): RegexLineDataProvider that uses a SubprocessDataProvider as its data source. """ # this is a conv. class and not really all that necc... + def __init__(self, *args, **kwargs): # using subprocess as proxy data source in filtered line prov. subproc_provider = SubprocessDataProvider(*args) @@ -135,6 +137,7 @@ class GzipDataProvider(base.DataProvider): This can be piped through other providers (column, map, genome region, etc.). """ + def __init__(self, source, **kwargs): unzipped = gzip.GzipFile(source, 'rb') super(GzipDataProvider, self).__init__(unzipped, **kwargs) @@ -148,6 +151,7 @@ class TempfileDataProvider(base.DataProvider): it to be used as a source where a file_name is needed (e.g. as a parameter to a command line tool: samtools view -t ) """ + def __init__(self, source, **kwargs): # TODO: raise NotImplementedError() diff --git a/lib/galaxy/datatypes/dataproviders/hierarchy.py b/lib/galaxy/datatypes/dataproviders/hierarchy.py index 0c6cbd1066d..e5e76134abf 100644 --- a/lib/galaxy/datatypes/dataproviders/hierarchy.py +++ b/lib/galaxy/datatypes/dataproviders/hierarchy.py @@ -23,6 +23,7 @@ class HierarchalDataProvider(line.BlockDataProvider): e.g. XML, HTML, GFF3, Phylogenetic """ + def __init__(self, source, **kwargs): # TODO: (and defer to better (than I can write) parsers for each subtype) super(HierarchalDataProvider, self).__init__(source, **kwargs) diff --git a/lib/galaxy/datatypes/dataproviders/line.py b/lib/galaxy/datatypes/dataproviders/line.py index a4526e4c18b..e9244ebca54 100644 --- a/lib/galaxy/datatypes/dataproviders/line.py +++ b/lib/galaxy/datatypes/dataproviders/line.py @@ -139,6 +139,7 @@ class BlockDataProvider(base.LimitedOffsetDataProvider): e.g. Fasta, GenBank, MAF, hg log Note: mem intensive (gathers list of lines before output) """ + def __init__(self, source, new_block_delim_fn=None, block_filter_fn=None, **kwargs): """ :param new_block_delim_fn: T/F function to determine whether a given line diff --git a/lib/galaxy/datatypes/genetics.py b/lib/galaxy/datatypes/genetics.py index 3205b4de9b1..22833fd50ad 100644 --- a/lib/galaxy/datatypes/genetics.py +++ b/lib/galaxy/datatypes/genetics.py @@ -320,7 +320,6 @@ class Rgenetics(Html): return 'text/html' def set_meta(self, dataset, **kwd): - """ for lped/pbed eg @@ -617,10 +616,10 @@ class RexpBase(Html): del useConc[i] # get rid of concordance del useCols[i] # and usecols entry for i, conc in enumerate(useConc): # these are all unique columns for the design matrix - ccounts = sorted((conc.get(code, 0), code) for code in conc.keys()) # decorate - cc = [(x[1], x[0]) for x in ccounts] # list of code count tuples - codeDetails = (head[useCols[i]], cc) # ('foo',[('a',3),('b',11),..]) - listCol.append(codeDetails) + ccounts = sorted((conc.get(code, 0), code) for code in conc.keys()) # decorate + cc = [(x[1], x[0]) for x in ccounts] # list of code count tuples + codeDetails = (head[useCols[i]], cc) # ('foo',[('a',3),('b',11),..]) + listCol.append(codeDetails) if len(listCol) > 0: res = listCol # metadata.pheCols becomes [('bar;22,zot;113','foo'), ...] @@ -706,7 +705,6 @@ class RexpBase(Html): dataset.metadata = copy_from.metadata def set_meta(self, dataset, **kwd): - """ NOTE we apply the tabular machinary to the phenodata extracted from a BioC eSet or affybatch. diff --git a/lib/galaxy/datatypes/graph.py b/lib/galaxy/datatypes/graph.py index f0d5e4773e8..6e7ca5e9afe 100644 --- a/lib/galaxy/datatypes/graph.py +++ b/lib/galaxy/datatypes/graph.py @@ -106,6 +106,7 @@ class XGMMLGraphDataProvider(dataproviders.hierarchy.XMLDataProvider): 'edges': contains objects of the form: { 'source' : , 'target': , 'data': } """ + def __iter__(self): # use simple graph to store nodes and links, later providing them as a dict # essentially this is a form of aggregation @@ -139,6 +140,7 @@ class SIFGraphDataProvider(dataproviders.column.ColumnarDataProvider): 'edges': contains objects of the form: { 'source' : , 'target': , 'data': } """ + def __iter__(self): # use simple graph to store nodes and links, later providing them as a dict # essentially this is a form of aggregation diff --git a/lib/galaxy/datatypes/molecules.py b/lib/galaxy/datatypes/molecules.py index c0c4cd46753..bc65b2a7c07 100644 --- a/lib/galaxy/datatypes/molecules.py +++ b/lib/galaxy/datatypes/molecules.py @@ -754,7 +754,7 @@ class CML(GenericXml): if line.lstrip().startswith('') or \ line.lstrip().startswith('>> sorted( p.to_dict( trans ).items() ) [('area', False), ('argument', None), ('datalist', []), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'TextToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'text'), ('value', 'default')] """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -455,6 +456,7 @@ class BooleanToolParameter(ToolParameter): >>> print p.to_param_dict_string( False ) _falsevalue """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -506,6 +508,7 @@ class FileToolParameter(ToolParameter): >>> sorted( p.to_dict( trans ).items() ) [('argument', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'FileToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'file'), ('value', None)] """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -562,6 +565,7 @@ class FTPFileToolParameter(ToolParameter): >>> sorted( p.to_dict( trans ).items() ) [('argument', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'FTPFileToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('refresh_on_change', False), ('type', 'ftpfile'), ('value', None)] """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -634,6 +638,7 @@ class HiddenToolParameter(ToolParameter): >>> sorted( p.to_dict( trans ).items() ) [('argument', None), ('help', ''), ('hidden', True), ('is_dynamic', False), ('label', ''), ('model_class', 'HiddenToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'hidden'), ('value', u'_value')] """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -668,6 +673,7 @@ class ColorToolParameter(ToolParameter): ... ValueError: Failed to convert 'None' to RGB. """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -699,6 +705,7 @@ class BaseURLToolParameter(HiddenToolParameter): >>> sorted( p.to_dict( trans ).items() ) [('argument', None), ('help', ''), ('hidden', True), ('is_dynamic', False), ('label', ''), ('model_class', 'BaseURLToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'base_url'), ('value', u'_value')] """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) super(BaseURLToolParameter, self).__init__(tool, input_source) @@ -755,6 +762,7 @@ class SelectToolParameter(ToolParameter): >>> print p.to_param_dict_string( ["y", "z"] ) y,z """ + def __init__(self, tool, input_source, context=None): input_source = ensure_input_source(input_source) ToolParameter.__init__(self, tool, input_source) @@ -946,6 +954,7 @@ class GenomeBuildParameter(SelectToolParameter): >>> [ i for i in o if i[ 1 ] == 'hg18' ] [('Human Mar. 2006 (NCBI36/hg18) (hg18)', 'hg18', False)] """ + def __init__(self, *args, **kwds): super(GenomeBuildParameter, self).__init__(*args, **kwds) if self.tool: @@ -1013,6 +1022,7 @@ class ColumnListParameter(SelectToolParameter): >>> print clp.name numerical_column """ + def __init__(self, tool, input_source): input_source = ensure_input_source(input_source) SelectToolParameter.__init__(self, tool, input_source) @@ -1195,6 +1205,7 @@ class DrillDownSelectToolParameter(SelectToolParameter): >>> assert d[ 'options' ][ 1 ][ 'name' ] == 'Option 5' >>> assert d[ 'options' ][ 1 ][ 'value' ] == 'option5' """ + def __init__(self, tool, input_source, context=None): input_source = ensure_input_source(input_source) @@ -1965,6 +1976,7 @@ class HiddenDataToolParameter(HiddenToolParameter, DataToolParameter): Hidden parameter that behaves as a DataToolParameter. As with all hidden parameters, this is a HACK. """ + def __init__(self, tool, elem): DataToolParameter.__init__(self, tool, elem) self.value = "None" diff --git a/lib/galaxy/tools/parameters/dynamic_options.py b/lib/galaxy/tools/parameters/dynamic_options.py index 69fbad60db9..a55b7dad618 100644 --- a/lib/galaxy/tools/parameters/dynamic_options.py +++ b/lib/galaxy/tools/parameters/dynamic_options.py @@ -57,6 +57,7 @@ class StaticValueFilter(Filter): keep: Keep columns matching value (True) Discard columns matching value (False) """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.value = elem.get("value", None) @@ -100,6 +101,7 @@ class DataMetaFilter(Filter): - separator: When multiple split by this (,) """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.ref_name = elem.get("ref", None) @@ -196,6 +198,7 @@ class ParamValueFilter(Filter): - ref_attribute: Period (.) separated attribute chain of input (ref) to use as value for filter """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.ref_name = elem.get("ref", None) @@ -238,6 +241,7 @@ class UniqueValueFilter(Filter): Required Attributes: column: column in options to compare with """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) column = elem.get("column", None) @@ -268,6 +272,7 @@ class MultipleSplitterFilter(Filter): Optional Attributes: separator: Split column by this (,) """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.separator = elem.get("separator", ",") @@ -296,6 +301,7 @@ class AttributeValueSplitterFilter(Filter): pair_separator: Split column by this (,) name_val_separator: Split name-value pair by this ( whitespace ) """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.pair_separator = elem.get("pair_separator", ",") @@ -331,6 +337,7 @@ class AdditionalValueFilter(Filter): name: Display name to appear in select list (value) index: Index of option list to add value (APPEND) """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.value = elem.get("value", None) @@ -375,6 +382,7 @@ class RemoveValueFilter(Filter): key: metadata key to compare to """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) self.value = elem.get("value", None) @@ -424,6 +432,7 @@ class SortByColumnFilter(Filter): Required Attributes: column: column to sort by """ + def __init__(self, d_option, elem): Filter.__init__(self, d_option, elem) column = elem.get("column", None) @@ -455,6 +464,7 @@ filter_types = dict(data_meta=DataMetaFilter, class DynamicOptions(object): """Handles dynamically generated SelectToolParameter options""" + def __init__(self, elem, tool_param): def load_from_parameter(from_parameter, transform_lines=None): obj = self.tool_param diff --git a/lib/galaxy/tools/parameters/validation.py b/lib/galaxy/tools/parameters/validation.py index 85998d3cf96..531b4ef8b51 100644 --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -233,6 +233,7 @@ class DatasetOkValidator(Validator): class DatasetEmptyValidator(Validator): """Validator that checks if a dataset has a positive file size.""" + def __init__(self, message=None): self.message = message @@ -250,6 +251,7 @@ class DatasetEmptyValidator(Validator): class DatasetExtraFilesPathEmptyValidator(Validator): """Validator that checks if a dataset's extra_files_path exists and is not empty.""" + def __init__(self, message=None): self.message = message diff --git a/lib/galaxy/tools/parser/interface.py b/lib/galaxy/tools/parser/interface.py index e2b82aedb91..47584170cfe 100644 --- a/lib/galaxy/tools/parser/interface.py +++ b/lib/galaxy/tools/parser/interface.py @@ -196,6 +196,7 @@ class PagesSource(object): Pages are deprecated so ideally this outer list will always be exactly a singleton. """ + def __init__(self, page_sources): self.page_sources = page_sources @@ -298,6 +299,7 @@ class ToolStdioRegex(object): attribute that contains "output" and/or "error", and a "level" attribute that contains "warning" or "fatal". """ + def __init__(self): self.match = "" self.stdout_match = False @@ -312,6 +314,7 @@ class ToolStdioExitCode(object): This is a container for the element's subelement. The exit_code element has a range of exit codes and the error level. """ + def __init__(self): self.range_start = float("-inf") self.range_end = float("inf") diff --git a/lib/galaxy/tools/wrappers.py b/lib/galaxy/tools/wrappers.py index e28a1702824..1ff41a5eb29 100644 --- a/lib/galaxy/tools/wrappers.py +++ b/lib/galaxy/tools/wrappers.py @@ -49,6 +49,7 @@ class RawObjectWrapper(ToolParameterValueWrapper): """ Wraps an object so that __str__ returns module_name:class_name. """ + def __init__(self, obj): self.obj = obj @@ -71,6 +72,7 @@ class InputValueWrapper(ToolParameterValueWrapper): """ Wraps an input so that __str__ gives the "param_dict" representation. """ + def __init__(self, input, value, other_values={}): self.input = input self.value = value @@ -124,6 +126,7 @@ class SelectToolParameterWrapper(ToolParameterValueWrapper): Provide access to any field by name or index for this particular value. Only applicable for dynamic_options selects, which have more than simple 'options' defined (name, value, selected). """ + def __init__(self, input, value, other_values, path_rewriter): self._input = input self._value = value @@ -181,6 +184,7 @@ class DatasetFilenameWrapper(ToolParameterValueWrapper): according to the metadata spec. Methods implemented to match behavior of a Metadata Collection. """ + def __init__(self, metadata): self.metadata = metadata @@ -314,6 +318,7 @@ class HasDatasets: class DatasetListWrapper(list, ToolParameterValueWrapper, HasDatasets): """ """ + def __init__(self, job_working_directory, datasets, dataset_paths=[], **kwargs): if not isinstance(datasets, list): datasets = [datasets] diff --git a/lib/galaxy/util/__init__.py b/lib/galaxy/util/__init__.py index b57889d98ea..2b86d235527 100644 --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -407,18 +407,18 @@ def pretty_print_time_interval(time=False, precise=False): if precise: if day_diff == 0: - if second_diff < 10: - return "just now" - if second_diff < 60: - return str(second_diff) + " seconds ago" - if second_diff < 120: - return "a minute ago" - if second_diff < 3600: - return str(second_diff / 60) + " minutes ago" - if second_diff < 7200: - return "an hour ago" - if second_diff < 86400: - return str(second_diff / 3600) + " hours ago" + if second_diff < 10: + return "just now" + if second_diff < 60: + return str(second_diff) + " seconds ago" + if second_diff < 120: + return "a minute ago" + if second_diff < 3600: + return str(second_diff / 60) + " minutes ago" + if second_diff < 7200: + return "an hour ago" + if second_diff < 86400: + return str(second_diff / 3600) + " hours ago" if day_diff == 1: return "yesterday" if day_diff < 7: @@ -599,7 +599,7 @@ def which(file): # http://stackoverflow.com/questions/5226958/which-equivalent-function-in-python for path in os.environ["PATH"].split(":"): if os.path.exists(path + "/" + file): - return path + "/" + file + return path + "/" + file return None @@ -721,7 +721,7 @@ class Params(object): key not in self.NEVER_SANITIZE and True not in [key.endswith("|%s" % nonsanitize_parameter) for nonsanitize_parameter in self.NEVER_SANITIZE]): - self.__dict__[key] = sanitize_param(value) + self.__dict__[key] = sanitize_param(value) else: self.__dict__[key] = value else: diff --git a/lib/galaxy/util/bunch.py b/lib/galaxy/util/bunch.py index 0f4acfc96b3..d353686a2ce 100644 --- a/lib/galaxy/util/bunch.py +++ b/lib/galaxy/util/bunch.py @@ -5,6 +5,7 @@ class Bunch(object): Often we want to just collect a bunch of stuff together, naming each item of the bunch; a dictionary's OK for that, but a small do-nothing class is even handier, and prettier to use. """ + def __init__(self, **kwds): self.__dict__.update(kwds) diff --git a/lib/galaxy/util/heartbeat.py b/lib/galaxy/util/heartbeat.py index 46f3cfb0326..9bd8b3f7fc2 100644 --- a/lib/galaxy/util/heartbeat.py +++ b/lib/galaxy/util/heartbeat.py @@ -33,6 +33,7 @@ class Heartbeat(threading.Thread): """ Thread that periodically dumps the state of all threads to a file """ + def __init__(self, config, name="Heartbeat Thread", period=20, fname="heartbeat.log"): threading.Thread.__init__(self, name=name) self.config = config diff --git a/lib/galaxy/util/odict.py b/lib/galaxy/util/odict.py index 184444e3779..3f123d2ecf0 100644 --- a/lib/galaxy/util/odict.py +++ b/lib/galaxy/util/odict.py @@ -14,6 +14,7 @@ class odict(UserDict): added. Calling keys(), values(), items(), etc. will return results in this order. """ + def __init__(self, dict=None): item = dict self._keys = [] diff --git a/lib/galaxy/util/pastescript/loadwsgi.py b/lib/galaxy/util/pastescript/loadwsgi.py index ab31383bebc..ed7f15cded3 100644 --- a/lib/galaxy/util/pastescript/loadwsgi.py +++ b/lib/galaxy/util/pastescript/loadwsgi.py @@ -723,6 +723,7 @@ class FuncLoader(_Loader): Dot notation is supported in both the module and function name, e.g.: use = call:my.module.path:object.method """ + def __init__(self, spec): self.spec = spec if ':' not in spec: diff --git a/lib/galaxy/util/simplegraph.py b/lib/galaxy/util/simplegraph.py index 8a727204adf..40a4a3fb363 100644 --- a/lib/galaxy/util/simplegraph.py +++ b/lib/galaxy/util/simplegraph.py @@ -10,6 +10,7 @@ class SimpleGraphNode(object): """ Node representation. """ + def __init__(self, index, **data): """ :param index: index of this node in some parent list @@ -26,6 +27,7 @@ class SimpleGraphEdge(object): """ Edge representation. """ + def __init__(self, source_index, target_index, **data): """ :param source_index: index of the edge's source node in some parent list @@ -53,6 +55,7 @@ class SimpleGraph(object): These graphs are not specifically directed but since source and targets on the edges are listed - it could easily be used that way. """ + def __init__(self, nodes=None, edges=None): # use an odict so that edge indeces actually match the final node list indeces self.nodes = nodes or odict() diff --git a/lib/galaxy/util/sleeper.py b/lib/galaxy/util/sleeper.py index 62bfe8ff813..a1f523d3857 100644 --- a/lib/galaxy/util/sleeper.py +++ b/lib/galaxy/util/sleeper.py @@ -6,6 +6,7 @@ class Sleeper(object): Provides a 'sleep' method that sleeps for a number of seconds *unless* the notify method is called (from a different thread). """ + def __init__(self): self.condition = threading.Condition() diff --git a/lib/galaxy/util/ucsc.py b/lib/galaxy/util/ucsc.py index 4dcf135d9c9..1542542b95d 100644 --- a/lib/galaxy/util/ucsc.py +++ b/lib/galaxy/util/ucsc.py @@ -9,6 +9,7 @@ class UCSCLimitException(Exception): class UCSCOutWrapper(object): """File-like object that throws an exception if it encounters the UCSC limit error lines""" + def __init__(self, other): self.other = iter(other) # Need one line of lookahead to be sure we are hitting the limit message diff --git a/lib/galaxy/visualization/data_providers/genome.py b/lib/galaxy/visualization/data_providers/genome.py index 5690e431758..460765eb3d5 100644 --- a/lib/galaxy/visualization/data_providers/genome.py +++ b/lib/galaxy/visualization/data_providers/genome.py @@ -1270,6 +1270,7 @@ class BigWigDataProvider (BBIDataProvider): Provides data from BigWig files; position data is reported in 1-based coordinate system, i.e. wiggle format. """ + def _get_dataset(self): if self.converted_dataset is not None: f = open(self.converted_dataset.file_name) diff --git a/lib/galaxy/visualization/data_providers/phyloviz/baseparser.py b/lib/galaxy/visualization/data_providers/phyloviz/baseparser.py index c22d2df441d..f55728a568c 100644 --- a/lib/galaxy/visualization/data_providers/phyloviz/baseparser.py +++ b/lib/galaxy/visualization/data_providers/phyloviz/baseparser.py @@ -3,6 +3,7 @@ import json class Node(object): """Node class of PhyloTree, which represents a CLAUDE in a phylogenetic tree""" + def __init__(self, nodeName, **kwargs): """Creates a node and adds in the typical annotations""" self.name, self.id = nodeName, kwargs.get("id", 0) diff --git a/lib/galaxy/visualization/genomes.py b/lib/galaxy/visualization/genomes.py index 0b8e646528b..b9165346470 100644 --- a/lib/galaxy/visualization/genomes.py +++ b/lib/galaxy/visualization/genomes.py @@ -75,6 +75,7 @@ class Genome(object): """ Encapsulates information about a known genome/dbkey. """ + def __init__(self, key, description, len_file=None, twobit_file=None): self.key = key self.description = description diff --git a/lib/galaxy/visualization/plugins/config_parser.py b/lib/galaxy/visualization/plugins/config_parser.py index c57d6534663..1c32035411f 100644 --- a/lib/galaxy/visualization/plugins/config_parser.py +++ b/lib/galaxy/visualization/plugins/config_parser.py @@ -452,6 +452,7 @@ class ParamModifierParser(ParamParser): (normal) param (e.g. 'hda_ldda' can equal 'hda' or 'ldda' and control whether a visualizations 'dataset_id' param is for an HDA or LDDA). """ + def parse(self, element): # modifies is required modifies = element.get('modifies') diff --git a/lib/galaxy/visualization/plugins/plugin.py b/lib/galaxy/visualization/plugins/plugin.py index e963eb93a8a..50e97cbbcd4 100644 --- a/lib/galaxy/visualization/plugins/plugin.py +++ b/lib/galaxy/visualization/plugins/plugin.py @@ -329,6 +329,7 @@ class StaticFileVisualizationPlugin(VisualizationPlugin): """ # TODO: these are not embeddable by their nature - update config # TODO: should do render/render_saved here since most of the calc done there is unneeded in this case + def _render(self, render_vars, trans=None, embedded=None, **kwargs): """ Render the static file simply by reading and returning it. diff --git a/lib/galaxy/visualization/plugins/utils.py b/lib/galaxy/visualization/plugins/utils.py index a7f713fcfbe..5fb48abd793 100644 --- a/lib/galaxy/visualization/plugins/utils.py +++ b/lib/galaxy/visualization/plugins/utils.py @@ -15,6 +15,7 @@ class OpenObject(dict): KeyError). JSON-serializable. """ + def __getitem__(self, key): if key not in self: return None diff --git a/lib/galaxy/web/form_builder.py b/lib/galaxy/web/form_builder.py index 81d76796ddc..486bf104cb5 100644 --- a/lib/galaxy/web/form_builder.py +++ b/lib/galaxy/web/form_builder.py @@ -49,6 +49,7 @@ class TextField(BaseField): >>> print TextField( "bins", size=4, value="default" ).get_html() """ + def __init__(self, name, size=None, value=None, **kwds): super(TextField, self).__init__(name, value, **kwds) self.size = int(size or 10) @@ -76,6 +77,7 @@ class PasswordField(BaseField): >>> print PasswordField( "bins", size=4, value="default" ).get_html() """ + def __init__(self, name, size=None, value=None, **kwds): super(PasswordField, self).__init__(name, value, **kwds) self.name = name @@ -213,6 +215,7 @@ class HiddenField(BaseField): >>> print HiddenField( "foo", 100 ).get_html() """ + def __init__(self, name, value=None, **kwds): super(HiddenField, self).__init__(name, value, **kwds) self.name = name @@ -265,6 +268,7 @@ class SelectField(BaseField):
""" + def __init__(self, name, multiple=None, display=None, refresh_on_change=False, refresh_on_change_values=None, size=None, field_id=None, value=None, selectlist=None, **kwds): super(SelectField, self).__init__(name, value, **kwds) self.name = name diff --git a/lib/galaxy/web/framework/base.py b/lib/galaxy/web/framework/base.py index 9bdcf67c684..e5a9d13cb1a 100644 --- a/lib/galaxy/web/framework/base.py +++ b/lib/galaxy/web/framework/base.py @@ -52,6 +52,7 @@ class WebApplication(object): complicated encoding of arguments in the PATH_INFO can be performed with routes. """ + def __init__(self): """ Create a new web application object. To actually connect some @@ -263,6 +264,7 @@ class WSGIEnvironmentProperty(object): associated object (provides property style access to keys in the WSGI environment) """ + def __init__(self, key, default=''): self.key = key self.default = default @@ -278,6 +280,7 @@ class LazyProperty(object): Property that replaces itself with a calculated value the first time it is used. """ + def __init__(self, func): self.func = func @@ -299,6 +302,7 @@ class DefaultWebTransaction(object): TODO: Provide hooks to allow application specific state to be included in here. """ + def __init__(self, environ): self.environ = environ self.request = Request(environ) @@ -343,6 +347,7 @@ class Request(webob.Request): """ Encapsulates an HTTP request. """ + def __init__(self, environ): """ Create a new request wrapping the WSGI environment `environ` @@ -406,6 +411,7 @@ class Response(object): Describes an HTTP response. Currently very simple since the actual body of the request is handled separately. """ + def __init__(self): """ Create a new Response defaulting to HTML content and "200 OK" status diff --git a/lib/galaxy/web/framework/formbuilder.py b/lib/galaxy/web/framework/formbuilder.py index 4858e002bf9..33c14c47fc7 100644 --- a/lib/galaxy/web/framework/formbuilder.py +++ b/lib/galaxy/web/framework/formbuilder.py @@ -12,6 +12,7 @@ class FormBuilder(object): """ Simple class describing an HTML form """ + def __init__(self, action="", title="", name="form", submit_text="submit", use_panels=False): self.title = title self.name = name @@ -42,6 +43,7 @@ class FormInput(object): """ Simple class describing a form input element """ + def __init__(self, type, name, label, value=None, error=None, help=None, use_label=True, extra_attributes={}, **kwargs): self.type = type self.name = name @@ -70,6 +72,7 @@ class DatalistInput(FormInput): class SelectInput(FormInput): """ A select form input. """ + def __init__(self, name, label, value=None, options=[], error=None, help=None, use_label=True): FormInput.__init__(self, "select", name, label, value=value, error=error, help=help, use_label=use_label) self.options = options @@ -80,6 +83,7 @@ class FormData(object): Class for passing data about a form to a template, very rudimentary, could be combined with the tool form handling to build something more general. """ + def __init__(self): # TODO: galaxy's two Bunchs are defined differently. Is this right? self.values = bunch.Bunch() diff --git a/lib/galaxy/web/framework/helpers/grids.py b/lib/galaxy/web/framework/helpers/grids.py index 2d64ca900c7..52f4d1e84e7 100644 --- a/lib/galaxy/web/framework/helpers/grids.py +++ b/lib/galaxy/web/framework/helpers/grids.py @@ -529,12 +529,14 @@ class GridColumn(object): class ReverseSortColumn(GridColumn): """ Column that reverses sorting; this is useful when the natural sort is descending. """ + def sort(self, trans, query, ascending, column_name=None): return GridColumn.sort(self, trans, query, (not ascending), column_name=column_name) class TextColumn(GridColumn): """ Generic column that employs freetext and, hence, supports freetext, case-independent filtering. """ + def filter(self, trans, user, query, column_filter): """ Modify query to filter using free text, case independence. """ if column_filter == "All": @@ -615,6 +617,7 @@ class IntegerColumn(TextColumn): JobIdColumn column in the SpecifiedDateListGrid class in the jobs controller of the reports webapp for an example. """ + def get_single_filter(self, user, a_filter): model_class_key_field = getattr(self.model_class, self.key) assert int(a_filter), "The search entry must be an integer" @@ -627,6 +630,7 @@ class IntegerColumn(TextColumn): class CommunityRatingColumn(GridColumn, UsesItemRatings): """ Column that displays community ratings for an item. """ + def get_value(self, trans, grid, item): ave_item_rating, num_ratings = self.get_ave_item_rating_data(trans.sa_session, item, webapp_model=trans.model) return trans.fill_template("tool_shed_rating.mako", @@ -667,6 +671,7 @@ class CommunityRatingColumn(GridColumn, UsesItemRatings): class OwnerAnnotationColumn(TextColumn, UsesAnnotations): """ Column that displays and filters item owner's annotations. """ + def __init__(self, col_name, key, model_class=None, model_annotation_association_class=None, filterable=None): GridColumn.__init__(self, col_name, key=key, model_class=model_class, filterable=filterable) self.sortable = False @@ -695,6 +700,7 @@ class OwnerAnnotationColumn(TextColumn, UsesAnnotations): class CommunityTagsColumn(TextColumn): """ Column that supports community tags. """ + def __init__(self, col_name, key, model_class=None, model_tag_association_class=None, filterable=None, grid_name=None): GridColumn.__init__(self, col_name, key=key, model_class=model_class, nowrap=True, filterable=filterable, sortable=False) self.model_tag_association_class = model_tag_association_class @@ -714,24 +720,25 @@ class CommunityTagsColumn(TextColumn): return query def get_filter(self, trans, user, column_filter): - # Parse filter to extract multiple tags. - if isinstance(column_filter, list): - # Collapse list of tags into a single string; this is redundant but effective. TODO: fix this by iterating over tags. - column_filter = ",".join(column_filter) - raw_tags = trans.app.tag_handler.parse_tags(column_filter.encode("utf-8")) - clause_list = [] - for name, value in raw_tags: - if name: - # Filter by all tags. - clause_list.append(self.model_class.tags.any(func.lower(self.model_tag_association_class.user_tname).like("%" + name.lower() + "%"))) - if value: - # Filter by all values. - clause_list.append(self.model_class.tags.any(func.lower(self.model_tag_association_class.user_value).like("%" + value.lower() + "%"))) - return and_(*clause_list) + # Parse filter to extract multiple tags. + if isinstance(column_filter, list): + # Collapse list of tags into a single string; this is redundant but effective. TODO: fix this by iterating over tags. + column_filter = ",".join(column_filter) + raw_tags = trans.app.tag_handler.parse_tags(column_filter.encode("utf-8")) + clause_list = [] + for name, value in raw_tags: + if name: + # Filter by all tags. + clause_list.append(self.model_class.tags.any(func.lower(self.model_tag_association_class.user_tname).like("%" + name.lower() + "%"))) + if value: + # Filter by all values. + clause_list.append(self.model_class.tags.any(func.lower(self.model_tag_association_class.user_value).like("%" + value.lower() + "%"))) + return and_(*clause_list) class IndividualTagsColumn(CommunityTagsColumn): """ Column that supports individual tags. """ + def get_value(self, trans, grid, item): return trans.fill_template("/tagging_common.mako", tag_type="individual", @@ -744,24 +751,25 @@ class IndividualTagsColumn(CommunityTagsColumn): use_toggle_link=True) def get_filter(self, trans, user, column_filter): - # Parse filter to extract multiple tags. - if isinstance(column_filter, list): - # Collapse list of tags into a single string; this is redundant but effective. TODO: fix this by iterating over tags. - column_filter = ",".join(column_filter) - raw_tags = trans.app.tag_handler.parse_tags(column_filter.encode("utf-8")) - clause_list = [] - for name, value in raw_tags: - if name: - # Filter by individual's tag names. - clause_list.append(self.model_class.tags.any(and_(func.lower(self.model_tag_association_class.user_tname).like("%" + name.lower() + "%"), self.model_tag_association_class.user == user))) - if value: - # Filter by individual's tag values. - clause_list.append(self.model_class.tags.any(and_(func.lower(self.model_tag_association_class.user_value).like("%" + value.lower() + "%"), self.model_tag_association_class.user == user))) - return and_(*clause_list) + # Parse filter to extract multiple tags. + if isinstance(column_filter, list): + # Collapse list of tags into a single string; this is redundant but effective. TODO: fix this by iterating over tags. + column_filter = ",".join(column_filter) + raw_tags = trans.app.tag_handler.parse_tags(column_filter.encode("utf-8")) + clause_list = [] + for name, value in raw_tags: + if name: + # Filter by individual's tag names. + clause_list.append(self.model_class.tags.any(and_(func.lower(self.model_tag_association_class.user_tname).like("%" + name.lower() + "%"), self.model_tag_association_class.user == user))) + if value: + # Filter by individual's tag values. + clause_list.append(self.model_class.tags.any(and_(func.lower(self.model_tag_association_class.user_value).like("%" + value.lower() + "%"), self.model_tag_association_class.user == user))) + return and_(*clause_list) class MulticolFilterColumn(TextColumn): """ Column that performs multicolumn filtering. """ + def __init__(self, col_name, cols_to_filter, key, visible, filterable="default"): GridColumn.__init__(self, col_name, key=key, visible=visible, filterable=filterable) self.cols_to_filter = cols_to_filter @@ -788,6 +796,7 @@ class MulticolFilterColumn(TextColumn): class OwnerColumn(TextColumn): """ Column that lists item's owner. """ + def get_value(self, trans, grid, item): return item.user.username @@ -802,6 +811,7 @@ class OwnerColumn(TextColumn): class PublicURLColumn(TextColumn): """ Column displays item's public URL based on username and slug. """ + def get_link(self, trans, grid, item): if item.user.username and item.slug: return dict(action='display_by_username_and_slug', username=item.user.username, slug=item.slug) @@ -815,6 +825,7 @@ class PublicURLColumn(TextColumn): class DeletedColumn(GridColumn): """ Column that tracks and filters for items with deleted attribute. """ + def get_accepted_filters(self): """ Returns a list of accepted filters for this column. """ accepted_filter_labels_and_vals = {"active" : "False", "deleted" : "True", "all": "All"} @@ -840,6 +851,7 @@ class StateColumn(GridColumn): IMPORTANT NOTE: self.model_class must have a states Bunch or dict if this column type is used in the grid. """ + def get_value(self, trans, grid, item): return item.state @@ -863,6 +875,7 @@ class StateColumn(GridColumn): class SharingStatusColumn(GridColumn): """ Grid column to indicate sharing status. """ + def get_value(self, trans, grid, item): # Delete items cannot be shared. if item.deleted: @@ -953,6 +966,7 @@ class GridOperation(object): class DisplayByUsernameAndSlugGridOperation(GridOperation): """ Operation to display an item by username and slug. """ + def get_url_args(self, item): return {'action' : 'display_by_username_and_slug', 'username' : item.user.username, 'slug' : item.slug} diff --git a/lib/galaxy/web/framework/middleware/request_id.py b/lib/galaxy/web/framework/middleware/request_id.py index 78bf85dcf18..46eb644f896 100644 --- a/lib/galaxy/web/framework/middleware/request_id.py +++ b/lib/galaxy/web/framework/middleware/request_id.py @@ -6,6 +6,7 @@ class RequestIDMiddleware(object): A WSGI middleware that creates a unique ID for the request and puts it in the environment """ + def __init__(self, app, global_conf=None): self.app = app diff --git a/lib/galaxy/web/framework/middleware/sentry.py b/lib/galaxy/web/framework/middleware/sentry.py index 2d5ac4454f5..0817fc5fbb3 100644 --- a/lib/galaxy/web/framework/middleware/sentry.py +++ b/lib/galaxy/web/framework/middleware/sentry.py @@ -24,6 +24,7 @@ class Sentry(object): A WSGI middleware which will attempt to capture any uncaught exceptions and send them to Sentry. """ + def __init__(self, application, dsn): assert Client is not None, RAVEN_IMPORT_MESSAGE self.application = application diff --git a/lib/galaxy/web/framework/middleware/translogger.py b/lib/galaxy/web/framework/middleware/translogger.py index 3d6fc831aee..cf837c1421a 100644 --- a/lib/galaxy/web/framework/middleware/translogger.py +++ b/lib/galaxy/web/framework/middleware/translogger.py @@ -74,13 +74,13 @@ class TransLogger(object): if bytes is None: bytes = '-' if time.daylight: - offset = time.altzone / 60 / 60 * -100 + offset = time.altzone / 60 / 60 * -100 else: - offset = time.timezone / 60 / 60 * -100 + offset = time.timezone / 60 / 60 * -100 if offset >= 0: - offset = "+%0.4d" % (offset) + offset = "+%0.4d" % (offset) elif offset < 0: - offset = "%0.4d" % (offset) + offset = "%0.4d" % (offset) d = { 'REMOTE_ADDR': environ.get('REMOTE_ADDR') or '-', 'REMOTE_USER': environ.get('REMOTE_USER') or '-', diff --git a/lib/galaxy/web/framework/middleware/xforwardedhost.py b/lib/galaxy/web/framework/middleware/xforwardedhost.py index c9cb16d8306..ff5e394c062 100644 --- a/lib/galaxy/web/framework/middleware/xforwardedhost.py +++ b/lib/galaxy/web/framework/middleware/xforwardedhost.py @@ -3,6 +3,7 @@ class XForwardedHostMiddleware(object): A WSGI middleware that changes the HTTP host header in the WSGI environ based on the X-Forwarded-Host header IF found """ + def __init__(self, app, global_conf=None): self.app = app diff --git a/lib/galaxy/web/framework/webapp.py b/lib/galaxy/web/framework/webapp.py index c9581c14ef8..be91c09b9ed 100644 --- a/lib/galaxy/web/framework/webapp.py +++ b/lib/galaxy/web/framework/webapp.py @@ -70,6 +70,7 @@ class WebApplication(base.WebApplication): * builds mako template lookups. * generates GalaxyWebTransactions. """ + def __init__(self, galaxy_app, session_cookie='galaxysession', name=None): self.name = name base.WebApplication.__init__(self) diff --git a/lib/galaxy/webapps/galaxy/api/provenance.py b/lib/galaxy/webapps/galaxy/api/provenance.py index 546163f2ddd..f3d0c5f1542 100644 --- a/lib/galaxy/webapps/galaxy/api/provenance.py +++ b/lib/galaxy/webapps/galaxy/api/provenance.py @@ -13,6 +13,7 @@ log = logging.getLogger(__name__) class BaseProvenanceController(BaseAPIController): """ """ + def __init__(self, app): super(BaseProvenanceController, self).__init__(app) self.hda_manager = managers.hdas.HDAManager(app) diff --git a/lib/galaxy/webapps/galaxy/api/remote_files.py b/lib/galaxy/webapps/galaxy/api/remote_files.py index 920ddc71efe..9dc39fc8222 100644 --- a/lib/galaxy/webapps/galaxy/api/remote_files.py +++ b/lib/galaxy/webapps/galaxy/api/remote_files.py @@ -70,13 +70,13 @@ class RemoteFilesAPIController(BaseAPIController): if base_dir is None: raise exceptions.ConfigDoesNotAllowException('The configuration of this Galaxy instance does not allow usage of import directory.') if format == 'jstree': - disable = kwd.get('disable', 'folders') - try: - importdir_jstree = self.__create_jstree(base_dir, disable) - response = importdir_jstree.jsonData() - except Exception as exception: - log.debug(str(exception)) - raise exceptions.InternalServerError('Could not create tree representation of the given folder: ' + str(base_dir)) + disable = kwd.get('disable', 'folders') + try: + importdir_jstree = self.__create_jstree(base_dir, disable) + response = importdir_jstree.jsonData() + except Exception as exception: + log.debug(str(exception)) + raise exceptions.InternalServerError('Could not create tree representation of the given folder: ' + str(base_dir)) elif format == 'ajax': raise exceptions.NotImplemented('Not implemented yet. Sorry.') else: diff --git a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py index f660f3e9d29..18b9910e144 100644 --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -787,9 +787,9 @@ class AdminToolshed(AdminGalaxy): message = 'All selected tool dependencies are already installed.' status = 'error' else: - message = 'Set the value of your tool_dependency_dir setting in your Galaxy config file (galaxy.ini) ' - message += ' and restart your Galaxy server to install tool dependencies.' - status = 'error' + message = 'Set the value of your tool_dependency_dir setting in your Galaxy config file (galaxy.ini) ' + message += ' and restart your Galaxy server to install tool dependencies.' + status = 'error' installed_tool_dependencies_select_field = \ tool_dependency_util.build_tool_dependencies_select_field(trans.app, tool_shed_repository=tool_shed_repository, @@ -856,10 +856,10 @@ class AdminToolshed(AdminGalaxy): kwd['message'] = 'All selected tool dependencies are already installed.' kwd['status'] = 'error' else: - message = 'Set the value of your tool_dependency_dir setting in your Galaxy config file (galaxy.ini) ' - message += ' and restart your Galaxy server to install tool dependencies.' - kwd['message'] = message - kwd['status'] = 'error' + message = 'Set the value of your tool_dependency_dir setting in your Galaxy config file (galaxy.ini) ' + message += ' and restart your Galaxy server to install tool dependencies.' + kwd['message'] = message + kwd['status'] = 'error' # Redirect if no tool dependencies are in the process of being installed. if tool_shed_repository.tool_dependencies_being_installed: return self.tool_dependency_grid(trans, **kwd) diff --git a/lib/galaxy/webapps/galaxy/controllers/requests_common.py b/lib/galaxy/webapps/galaxy/controllers/requests_common.py index c7325e443cc..db764265984 100644 --- a/lib/galaxy/webapps/galaxy/controllers/requests_common.py +++ b/lib/galaxy/webapps/galaxy/controllers/requests_common.py @@ -1620,13 +1620,13 @@ class RequestsCommon(BaseUIController, UsesFormDefinitionsMixin): workflow_dict['mappings'][int(k[len(kwd_tag):])] = {'ds_tag': v} field_values = {} for field_index, field in enumerate(request.type.sample_form.fields): - field_name = field['name'] - input_value = params.get('sample_%i_field_%i' % (index, field_index), '') - if field['type'] == CheckboxField.__name__: - field_value = CheckboxField.is_checked(input_value) - else: - field_value = util.restore_text(input_value) - field_values[field_name] = field_value + field_name = field['name'] + input_value = params.get('sample_%i_field_%i' % (index, field_index), '') + if field['type'] == CheckboxField.__name__: + field_value = CheckboxField.is_checked(input_value) + else: + field_value = util.restore_text(input_value) + field_values[field_name] = field_value library_select_field, folder_select_field = self.__build_library_and_folder_select_fields(trans=trans, user=request.user, sample_index=index, diff --git a/lib/galaxy/webapps/galaxy/controllers/root.py b/lib/galaxy/webapps/galaxy/controllers/root.py index ecb6efc29ae..4817aee5b84 100644 --- a/lib/galaxy/webapps/galaxy/controllers/root.py +++ b/lib/galaxy/webapps/galaxy/controllers/root.py @@ -24,6 +24,7 @@ class RootController(controller.JSAppLauncher, UsesAnnotations): """ Controller class that maps to the url root of Galaxy (i.e. '/'). """ + def __init__(self, app): super(RootController, self).__init__(app) self.history_manager = managers.histories.HistoryManager(app) diff --git a/lib/galaxy/webapps/galaxy/controllers/userskeys.py b/lib/galaxy/webapps/galaxy/controllers/userskeys.py index 60b282119e4..4f85fc6b3ed 100644 --- a/lib/galaxy/webapps/galaxy/controllers/userskeys.py +++ b/lib/galaxy/webapps/galaxy/controllers/userskeys.py @@ -66,12 +66,12 @@ class User(BaseUIController, UsesFormDefinitionsMixin): for user in trans.sa_session.query(trans.app.model.User) \ .filter(trans.app.model.User.table.c.deleted == false()) \ .order_by(trans.app.model.User.table.c.email): - uid = int(user.id) - userkey = "" - for api_user in trans.sa_session.query(trans.app.model.APIKeys) \ - .filter(trans.app.model.APIKeys.user_id == uid): - userkey = api_user.key - users.append({'uid': uid, 'email': user.email, 'key': userkey}) + uid = int(user.id) + userkey = "" + for api_user in trans.sa_session.query(trans.app.model.APIKeys) \ + .filter(trans.app.model.APIKeys.user_id == uid): + userkey = api_user.key + users.append({'uid': uid, 'email': user.email, 'key': userkey}) return trans.fill_template('webapps/galaxy/user/list_users.mako', cntrller=cntrller, users=users, diff --git a/lib/galaxy/webapps/reports/app.py b/lib/galaxy/webapps/reports/app.py index 8d898854c81..109f3eceec1 100644 --- a/lib/galaxy/webapps/reports/app.py +++ b/lib/galaxy/webapps/reports/app.py @@ -11,6 +11,7 @@ log = logging.getLogger(__name__) class UniverseApplication(object): """Encapsulates the state of a Universe application""" + def __init__(self, **kwargs): log.debug("python path is: %s", ", ".join(sys.path)) self.name = "reports" diff --git a/lib/galaxy/webapps/tool_shed/util/ratings_util.py b/lib/galaxy/webapps/tool_shed/util/ratings_util.py index 5767575f510..8a4e848bbf7 100644 --- a/lib/galaxy/webapps/tool_shed/util/ratings_util.py +++ b/lib/galaxy/webapps/tool_shed/util/ratings_util.py @@ -7,6 +7,7 @@ log = logging.getLogger(__name__) class ItemRatings(UsesItemRatings): """Overrides rate_item method since we also allow for comments""" + def rate_item(self, trans, user, item, rating, comment=''): """ Rate an item. Return type is RatingAssociation. """ item_rating = self.get_user_item_rating(trans.sa_session, user, item, webapp_model=trans.model) diff --git a/lib/galaxy/workflow/extract.py b/lib/galaxy/workflow/extract.py index f113a9f3146..53161117f70 100644 --- a/lib/galaxy/workflow/extract.py +++ b/lib/galaxy/workflow/extract.py @@ -163,6 +163,7 @@ class FakeJob(object): Fake job object for datasets that have no creating_job_associations, they will be treated as "input" datasets. """ + def __init__(self, dataset): self.is_fake = True self.id = "fake_%s" % dataset.id diff --git a/lib/tool_shed/galaxy_install/grids/admin_toolshed_grids.py b/lib/tool_shed/galaxy_install/grids/admin_toolshed_grids.py index b5342176723..2f18a37784c 100644 --- a/lib/tool_shed/galaxy_install/grids/admin_toolshed_grids.py +++ b/lib/tool_shed/galaxy_install/grids/admin_toolshed_grids.py @@ -112,14 +112,14 @@ class InstalledRepositoryGrid(grids.Grid): class DeletedColumn(grids.DeletedColumn): - def get_accepted_filters(self): - """ Returns a list of accepted filters for this column. """ - accepted_filter_labels_and_vals = {"Active": "False", "Deactivated or uninstalled": "True", "All": "All"} - accepted_filters = [] - for label, val in accepted_filter_labels_and_vals.items(): - args = {self.key: val} - accepted_filters.append(grids.GridColumnFilter(label, args)) - return accepted_filters + def get_accepted_filters(self): + """ Returns a list of accepted filters for this column. """ + accepted_filter_labels_and_vals = {"Active": "False", "Deactivated or uninstalled": "True", "All": "All"} + accepted_filters = [] + for label, val in accepted_filter_labels_and_vals.items(): + args = {self.key: val} + accepted_filters.append(grids.GridColumnFilter(label, args)) + return accepted_filters # Grid definition title = "Installed tool shed repositories" diff --git a/test/casperjs/casperjs_runner.py b/test/casperjs/casperjs_runner.py index abd0b0f8aae..cec9d794fd6 100644 --- a/test/casperjs/casperjs_runner.py +++ b/test/casperjs/casperjs_runner.py @@ -345,6 +345,7 @@ class Test_01_User(CasperJSTestCase): """Tests for the Galaxy user centered functionality: registration, login, etc. """ + def test_10_registration(self): """User registration tests: register new user, logout, attempt bad registrations. @@ -369,6 +370,7 @@ class Test_01_User(CasperJSTestCase): class Test_02_Tools(CasperJSTestCase): """(Minimal) casperjs tests for tools. """ + def test_10_upload(self): """Tests uploading files """ @@ -378,6 +380,7 @@ class Test_02_Tools(CasperJSTestCase): class Test_03_HistoryPanel(CasperJSTestCase): """Tests for History fetching, rendering, and modeling. """ + def test_00_history_panel(self): """Test history panel basics (controls, structure, refresh, history options menu, etc.). """ @@ -397,6 +400,7 @@ class Test_03_HistoryPanel(CasperJSTestCase): class Test_04_HDAs(CasperJSTestCase): """Tests for HistoryDatasetAssociation fetching, rendering, and modeling. """ + def test_00_HDA_states(self): """Test structure rendering of HDAs in all the possible HDA states """ @@ -406,6 +410,7 @@ class Test_04_HDAs(CasperJSTestCase): class Test_05_API(CasperJSTestCase): """Tests for API functionality and security. """ + def test_00_history_api(self): """Test history API. """ diff --git a/test/galaxy_selenium/driver_factory.py b/test/galaxy_selenium/driver_factory.py index 4520c70b627..70e3610e5f1 100644 --- a/test/galaxy_selenium/driver_factory.py +++ b/test/galaxy_selenium/driver_factory.py @@ -76,7 +76,7 @@ def _which(file): # http://stackoverflow.com/questions/5226958/which-equivalent-function-in-python for path in os.environ["PATH"].split(":"): if os.path.exists(path + "/" + file): - return path + "/" + file + return path + "/" + file return None diff --git a/test/shed_functional/functional/test_0060_workflows.py b/test/shed_functional/functional/test_0060_workflows.py index a1331949ac9..0f3d5cde4a8 100644 --- a/test/shed_functional/functional/test_0060_workflows.py +++ b/test/shed_functional/functional/test_0060_workflows.py @@ -19,6 +19,7 @@ workflow_repository_long_description = "Long description of the workflow for tes class TestToolShedWorkflowFeatures(ShedTwillTestCase): '''Test valid and invalid workflows.''' + def test_0000_initiate_users(self): """Create necessary user accounts and login as an admin user.""" self.login(email=common.test_user_1_email, username=common.test_user_1_name) diff --git a/test/shed_functional/functional/test_0400_repository_component_reviews.py b/test/shed_functional/functional/test_0400_repository_component_reviews.py index 80899114a8a..71a439d4cde 100644 --- a/test/shed_functional/functional/test_0400_repository_component_reviews.py +++ b/test/shed_functional/functional/test_0400_repository_component_reviews.py @@ -37,6 +37,7 @@ repository_long_description = 'Long description of Galaxy filtering tool for tes class TestRepositoryComponentReviews(ShedTwillTestCase): '''Test repository component review features.''' + def test_0000_initiate_users(self): """Create necessary user accounts and login as an admin user.""" """ diff --git a/test/shed_functional/functional/test_0410_repository_component_review_access_control.py b/test/shed_functional/functional/test_0410_repository_component_review_access_control.py index 79fcba42eb7..d2628f0d4c9 100644 --- a/test/shed_functional/functional/test_0410_repository_component_review_access_control.py +++ b/test/shed_functional/functional/test_0410_repository_component_review_access_control.py @@ -17,6 +17,7 @@ repository_long_description = 'Long description of Galaxy filtering tool for tes class TestRepositoryComponentReviews(ShedTwillTestCase): '''Test repository component review features.''' + def test_0000_initiate_users(self): """Create necessary user accounts and login as an admin user.""" """ diff --git a/test/shed_functional/functional/test_0420_citable_urls_for_repositories.py b/test/shed_functional/functional/test_0420_citable_urls_for_repositories.py index e312069c1ee..9f6e1b63c6b 100644 --- a/test/shed_functional/functional/test_0420_citable_urls_for_repositories.py +++ b/test/shed_functional/functional/test_0420_citable_urls_for_repositories.py @@ -26,6 +26,7 @@ first_changeset_hash = '' class TestRepositoryCitableURLs(ShedTwillTestCase): '''Test repository citable url features.''' + def test_0000_initiate_users(self): """Create necessary user accounts and login as an admin user.""" """ diff --git a/test/shed_functional/functional/test_1010_install_repository_with_tool_dependencies.py b/test/shed_functional/functional/test_1010_install_repository_with_tool_dependencies.py index 55f4ec79bd4..6d009c00c62 100644 --- a/test/shed_functional/functional/test_1010_install_repository_with_tool_dependencies.py +++ b/test/shed_functional/functional/test_1010_install_repository_with_tool_dependencies.py @@ -12,6 +12,7 @@ log = logging.getLogger(__name__) class ToolWithToolDependencies(ShedTwillTestCase): '''Test installing a repository with tool dependencies.''' + def test_0000_initiate_users(self): """Create necessary user accounts.""" self.galaxy_login(email=common.admin_email, username=common.admin_username) diff --git a/test/shed_functional/functional/test_1060_install_repository_with_workflow.py b/test/shed_functional/functional/test_1060_install_repository_with_workflow.py index 2ae72777491..ff6e94435d0 100644 --- a/test/shed_functional/functional/test_1060_install_repository_with_workflow.py +++ b/test/shed_functional/functional/test_1060_install_repository_with_workflow.py @@ -20,6 +20,7 @@ workflow_repository_long_description = "Long description of the workflow for tes class ToolWithRepositoryDependencies(ShedTwillTestCase): '''Test installing a repository with repository dependencies.''' + def test_0000_initiate_users(self): """Create necessary user accounts.""" self.galaxy_login(email=common.admin_email, username=common.admin_username) diff --git a/test/shed_functional/functional/test_1070_invalid_tool.py b/test/shed_functional/functional/test_1070_invalid_tool.py index aa28c6fd20d..bf8e3aad69f 100644 --- a/test/shed_functional/functional/test_1070_invalid_tool.py +++ b/test/shed_functional/functional/test_1070_invalid_tool.py @@ -9,6 +9,7 @@ category_description = 'Test 1070 for a repository with an invalid tool.' class TestFreebayesRepository(ShedTwillTestCase): '''Test repository with multiple revisions with invalid tools.''' + def test_0000_create_or_login_admin_user(self): """Create necessary user accounts and login as an admin user.""" self.galaxy_login(email=common.admin_email, username=common.admin_username) diff --git a/tools/data_source/upload.py b/tools/data_source/upload.py index e1415c6a972..b47892afd3e 100644 --- a/tools/data_source/upload.py +++ b/tools/data_source/upload.py @@ -346,39 +346,39 @@ def add_file(dataset, registry, json_file, output_path): def add_composite_file(dataset, json_file, output_path, files_path): - if dataset.composite_files: - os.mkdir(files_path) - for name, value in dataset.composite_files.items(): - value = util.bunch.Bunch(**value) - if dataset.composite_file_paths[value.name] is None and not value.optional: - file_err('A required composite data file was not provided (%s)' % name, dataset, json_file) - break - elif dataset.composite_file_paths[value.name] is not None: - dp = dataset.composite_file_paths[value.name]['path'] - isurl = dp.find('://') != -1 # todo fixme - if isurl: - try: - temp_name, dataset.is_multi_byte = sniff.stream_to_file(urlopen(dp), prefix='url_paste') - except Exception as e: - file_err('Unable to fetch %s\n%s' % (dp, str(e)), dataset, json_file) - return - dataset.path = temp_name - dp = temp_name - if not value.is_binary: - tmpdir = output_adjacent_tmpdir(output_path) - tmp_prefix = 'data_id_%s_convert_' % dataset.dataset_id - if dataset.composite_file_paths[value.name].get('space_to_tab', value.space_to_tab): - sniff.convert_newlines_sep2tabs(dp, tmp_dir=tmpdir, tmp_prefix=tmp_prefix) - else: - sniff.convert_newlines(dp, tmp_dir=tmpdir, tmp_prefix=tmp_prefix) - shutil.move(dp, os.path.join(files_path, name)) - # Move the dataset to its "real" path - shutil.move(dataset.primary_file, output_path) - # Write the job info - info = dict(type='dataset', - dataset_id=dataset.dataset_id, - stdout='uploaded %s file' % dataset.file_type) - json_file.write(dumps(info) + "\n") + if dataset.composite_files: + os.mkdir(files_path) + for name, value in dataset.composite_files.items(): + value = util.bunch.Bunch(**value) + if dataset.composite_file_paths[value.name] is None and not value.optional: + file_err('A required composite data file was not provided (%s)' % name, dataset, json_file) + break + elif dataset.composite_file_paths[value.name] is not None: + dp = dataset.composite_file_paths[value.name]['path'] + isurl = dp.find('://') != -1 # todo fixme + if isurl: + try: + temp_name, dataset.is_multi_byte = sniff.stream_to_file(urlopen(dp), prefix='url_paste') + except Exception as e: + file_err('Unable to fetch %s\n%s' % (dp, str(e)), dataset, json_file) + return + dataset.path = temp_name + dp = temp_name + if not value.is_binary: + tmpdir = output_adjacent_tmpdir(output_path) + tmp_prefix = 'data_id_%s_convert_' % dataset.dataset_id + if dataset.composite_file_paths[value.name].get('space_to_tab', value.space_to_tab): + sniff.convert_newlines_sep2tabs(dp, tmp_dir=tmpdir, tmp_prefix=tmp_prefix) + else: + sniff.convert_newlines(dp, tmp_dir=tmpdir, tmp_prefix=tmp_prefix) + shutil.move(dp, os.path.join(files_path, name)) + # Move the dataset to its "real" path + shutil.move(dataset.primary_file, output_path) + # Write the job info + info = dict(type='dataset', + dataset_id=dataset.dataset_id, + stdout='uploaded %s file' % dataset.file_type) + json_file.write(dumps(info) + "\n") def output_adjacent_tmpdir(output_path):