Deprecated code corrections for supporting Python 2.6. Many of the Python 2.6 eggs are still throwing DeprecationWarning messages, so some things still won't work. Eggs for 2.6 need to be re-scrambled after corrections are made.

This commit is contained in:
Greg Von Kuster
2009-08-14 15:37:31 -04:00
parent 1b460feda2
commit d0d7875192
26 changed files with 120 additions and 63 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ Coverage datatypes
import pkg_resources
pkg_resources.require( "bx-python" )
import logging, os, sys, time, sets, tempfile, shutil
import logging, os, sys, time, tempfile, shutil
import data
from galaxy import util
from galaxy.datatypes.sniff import *
+1 -1
View File
@@ -1,4 +1,4 @@
import logging, os, sys, time, sets, tempfile
import logging, os, sys, time, tempfile
from galaxy import util
from galaxy.util.odict import odict
from galaxy.util.bunch import Bunch
+1 -1
View File
@@ -12,7 +12,7 @@ ross lazarus for rgenetics
august 20 2007
"""
import logging, os, sys, time, sets, tempfile, shutil
import logging, os, sys, time, tempfile, shutil
import data
from galaxy import util
from cgi import escape
+1 -1
View File
@@ -5,7 +5,7 @@ Interval datatypes
import pkg_resources
pkg_resources.require( "bx-python" )
import logging, os, sys, time, sets, tempfile, shutil
import logging, os, sys, time, tempfile, shutil
import data
from galaxy import util
from galaxy.datatypes.sniff import *
+14 -6
View File
@@ -5,8 +5,7 @@ Naming: try to use class names that have a distinct plural form so that
the relationship cardinalities are obvious (e.g. prefer Dataset to Data)
"""
import os.path, os, errno
import sha
import os.path, os, errno, sys
import galaxy.datatypes
from galaxy.util.bunch import Bunch
from galaxy import util
@@ -14,8 +13,11 @@ import tempfile
import galaxy.datatypes.registry
from galaxy.datatypes.metadata import MetadataCollection
from galaxy.security import RBACAgent, get_permitted_actions
using_24 = sys.version_info[:2] < ( 2, 5 )
if using_24:
import sha
else:
import hashlib
import logging
log = logging.getLogger( __name__ )
@@ -40,10 +42,16 @@ class User( object ):
def set_password_cleartext( self, cleartext ):
"""Set 'self.password' to the digest of 'cleartext'."""
self.password = sha.new( cleartext ).hexdigest()
if using_24:
self.password = sha.new( cleartext ).hexdigest()
else:
self.password = hashlib.sha1( cleartext ).hexdigest()
def check_password( self, cleartext ):
"""Check if 'cleartext' matches 'self.password' when hashed."""
return self.password == sha.new( cleartext ).hexdigest()
if using_24:
return self.password == sha.new( cleartext ).hexdigest()
else:
return self.password == hashlib.sha1( cleartext ).hexdigest()
def all_roles( self ):
roles = [ ura.role for ura in self.roles ]
for group in [ uga.group for uga in self.groups ]:
+15 -6
View File
@@ -1,15 +1,13 @@
"""
Classes encapsulating galaxy tools and tool configuration.
"""
import pkg_resources;
pkg_resources.require( "simplejson" )
import logging, os, string, sys, tempfile, glob, shutil
import simplejson
import sha, hmac, binascii
import hmac, binascii
from UserDict import DictMixin
from galaxy.util.odict import odict
from galaxy.util.bunch import Bunch
@@ -27,6 +25,12 @@ from galaxy.util.none_like import NoneDataset
from galaxy.datatypes import sniff
from cgi import FieldStorage
using_24 = sys.version_info[:2] < ( 2, 5 )
if using_24:
import sha
else:
import hashlib
log = logging.getLogger( __name__ )
class ToolNotFoundException( Exception ):
@@ -211,7 +215,10 @@ class DefaultToolState( object ):
value["__page__"] = self.page
value = simplejson.dumps( value )
# Make it secure
a = hmac.new( app.config.tool_secret, value, sha ).hexdigest()
if using_24:
a = hmac.new( app.config.tool_secret, value, sha ).hexdigest()
else:
a = hmac.new( app.config.tool_secret, value, hashlib.sha1 ).hexdigest()
b = binascii.hexlify( value )
return "%s:%s" % ( a, b )
def decode( self, value, tool, app ):
@@ -221,7 +228,10 @@ class DefaultToolState( object ):
# Extract and verify hash
a, b = value.split( ":" )
value = binascii.unhexlify( b )
test = hmac.new( app.config.tool_secret, value, sha ).hexdigest()
if using_24:
test = hmac.new( app.config.tool_secret, value, sha ).hexdigest()
else:
test = hmac.new( app.config.tool_secret, value, hashlib.sha1 ).hexdigest()
assert a == test
# Restore from string
values = json_fix( simplejson.loads( value ) )
@@ -453,7 +463,6 @@ class Tool:
self.tests = None
# Determine if this tool can be used in workflows
self.is_workflow_compatible = self.check_workflow_compatible()
def parse_inputs( self, root ):
"""
+12 -7
View File
@@ -1,9 +1,14 @@
import shutil, StringIO, operator, urllib, gzip, tempfile, sets, string, sys
import shutil, StringIO, operator, urllib, gzip, tempfile, string, sys
from datetime import datetime, timedelta
from galaxy import util, datatypes
from galaxy.web.base.controller import *
from galaxy.model.orm import *
from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
# Older py compatibility
try:
set()
except:
from sets import Set as set
import logging
log = logging.getLogger( __name__ )
@@ -1236,16 +1241,16 @@ class Admin( BaseController ):
if v == trans.app.security_agent.permitted_actions.DATASET_ACCESS:
if len( in_roles ) > 1:
# Get the set of all users that are being associated with the dataset
in_roles_set = sets.Set()
in_roles_set = set()
for role in in_roles:
in_roles_set.add( role )
users_set = sets.Set()
users_set = set()
for role in in_roles:
for ura in role.users:
users_set.add( ura.user )
# Make sure that at least 1 user has every role being associated with the dataset
for user in users_set:
user_roles_set = sets.Set()
user_roles_set = set()
for ura in user.roles:
user_roles_set.add( ura.role )
if in_roles_set.issubset( user_roles_set ):
@@ -1421,16 +1426,16 @@ class Admin( BaseController ):
if v == trans.app.security_agent.permitted_actions.DATASET_ACCESS:
if len( in_roles ) > 1:
# Get the set of all users that are being associated with the dataset
in_roles_set = sets.Set()
in_roles_set = set()
for role in in_roles:
in_roles_set.add( role )
users_set = sets.Set()
users_set = set()
for role in in_roles:
for ura in role.users:
users_set.add( ura.user )
# Make sure that at least 1 user has every role being associated with the dataset
for user in users_set:
user_roles_set = sets.Set()
user_roles_set = set()
for ura in user.roles:
user_roles_set.add( ura.role )
if in_roles_set.issubset( user_roles_set ):
+15 -4
View File
@@ -6,8 +6,13 @@ from galaxy.web.base.controller import *
from galaxy import jobs, util, datatypes, web
import logging, urllib
import sha, hmac
import logging, urllib, hmac, sys
using_24 = sys.version_info[:2] < ( 2, 5 )
if using_24:
import sha
else:
import hashlib
log = logging.getLogger( __name__ )
@@ -58,7 +63,10 @@ class ASync( BaseController ):
return "Data %s does not exist or has already been deleted" % data_id
if STATUS == 'OK':
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), sha ).hexdigest()
if using_24:
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), sha ).hexdigest()
else:
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), hashlib.sha1 ).hexdigest()
if key != data_secret:
return "You do not have permission to alter data %s." % data_id
# push the job into the queue
@@ -116,7 +124,10 @@ class ASync( BaseController ):
trans.log_event( "Added dataset %d to history %d" %(data.id, trans.history.id ), tool_id=tool_id )
try:
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), sha ).hexdigest()
if using_24:
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), sha ).hexdigest()
else:
key = hmac.new( trans.app.config.tool_secret, "%d:%d" % ( data.id, data.history_id), hashlib.sha1 ).hexdigest()
galaxy_url = trans.request.base + '/async/%s/%s/%s' % ( tool_id, data.id, key )
params.update( { 'GALAXY_URL' :galaxy_url } )
params.update( { 'data_id' :data.id } )
+1 -1
View File
@@ -1,4 +1,4 @@
import logging, os, sets, string, shutil, re, socket, mimetypes, smtplib, urllib
import logging, os, string, shutil, re, socket, mimetypes, smtplib, urllib
from galaxy.web.base.controller import *
from galaxy import util, datatypes, jobs, web, model
+11 -4
View File
@@ -1,12 +1,16 @@
import time, glob, os
import time, glob, os, sys
from itertools import cycle
import sha
from mako import exceptions
from mako.template import Template
from mako.lookup import TemplateLookup
from galaxy.web.base.controller import *
using_24 = sys.version_info[:2] < ( 2, 5 )
if using_24:
import sha
else:
import hashlib
try:
import pkg_resources
pkg_resources.require("GeneTrack")
@@ -265,7 +269,10 @@ class WebRoot(BaseController):
tmpl_name, track_maker = conf.PLOT_MAPPER[param.plot]
# check against a hash, display an image that already exists if it was previously created.
hash = sha.new()
if using_24:
hash = sha.new()
else:
hash = hashlib.sha1()
hash.update(str(dataset_id))
for key in sorted(kwds.keys()):
hash.update(str(kwds[key]))
+1 -2
View File
@@ -1,7 +1,7 @@
"""
Contains the main interface in the Universe class
"""
import logging, os, sets, string, shutil, urllib, re, socket
import logging, os, string, shutil, urllib, re, socket
from cgi import escape, FieldStorage
from galaxy import util, datatypes, jobs, web, util
from galaxy.web.base.controller import *
@@ -60,7 +60,6 @@ class RootController( BaseController ):
trans.response.set_content_type('text/xml')
return trans.fill_template_mako( "root/history_as_xml.mako", history=history, show_deleted=util.string_as_bool( show_deleted ) )
else:
template = "root/history.mako"
show_deleted = util.string_as_bool( show_deleted )
query = trans.sa_session.query( model.HistoryDatasetAssociation ) \
.filter( model.HistoryDatasetAssociation.history == history ) \
+1 -6
View File
@@ -117,7 +117,6 @@ class ToolRunner( BaseController ):
tool_state_string = util.object_to_string(state.encode(tool, trans.app))
# Setup context for template
history = trans.get_history()
template = "tool_form.mako"
vars = dict( tool_state=state, errors = {} )
# Is the "add frame" stuff neccesary here?
add_frame = AddFrameData()
@@ -125,17 +124,13 @@ class ToolRunner( BaseController ):
if from_noframe is not None:
add_frame.wiki_url = trans.app.config.wiki_url
add_frame.from_noframe = True
return trans.fill_template( template, history=history, toolbox=toolbox, tool=tool, util=util, add_frame=add_frame, **vars )
return trans.fill_template( "tool_form.mako", history=history, toolbox=toolbox, tool=tool, util=util, add_frame=add_frame, **vars )
@web.expose
def redirect( self, trans, redirect_url=None, **kwd ):
if not redirect_url:
return trans.show_error_message( "Required URL for redirection missing" )
trans.log_event( "Redirecting to: %s" % redirect_url )
return trans.fill_template( 'root/redirect.mako', redirect_url=redirect_url )
@web.json
def upload_async_create( self, trans, tool_id=None, **kwd ):
"""
+3 -3
View File
@@ -93,8 +93,8 @@ class MessageException( Exception ):
"""
Exception to make throwing errors from deep in controllers easier
"""
def __init__( self, message, type="info" ):
self.message = message
def __init__( self, err_msg, type="info" ):
self.err_msg = err_msg
self.type = type
def error( message ):
@@ -117,7 +117,7 @@ class WebApplication( base.WebApplication ):
self.security = galaxy_app.security
def handle_controller_exception( self, e, trans, **kwargs ):
if isinstance( e, MessageException ):
return trans.show_message( e.message, e.type )
return trans.show_message( e.err_msg, e.type )
def make_body_iterable( self, trans, body ):
if isinstance( body, FormBuilder ):
body = trans.show_form( body )
@@ -1,8 +1,8 @@
import sys, os, operator, sets, string, shutil, re, socket, urllib
import sys, os, operator, string, shutil, re, socket, urllib, time
from galaxy import web
from cgi import escape, FieldStorage
from galaxy.webapps.reports.base.controller import *
import logging, sets, time
import logging
log = logging.getLogger( __name__ )
class Report( BaseController ):
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python
from Bio import GenBank
import sys, os, sets, textwrap
import sys, os, textwrap
assert sys.version_info[:2] >= ( 2, 4 )
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python
import urllib
import sys, os, sets
import sys, os
assert sys.version_info[:2] >= ( 2, 4 )
+1 -1
View File
@@ -9,7 +9,7 @@ usage: %prog input out_file size direction region
-o, --off=N: Offset
"""
import sys, sets, re, os
import sys, re, os
from galaxy import eggs
import pkg_resources; pkg_resources.require( "bx-python" )
from bx.cookbook import doc_optparse
+8 -3
View File
@@ -1,8 +1,13 @@
# runs after the job (and after the default post-filter)
import sets, os
import os
from galaxy import eggs
from galaxy import jobs
from galaxy.tools.parameters import DataToolParameter
# Older py compatibility
try:
set()
except:
from sets import Set as set
#def exec_before_process(app, inp_data, out_data, param_dict, tool=None):
# """Sets the name of the data"""
@@ -11,8 +16,8 @@ from galaxy.tools.parameters import DataToolParameter
# raise Exception, '<p><font color="yellow">Both Queries must be from the same genome build</font></p>'
def validate_input( trans, error_map, param_values, page_param_map ):
dbkeys = sets.Set()
data_param_names = sets.Set()
dbkeys = set()
data_param_names = set()
data_params = 0
for name, param in page_param_map.iteritems():
if isinstance( param, DataToolParameter ):
+7 -3
View File
@@ -5,13 +5,17 @@
Subtract an entire query from another query
usage: %prog in_file_1 in_file_2 begin_col end_col output
"""
import sys, sets, re
import sys, re
from galaxy import eggs
import pkg_resources; pkg_resources.require( "bx-python" )
from bx.cookbook import doc_optparse
# Older py compatibility
try:
set()
except:
from sets import Set as set
assert sys.version_info[:2] >= ( 2, 4 )
def get_lines(fname, begin_col='', end_col=''):
+1 -1
View File
@@ -7,7 +7,7 @@ usage: %prog input size out_file
-l, --cols=N,N,N,N: Columns for chrom, start, end, strand in file
"""
import sys, sets, re, os
import sys, re, os
from galaxy import eggs
import pkg_resources; pkg_resources.require( "bx-python" )
+1 -1
View File
@@ -2,7 +2,7 @@
# This tool takes a tab-delimited textfile as input and creates another column in the file which is the result of
# a computation performed on every row in the original file. The tool will skip over invalid lines within the file,
# informing the user about the number of lines skipped.
import sys, sets, re, os.path
import sys, re, os.path
from galaxy import eggs
from galaxy.tools import validation
from galaxy.datatypes import metadata
+7 -2
View File
@@ -2,8 +2,13 @@
# This tool takes a tab-delimited text file as input and creates filters on columns based on certain properties.
# The tool will skip over invalid lines within the file, informing the user about the number of lines skipped.
import sys, sets, re, os.path
import sys, re, os.path
from galaxy import eggs
# Older py compatibility
try:
set()
except:
from sets import Set as set
assert sys.version_info[:2] >= ( 2, 4 )
@@ -13,7 +18,7 @@ def get_operands( filter_condition ):
for item in items_to_strip:
if filter_condition.find( item ) >= 0:
filter_condition = filter_condition.replace( item, ' ' )
operands = sets.Set( filter_condition.split( ' ' ) )
operands = set( filter_condition.split( ' ' ) )
return operands
def stop_err( msg ):
+1 -1
View File
@@ -3,7 +3,7 @@
"""
This tool provides the SQL "group by" functionality.
"""
import sys, string, re, commands, tempfile, random, sets
import sys, string, re, commands, tempfile, random
from rpy import *
def stop_err(msg):
+7 -2
View File
@@ -1,7 +1,12 @@
#!/usr/bin/python
import sys, sets, re, tempfile
import sys, re, tempfile
from rpy import *
# Older py compatibility
try:
set()
except:
from sets import Set as set
assert sys.version_info[:2] >= ( 2, 4 )
@@ -33,7 +38,7 @@ def main():
for word in re.compile( '[a-zA-Z]+' ).findall( expression ):
if word and not word in math_allowed:
stop_err( "Invalid expression '%s': term '%s' is not recognized or allowed" %( expression, word ) )
symbols = sets.Set()
symbols = set()
for symbol in re.compile( '[^a-z0-9\s]+' ).findall( expression ):
if symbol and not symbol in ops_allowed:
stop_err( "Invalid expression '%s': operator '%s' is not recognized or allowed" % ( expression, symbol ) )
@@ -1,6 +1,10 @@
# runs after the job (and after the default post-filter)
from sets import Set as set
# Older py compatibility
try:
set()
except:
from sets import Set as set
def validate_input( trans, error_map, param_values, page_param_map ):
dbkeys = set()
+1 -1
View File
@@ -1,4 +1,4 @@
import sets, os
import os
from galaxy import eggs
from galaxy import jobs
from galaxy.tools.parameters import DataToolParameter