mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 05:45:37 +08:00
Add autopep8 script to help rebasing branches after #4440.
Fixes a few more PEP8 issues as part of the autopep8'ing as well.
This commit is contained in:
Executable
+2
@@ -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/
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -291,6 +291,7 @@ class MultiSourceDataProvider(DataProvider):
|
||||
|
||||
An iterator over iterators.
|
||||
"""
|
||||
|
||||
def __init__(self, source_list, **kwargs):
|
||||
"""
|
||||
:param source_list: an iterator of iterables
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <this_provider.source.file_name>)
|
||||
"""
|
||||
|
||||
def __init__(self, source, **kwargs):
|
||||
# TODO:
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -106,6 +106,7 @@ class XGMMLGraphDataProvider(dataproviders.hierarchy.XMLDataProvider):
|
||||
'edges': contains objects of the form:
|
||||
{ 'source' : <an index into nodes>, 'target': <an index into nodes>, 'data': <any extra 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' : <an index into nodes>, 'target': <an index into nodes>, 'data': <any extra 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
|
||||
|
||||
@@ -754,7 +754,7 @@ class CML(GenericXml):
|
||||
if line.lstrip().startswith('<?xml version="1.0"?>') or \
|
||||
line.lstrip().startswith('<cml xmlns="http://www.xml-cml.org/schema') or \
|
||||
line.lstrip().startswith('</cml>'):
|
||||
continue
|
||||
continue
|
||||
lines.append(line)
|
||||
if line.lstrip().startswith('</molecule>'):
|
||||
yield lines
|
||||
|
||||
@@ -904,6 +904,7 @@ class SffFlow(Tabular):
|
||||
GQY1XT001CQIRF 84 1.02 0.06 0.98 0.06 0.09 1.05 0.07 ...
|
||||
GQY1XT001CF5YW 88 1.02 0.02 1.01 0.04 0.06 1.02 0.03 ...
|
||||
"""
|
||||
|
||||
def __init__(self, **kwd):
|
||||
super(SffFlow, self).__init__(**kwd)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class Neo4j(Html):
|
||||
derived from html - composite datatype elements
|
||||
stored in extra files path
|
||||
"""
|
||||
|
||||
def generate_primary_file(self, dataset=None):
|
||||
"""
|
||||
This is called only at upload to write the html file
|
||||
|
||||
@@ -487,6 +487,7 @@ class SnpSiftDbNSFP(Text):
|
||||
## Create tabix index
|
||||
tabix -s 1 -b 2 -e 2 dbNSFP2.3.txt.gz
|
||||
"""
|
||||
|
||||
def __init__(self, **kwd):
|
||||
Text.__init__(self, **kwd)
|
||||
self.add_composite_file('%s.gz', description='dbNSFP bgzip', substitute_name_with_metadata='reference_name', is_binary=True)
|
||||
|
||||
@@ -16,6 +16,7 @@ class GFFInterval(GenomicInterval):
|
||||
A GFF interval, including attributes. If file is strictly a GFF file,
|
||||
only attribute is 'group.'
|
||||
"""
|
||||
|
||||
def __init__(self, reader, fields, chrom_col=0, feature_col=2, start_col=3, end_col=4,
|
||||
strand_col=6, score_col=5, default_strand='.', fix_strand=False):
|
||||
# HACK: GFF format allows '.' for strand but GenomicInterval does not. To get around this,
|
||||
@@ -52,6 +53,7 @@ class GFFFeature(GFFInterval):
|
||||
"""
|
||||
A GFF feature, which can include multiple intervals.
|
||||
"""
|
||||
|
||||
def __init__(self, reader, chrom_col=0, feature_col=2, start_col=3, end_col=4,
|
||||
strand_col=6, score_col=5, default_strand='.', fix_strand=False, intervals=[],
|
||||
raw_size=0):
|
||||
|
||||
@@ -55,6 +55,7 @@ class JobDestination(Bunch):
|
||||
"""
|
||||
Provides details about where a job runs
|
||||
"""
|
||||
|
||||
def __init__(self, **kwds):
|
||||
self['id'] = None
|
||||
self['url'] = None
|
||||
@@ -87,6 +88,7 @@ class JobToolConfiguration(Bunch):
|
||||
A JobToolConfiguration will have the required attribute 'id' and optional
|
||||
attributes 'handler', 'destination', and 'params'
|
||||
"""
|
||||
|
||||
def __init__(self, **kwds):
|
||||
self['handler'] = None
|
||||
self['destination'] = None
|
||||
@@ -723,6 +725,7 @@ class JobWrapper(object, HasResourceParameters):
|
||||
Wraps a 'model.Job' with convenience methods for running processes and
|
||||
state management.
|
||||
"""
|
||||
|
||||
def __init__(self, job, queue, use_persisted_destination=False):
|
||||
self.job_id = job.id
|
||||
self.session_id = job.session_id
|
||||
@@ -2101,6 +2104,7 @@ class NoopQueue(object):
|
||||
"""
|
||||
Implements the JobQueue / JobStopQueue interface but does nothing
|
||||
"""
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
return
|
||||
|
||||
@@ -2116,6 +2120,7 @@ class ParallelismInfo(object):
|
||||
Stores the information (if any) for running multiple instances of the tool in parallel
|
||||
on the same set of inputs.
|
||||
"""
|
||||
|
||||
def __init__(self, tag):
|
||||
self.method = tag.get('method')
|
||||
if isinstance(tag, dict):
|
||||
|
||||
@@ -151,6 +151,7 @@ class DeferredJobQueue(object):
|
||||
|
||||
class FakeTrans(object):
|
||||
"""A fake trans for calling the external set metadata tool"""
|
||||
|
||||
def __init__(self, app, history=None, user=None):
|
||||
class Dummy(object):
|
||||
def __init__(self):
|
||||
|
||||
@@ -27,6 +27,7 @@ class JobHandler(object):
|
||||
"""
|
||||
Handle the preparation, running, tracking, and finishing of jobs
|
||||
"""
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
# The dispatcher launches the underlying job runners
|
||||
@@ -109,11 +110,11 @@ class JobHandlerQueue(object):
|
||||
model.Job.states.QUEUED,
|
||||
model.Job.states.RUNNING)
|
||||
if self.app.config.user_activation_on:
|
||||
jobs_at_startup = self.sa_session.query(model.Job).enable_eagerloads(False) \
|
||||
.outerjoin(model.User) \
|
||||
.filter(model.Job.state.in_(in_list) &
|
||||
(model.Job.handler == self.app.config.server_name) &
|
||||
or_((model.Job.user_id == null()), (model.User.active == true()))).all()
|
||||
jobs_at_startup = self.sa_session.query(model.Job).enable_eagerloads(False) \
|
||||
.outerjoin(model.User) \
|
||||
.filter(model.Job.state.in_(in_list) &
|
||||
(model.Job.handler == self.app.config.server_name) &
|
||||
or_((model.Job.user_id == null()), (model.User.active == true()))).all()
|
||||
else:
|
||||
jobs_at_startup = self.sa_session.query(model.Job).enable_eagerloads(False) \
|
||||
.filter(model.Job.state.in_(in_list) &
|
||||
|
||||
@@ -16,6 +16,7 @@ class JobManager(object):
|
||||
TODO: Currently the app accesses "job_queue" and "job_stop_queue" directly.
|
||||
This should be decoupled.
|
||||
"""
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
if self.app.is_job_handler():
|
||||
|
||||
@@ -21,6 +21,7 @@ class Godocker(object):
|
||||
"""
|
||||
API parameters
|
||||
"""
|
||||
|
||||
def __init__(self, server, login, apikey, noCert):
|
||||
self.token = None
|
||||
self.server = server
|
||||
|
||||
@@ -11,6 +11,7 @@ class DrmaaSessionFactory(object):
|
||||
"""
|
||||
Abstraction used to production DrmaaSession wrappers.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.session_constructor = Session
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class TransferManager(object):
|
||||
"""
|
||||
Manage simple data transfers from URLs to temporary locations.
|
||||
"""
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
self.sa_session = app.model.context.current
|
||||
|
||||
@@ -18,6 +18,7 @@ class DeletableManagerMixin(object):
|
||||
that they are no longer needed, should not be displayed, or may be actually
|
||||
removed by an admin/script.
|
||||
"""
|
||||
|
||||
def delete(self, item, flush=True, **kwargs):
|
||||
"""
|
||||
Mark as deleted and return.
|
||||
@@ -72,6 +73,7 @@ class PurgableManagerMixin(DeletableManagerMixin):
|
||||
purging is often removal of some additional, non-db resource (e.g. a dataset's
|
||||
file).
|
||||
"""
|
||||
|
||||
def purge(self, item, flush=True, **kwargs):
|
||||
"""
|
||||
Mark as purged and return.
|
||||
|
||||
@@ -3304,6 +3304,7 @@ class DatasetCollection(object, Dictifiable, UsesAnnotations):
|
||||
class DatasetCollectionInstance(object, HasName):
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
collection=None,
|
||||
|
||||
@@ -21,6 +21,7 @@ class UsesItemRatings:
|
||||
(2) item-rating association table has a column with a foreign key referencing
|
||||
item table that contains the item's id.
|
||||
"""
|
||||
|
||||
def get_ave_item_rating_data(self, db_session, item, webapp_model=None):
|
||||
""" Returns the average rating for an item."""
|
||||
if webapp_model is None:
|
||||
@@ -96,6 +97,7 @@ class UsesItemRatings:
|
||||
|
||||
class UsesAnnotations:
|
||||
""" Mixin for getting and setting item annotations. """
|
||||
|
||||
def get_item_annotation_str(self, db_session, user, item):
|
||||
""" Returns a user's annotation string for an item. """
|
||||
annotation_obj = self.get_item_annotation_obj(db_session, user, item)
|
||||
|
||||
@@ -37,6 +37,7 @@ class Statement(object):
|
||||
statements. This is how we shove the metadata element spec into
|
||||
the class.
|
||||
"""
|
||||
|
||||
def __init__(self, target):
|
||||
self.target = target
|
||||
|
||||
@@ -61,6 +62,7 @@ class MetadataCollection(object):
|
||||
handles processing the metadata elements when they are set and
|
||||
retrieved, returning default values in cases when metadata is not set.
|
||||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
# initialize dict if needed
|
||||
@@ -205,6 +207,7 @@ class MetadataSpecCollection(odict):
|
||||
list. append() is also implemented for simplicity and does not
|
||||
"append".
|
||||
"""
|
||||
|
||||
def __init__(self, dict=None):
|
||||
odict.__init__(self, dict=None)
|
||||
|
||||
@@ -309,6 +312,7 @@ class MetadataElementSpec(object):
|
||||
Defines a metadata element and adds it to the metadata_spec (which
|
||||
is a MetadataSpecCollection) of datatype.
|
||||
"""
|
||||
|
||||
def __init__(self, datatype, name=None, desc=None,
|
||||
param=MetadataParameter, default=None, no_value=None,
|
||||
visible=True, set_in_upload=False, **kwargs):
|
||||
|
||||
@@ -58,6 +58,7 @@ class TraceLoggerProxy(ConnectionProxy):
|
||||
"""
|
||||
Logs SQL statements using a metlog client
|
||||
"""
|
||||
|
||||
def __init__(self, trace_logger):
|
||||
self.trace_logger = trace_logger
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ class ViewField(object):
|
||||
its chain of parents to find out which library it belongs to
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, name, sqlalchemy_field=None, handler=None, post_filter=None, id_decode=False):
|
||||
self.name = name
|
||||
self.sqlalchemy_field = sqlalchemy_field
|
||||
@@ -603,6 +604,7 @@ class GalaxyQuery(object):
|
||||
"""
|
||||
This class represents a data structure of a compiled GQL query
|
||||
"""
|
||||
|
||||
def __init__(self, field_list, table_name, conditional):
|
||||
self.field_list = field_list
|
||||
self.table_name = table_name
|
||||
@@ -614,6 +616,7 @@ class GalaxyQueryComparison(object):
|
||||
This class represents the data structure of the comparison arguments of a
|
||||
compiled GQL query (ie where name='Untitled History')
|
||||
"""
|
||||
|
||||
def __init__(self, left, operator, right):
|
||||
self.left = left
|
||||
self.operator = operator
|
||||
@@ -625,6 +628,7 @@ class GalaxyQueryAnd(object):
|
||||
This class represents the data structure of the comparison arguments of a
|
||||
compiled GQL query (ie where name='Untitled History')
|
||||
"""
|
||||
|
||||
def __init__(self, left, right):
|
||||
self.left = left
|
||||
self.operator = 'and'
|
||||
@@ -669,6 +673,7 @@ class GalaxySearchEngine(object):
|
||||
"""
|
||||
Primary class for searching. Parses GQL (Galaxy Query Language) queries and returns a 'SearchQuery' class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.parser = parsley.makeGrammar(gqlGrammar, {
|
||||
're': re,
|
||||
|
||||
@@ -749,6 +749,7 @@ def build_object_store_from_config(config, fsmon=False, config_xml=None):
|
||||
|
||||
def local_extra_dirs(func):
|
||||
"""Non-local plugin decorator using local directories for the extra_dirs (job_work and temp)."""
|
||||
|
||||
def wraps(self, *args, **kwargs):
|
||||
if kwargs.get('base_dir', None) is None:
|
||||
return func(self, *args, **kwargs)
|
||||
|
||||
@@ -35,6 +35,7 @@ class AzureBlobObjectStore(ObjectStore):
|
||||
cache exists that is used as an intermediate location for files between
|
||||
Galaxy and Azure.
|
||||
"""
|
||||
|
||||
def __init__(self, config, config_xml):
|
||||
if BlockBlobService is None:
|
||||
raise Exception(NO_BLOBSERVICE_ERROR_MESSAGE)
|
||||
|
||||
@@ -75,6 +75,7 @@ class PithosObjectStore(ObjectStore):
|
||||
Object store that stores objects as items in a Pithos+ container.
|
||||
Cache is ignored for the time being.
|
||||
"""
|
||||
|
||||
def __init__(self, config, config_xml):
|
||||
if KamakiClient is None:
|
||||
raise Exception(NO_KAMAKI_ERROR_MESSAGE)
|
||||
|
||||
@@ -33,6 +33,7 @@ class IRODSObjectStore(DiskObjectStore):
|
||||
"""
|
||||
Galaxy object store based on iRODS
|
||||
"""
|
||||
|
||||
def __init__(self, config, file_path=None, extra_dirs=None):
|
||||
super(IRODSObjectStore, self).__init__(config, file_path=file_path, extra_dirs=extra_dirs)
|
||||
assert irods is not None, IRODS_IMPORT_MESSAGE
|
||||
|
||||
@@ -47,6 +47,7 @@ class S3ObjectStore(ObjectStore):
|
||||
cache exists that is used as an intermediate location for files between
|
||||
Galaxy and S3.
|
||||
"""
|
||||
|
||||
def __init__(self, config, config_xml):
|
||||
if boto is None:
|
||||
raise Exception(NO_BOTO_ERROR_MESSAGE)
|
||||
|
||||
@@ -103,7 +103,7 @@ def _get_new_toolbox(app):
|
||||
from galaxy import tools
|
||||
from galaxy.tools.special_tools import load_lib_tools
|
||||
if hasattr(app, 'tool_shed_repository_cache'):
|
||||
app.tool_shed_repository_cache.rebuild()
|
||||
app.tool_shed_repository_cache.rebuild()
|
||||
tool_configs = app.config.tool_configs
|
||||
if app.config.migrated_tools_config not in tool_configs:
|
||||
tool_configs.append(app.config.migrated_tools_config)
|
||||
@@ -196,6 +196,7 @@ class GalaxyQueueWorker(ConsumerMixin, threading.Thread):
|
||||
handler, will have one of these used for dispatching so called 'control'
|
||||
tasks.
|
||||
"""
|
||||
|
||||
def __init__(self, app, queue=None, task_mapping=control_message_to_task, connection=None):
|
||||
super(GalaxyQueueWorker, self).__init__()
|
||||
log.info("Initializing %s Galaxy Queue Worker on %s", app.config.server_name, util.mask_password_from_url(app.config.amqp_internal_connection))
|
||||
|
||||
@@ -10,6 +10,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class NoQuotaAgent(object):
|
||||
"""Base quota agent, always returns no quota"""
|
||||
|
||||
def __init__(self, model):
|
||||
self.model = model
|
||||
self.sa_session = model.context
|
||||
@@ -42,6 +43,7 @@ class NoQuotaAgent(object):
|
||||
|
||||
class QuotaAgent(NoQuotaAgent):
|
||||
"""Class that handles galaxy quotas"""
|
||||
|
||||
def get_quota(self, user, nice_size=False):
|
||||
"""
|
||||
Calculated like so:
|
||||
|
||||
@@ -223,9 +223,9 @@ class GalaxyRBACAgent(RBACAgent):
|
||||
"""
|
||||
roles = []
|
||||
for item_permission in item.actions:
|
||||
permission_action = self.get_action(item_permission.action)
|
||||
if permission_action == action:
|
||||
roles.append(item_permission.role)
|
||||
permission_action = self.get_action(item_permission.action)
|
||||
if permission_action == action:
|
||||
roles.append(item_permission.role)
|
||||
return roles
|
||||
|
||||
def get_valid_roles(self, trans, item, query=None, page=None, page_limit=None, is_library_access=False):
|
||||
|
||||
@@ -325,6 +325,7 @@ class DefaultToolState(object):
|
||||
Keeps track of the state of a users interaction with a tool between
|
||||
requests.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.page = 0
|
||||
self.rerun_remap_job_id = None
|
||||
@@ -2396,12 +2397,12 @@ class MergeCollectionTool(DatabaseOperationTool):
|
||||
identifiers_map = {}
|
||||
for input_num, input_list in enumerate(input_lists):
|
||||
for dce in input_list.collection.elements:
|
||||
element_identifier = dce.element_identifier
|
||||
if element_identifier not in identifiers_map:
|
||||
identifiers_map[element_identifier] = []
|
||||
elif dupl_actions == "fail":
|
||||
raise Exception("Duplicate collection element identifiers found for [%s]" % element_identifier)
|
||||
identifiers_map[element_identifier].append(input_num)
|
||||
element_identifier = dce.element_identifier
|
||||
if element_identifier not in identifiers_map:
|
||||
identifiers_map[element_identifier] = []
|
||||
elif dupl_actions == "fail":
|
||||
raise Exception("Duplicate collection element identifiers found for [%s]" % element_identifier)
|
||||
identifiers_map[element_identifier].append(input_num)
|
||||
|
||||
for copy, input_list in enumerate(input_lists):
|
||||
for dce in input_list.collection.elements:
|
||||
|
||||
@@ -24,6 +24,7 @@ class ToolExecutionCache(object):
|
||||
""" An object mean to cache calculation caused by repeatedly evaluting
|
||||
the same tool by the same user with slightly different parameters.
|
||||
"""
|
||||
|
||||
def __init__(self, trans):
|
||||
self.trans = trans
|
||||
self.current_user_roles = trans.get_current_user_roles()
|
||||
@@ -34,6 +35,7 @@ class ToolAction(object):
|
||||
The actions to be taken when a tool is run (after parameters have
|
||||
been converted and validated).
|
||||
"""
|
||||
|
||||
def execute(self, tool, trans, incoming={}, set_output_hid=True):
|
||||
raise TypeError("Abstract method")
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class DependencyManager(object):
|
||||
and should each contain a file 'env.sh' which can be sourced to make the
|
||||
dependency available in the current shell environment.
|
||||
"""
|
||||
|
||||
def __init__(self, default_base_path, conf_file=None, app_config={}):
|
||||
"""
|
||||
Create a new dependency manager looking for packages under the paths listed
|
||||
|
||||
@@ -547,7 +547,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
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class QuaySearch():
|
||||
"""
|
||||
Tool to search within a quay organization for a given software name.
|
||||
"""
|
||||
|
||||
def __init__(self, organization):
|
||||
self.index = None
|
||||
self.organization = organization
|
||||
|
||||
@@ -20,6 +20,7 @@ class ToolRequirement(object):
|
||||
run (for example, a program, package, or library). Requirements can
|
||||
optionally assert a specific version.
|
||||
"""
|
||||
|
||||
def __init__(self, name=None, type=None, version=None, specs=[]):
|
||||
self.name = name
|
||||
self.type = type
|
||||
@@ -94,6 +95,7 @@ class ToolRequirements(object):
|
||||
"""
|
||||
Represents all requirements (packages, env vars) needed to run a tool.
|
||||
"""
|
||||
|
||||
def __init__(self, tool_requirements=None):
|
||||
if tool_requirements:
|
||||
if not isinstance(tool_requirements, list):
|
||||
|
||||
@@ -80,6 +80,7 @@ class DirectoryModuleChecker(object):
|
||||
|
||||
Searches the paths listed in modulepath to for a file or directory matching the module name.
|
||||
If the version=True, searches for files named module/version."""
|
||||
|
||||
def __init__(self, module_dependency_resolver, modulepath, prefetch):
|
||||
self.module_dependency_resolver = module_dependency_resolver
|
||||
self.directories = modulepath.split(pathsep)
|
||||
@@ -109,6 +110,7 @@ class AvailModuleChecker(object):
|
||||
module names into module and version on '/' and discarding a postfix matching default_indicator
|
||||
(by default '(default)'. Matching is done using the module and
|
||||
(if version=True) the module version."""
|
||||
|
||||
def __init__(self, module_dependency_resolver, modulepath, prefetch, default_indicator=DEFAULT_INDICATOR):
|
||||
self.module_dependency_resolver = module_dependency_resolver
|
||||
self.modulepath = modulepath
|
||||
|
||||
@@ -22,6 +22,7 @@ class JobImportHistoryArchiveWrapper(object, UsesAnnotations):
|
||||
Class provides support for performing jobs that import a history from
|
||||
an archive.
|
||||
"""
|
||||
|
||||
def __init__(self, app, job_id):
|
||||
self.app = app
|
||||
self.job_id = job_id
|
||||
@@ -217,8 +218,8 @@ class JobImportHistoryArchiveWrapper(object, UsesAnnotations):
|
||||
""" Hook to 'decode' an HDA; method uses history and HID to get the HDA represented by
|
||||
the encoded object. This only works because HDAs are created above. """
|
||||
if obj_dct.get('__HistoryDatasetAssociation__', False):
|
||||
return self.sa_session.query(model.HistoryDatasetAssociation) \
|
||||
.filter_by(history=new_history, hid=obj_dct['hid']).first()
|
||||
return self.sa_session.query(model.HistoryDatasetAssociation) \
|
||||
.filter_by(history=new_history, hid=obj_dct['hid']).first()
|
||||
return obj_dct
|
||||
jobs_attrs = loads(jobs_attr_str, object_hook=as_hda)
|
||||
|
||||
@@ -249,6 +250,7 @@ class JobImportHistoryArchiveWrapper(object, UsesAnnotations):
|
||||
|
||||
class HistoryDatasetAssociationIDEncoder(json.JSONEncoder):
|
||||
""" Custom JSONEncoder for a HistoryDatasetAssociation that encodes an HDA as its ID. """
|
||||
|
||||
def default(self, obj):
|
||||
""" Encode an HDA, default encoding for everything else. """
|
||||
if isinstance(obj, model.HistoryDatasetAssociation):
|
||||
@@ -309,6 +311,7 @@ class JobExportHistoryArchiveWrapper(object, UsesAnnotations):
|
||||
Class provides support for performing jobs that export a history to an
|
||||
archive.
|
||||
"""
|
||||
|
||||
def __init__(self, job_id):
|
||||
self.job_id = job_id
|
||||
|
||||
@@ -358,6 +361,7 @@ class JobExportHistoryArchiveWrapper(object, UsesAnnotations):
|
||||
|
||||
class HistoryDatasetAssociationEncoder(json.JSONEncoder):
|
||||
""" Custom JSONEncoder for a HistoryDatasetAssociation. """
|
||||
|
||||
def default(self, obj):
|
||||
""" Encode an HDA, default encoding for everything else. """
|
||||
if isinstance(obj, trans.app.model.HistoryDatasetAssociation):
|
||||
|
||||
@@ -251,6 +251,7 @@ class TextToolParameter(ToolParameter):
|
||||
>>> 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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 <stdio> element's <exit_code> 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")
|
||||
|
||||
@@ -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]
|
||||
|
||||
+14
-14
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -15,6 +15,7 @@ class OpenObject(dict):
|
||||
KeyError).
|
||||
JSON-serializable.
|
||||
"""
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key not in self:
|
||||
return None
|
||||
|
||||
@@ -49,6 +49,7 @@ class TextField(BaseField):
|
||||
>>> print TextField( "bins", size=4, value="default" ).get_html()
|
||||
<input type="text" name="bins" size="4" value="default">
|
||||
"""
|
||||
|
||||
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()
|
||||
<input type="password" name="bins" size="4" value="default">
|
||||
"""
|
||||
|
||||
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()
|
||||
<input type="hidden" name="foo" value="100">
|
||||
"""
|
||||
|
||||
def __init__(self, name, value=None, **kwds):
|
||||
super(HiddenField, self).__init__(name, value, **kwds)
|
||||
self.name = name
|
||||
@@ -265,6 +268,7 @@ class SelectField(BaseField):
|
||||
<div><input type="checkbox" name="bar" value="3" id="bar|3"><label class="inline" for="bar|3">automatic</label></div>
|
||||
<div><input type="checkbox" name="bar" value="4" id="bar|4" checked='checked'><label class="inline" for="bar|4">bazooty</label></div>
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 '-',
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -787,9 +787,9 @@ class AdminToolshed(AdminGalaxy):
|
||||
message = 'All selected tool dependencies are already installed.'
|
||||
status = 'error'
|
||||
else:
|
||||
message = 'Set the value of your <b>tool_dependency_dir</b> 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 <b>tool_dependency_dir</b> 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 <b>tool_dependency_dir</b> 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 <b>tool_dependency_dir</b> 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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 <item_class>RatingAssociation. """
|
||||
item_rating = self.get_user_item_rating(trans.sa_session, user, item, webapp_model=trans.model)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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."""
|
||||
"""
|
||||
|
||||
+1
@@ -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."""
|
||||
"""
|
||||
|
||||
@@ -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."""
|
||||
"""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+33
-33
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user