mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Remove egg cruft from scripts/
This commit is contained in:
@@ -7,13 +7,6 @@ import os
|
||||
import sys
|
||||
import urllib2
|
||||
|
||||
new_path = [ os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir, 'lib' ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( "pycrypto" )
|
||||
|
||||
from Crypto.Cipher import Blowfish
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
@@ -97,8 +97,6 @@ If the user does not exist, check_galaxy will create it for you.""" % login_file
|
||||
# find/import twill
|
||||
lib_dir = os.path.join( scripts_dir, os.pardir, "lib" )
|
||||
sys.path.insert( 1, lib_dir )
|
||||
from galaxy import eggs
|
||||
eggs.require( "twill" )
|
||||
import twill
|
||||
import twill.commands as tc
|
||||
|
||||
|
||||
@@ -49,11 +49,8 @@ from time import strftime
|
||||
|
||||
from cleanup_datasets import CleanupDatasetsApplication
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require('SQLAlchemy')
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import and_, false
|
||||
eggs.require("Mako")
|
||||
from mako.template import Template
|
||||
|
||||
import galaxy.config
|
||||
|
||||
@@ -10,16 +10,14 @@ from datetime import datetime, timedelta
|
||||
from optparse import OptionParser
|
||||
from time import strftime
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require('SQLAlchemy')
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import and_, false, null, true
|
||||
from sqlalchemy.orm import eagerload
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
import galaxy.config
|
||||
import galaxy.model.mapping
|
||||
from galaxy.exceptions import ObjectNotFound
|
||||
|
||||
@@ -17,10 +17,7 @@ from optparse import OptionParser
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
sys.path.insert(0, os.path.join(galaxy_root, 'lib'))
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require('psycopg2')
|
||||
import psycopg2
|
||||
eggs.require('SQLAlchemy')
|
||||
from sqlalchemy.engine.url import make_url
|
||||
|
||||
import galaxy.config
|
||||
|
||||
@@ -20,11 +20,8 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import galaxy.model.mapping
|
||||
from galaxy import config, model
|
||||
import pkg_resources
|
||||
pkg_resources.require( "SQLAlchemy >= 0.4" )
|
||||
|
||||
def main( ini_file ):
|
||||
sa_session, gconfig = get_sa_session( ini_file )
|
||||
|
||||
@@ -14,12 +14,9 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
# Whoosh is compatible with Python 2.5+ Try to import Whoosh and set flag to indicate whether search is enabled.
|
||||
try:
|
||||
eggs.require( "Whoosh" )
|
||||
|
||||
from whoosh.filedb.filestore import FileStorage
|
||||
from whoosh.fields import Schema, STORED, ID, KEYWORD, TEXT
|
||||
from whoosh.index import Index
|
||||
|
||||
@@ -22,10 +22,6 @@ sys.path = new_path
|
||||
|
||||
from galaxy.model.orm.scripts import get_config
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( "decorator" )
|
||||
eggs.require( "Tempita" )
|
||||
eggs.require( "SQLAlchemy" )
|
||||
|
||||
db_url = get_config( sys.argv )['db_url']
|
||||
|
||||
|
||||
@@ -9,12 +9,6 @@ import os
|
||||
import pwd
|
||||
import sys
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require("drmaa")
|
||||
import drmaa
|
||||
|
||||
|
||||
|
||||
@@ -12,12 +12,6 @@ import os
|
||||
import pwd
|
||||
import sys
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require("drmaa")
|
||||
import drmaa
|
||||
|
||||
DRMAA_jobTemplate_attributes = [ 'args', 'remoteCommand', 'outputPath', 'errorPath', 'nativeSpecification',
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Configure stdout logging
|
||||
|
||||
import glob
|
||||
import HTMLParser
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import urllib
|
||||
import urllib2
|
||||
import zipfile
|
||||
|
||||
log = logging.getLogger()
|
||||
log.setLevel( 10 )
|
||||
log.addHandler( logging.StreamHandler( sys.stdout ) )
|
||||
|
||||
# Fake pkg_resources
|
||||
|
||||
macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
|
||||
darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
|
||||
solarisVersionString = re.compile(r"solaris-(\d)\.(\d+)-(.*)")
|
||||
|
||||
|
||||
def compatible_platforms(provided, required):
|
||||
"""Can code for the `provided` platform run on the `required` platform?
|
||||
|
||||
Returns true if either platform is ``None``, or the platforms are equal.
|
||||
|
||||
XXX Needs compatibility checks for Linux and other unixy OSes.
|
||||
"""
|
||||
if provided is None or required is None or provided == required:
|
||||
return True # easy case
|
||||
|
||||
# Mac OS X special cases
|
||||
reqMac = macosVersionString.match(required)
|
||||
if reqMac:
|
||||
provMac = macosVersionString.match(provided)
|
||||
|
||||
# is this a Mac package?
|
||||
if not provMac:
|
||||
# this is backwards compatibility for packages built before
|
||||
# setuptools 0.6. All packages built after this point will
|
||||
# use the new macosx designation.
|
||||
provDarwin = darwinVersionString.match(provided)
|
||||
if provDarwin:
|
||||
dversion = int(provDarwin.group(1))
|
||||
macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2))
|
||||
if dversion == 7 and macosversion >= "10.3" or \
|
||||
dversion == 8 and macosversion >= "10.4":
|
||||
|
||||
# import warnings
|
||||
# warnings.warn("Mac eggs should be rebuilt to "
|
||||
# "use the macosx designation instead of darwin.",
|
||||
# category=DeprecationWarning)
|
||||
return True
|
||||
return False # egg isn't macosx or legacy darwin
|
||||
|
||||
# are they the same major version and machine type?
|
||||
if provMac.group(1) != reqMac.group(1) or \
|
||||
provMac.group(3) != reqMac.group(3):
|
||||
return False
|
||||
|
||||
# is the required OS major update >= the provided one?
|
||||
if int(provMac.group(2)) > int(reqMac.group(2)):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# Solaris' special cases
|
||||
reqSol = solarisVersionString.match(required)
|
||||
if reqSol:
|
||||
provSol = solarisVersionString.match(provided)
|
||||
if not provSol:
|
||||
return False
|
||||
if provSol.group(1) != reqSol.group(1) or \
|
||||
provSol.group(3) != reqSol.group(3):
|
||||
return False
|
||||
if int(provSol.group(2)) > int(reqSol.group(2)):
|
||||
return False
|
||||
return True
|
||||
|
||||
# XXX Linux and other platforms' special cases should go here
|
||||
return False
|
||||
|
||||
EGG_NAME = re.compile(
|
||||
r"(?P<name>[^-]+)"
|
||||
r"( -(?P<ver>[^-]+) (-py(?P<pyver>[^-]+) (-(?P<plat>.+))? )? )?",
|
||||
re.VERBOSE | re.IGNORECASE
|
||||
).match
|
||||
|
||||
|
||||
class Distribution( object ):
|
||||
def __init__( self, egg_name, project_name, version, py_version, platform ):
|
||||
self._egg_name = egg_name
|
||||
self.project_name = project_name
|
||||
if project_name is not None:
|
||||
self.project_name = project_name.replace( '-', '_' )
|
||||
self.version = version
|
||||
if version is not None:
|
||||
self.version = version.replace( '-', '_' )
|
||||
self.py_version = py_version
|
||||
self.platform = platform
|
||||
self.location = os.path.join( tmpd, egg_name ) + '.egg'
|
||||
|
||||
def egg_name( self ):
|
||||
return self._egg_name
|
||||
|
||||
@classmethod
|
||||
def from_filename( cls, basename ):
|
||||
project_name, version, py_version, platform = [None] * 4
|
||||
basename, ext = os.path.splitext(basename)
|
||||
if ext.lower() == '.egg':
|
||||
match = EGG_NAME( basename )
|
||||
if match:
|
||||
project_name, version, py_version, platform = match.group( 'name', 'ver', 'pyver', 'plat' )
|
||||
return cls( basename, project_name, version, py_version, platform )
|
||||
|
||||
|
||||
class pkg_resources( object ):
|
||||
pass
|
||||
|
||||
pkg_resources.Distribution = Distribution
|
||||
|
||||
# Fake galaxy.eggs
|
||||
|
||||
env = None
|
||||
|
||||
|
||||
def get_env():
|
||||
return None
|
||||
|
||||
|
||||
class URLRetriever( urllib.FancyURLopener ):
|
||||
def http_error_default( *args ):
|
||||
urllib.URLopener.http_error_default( *args )
|
||||
|
||||
|
||||
class Egg( object ):
|
||||
def __init__( self, distribution ):
|
||||
self.url = url + '/' + distribution.project_name.replace( '-', '_' )
|
||||
self.dir = tmpd
|
||||
self.distribution = distribution
|
||||
|
||||
def set_distribution( self ):
|
||||
pass
|
||||
|
||||
def unpack_if_needed( self ):
|
||||
pass
|
||||
|
||||
def remove_doppelgangers( self ):
|
||||
pass
|
||||
|
||||
def fetch( self, requirement ):
|
||||
"""
|
||||
fetch() serves as the install method to pkg_resources.working_set.resolve()
|
||||
"""
|
||||
def find_alternative():
|
||||
"""
|
||||
Some platforms (e.g. Solaris) support eggs compiled on older platforms
|
||||
"""
|
||||
class LinkParser( HTMLParser.HTMLParser ):
|
||||
"""
|
||||
Finds links in what should be an Apache-style directory index
|
||||
"""
|
||||
def __init__( self ):
|
||||
HTMLParser.HTMLParser.__init__( self )
|
||||
self.links = []
|
||||
|
||||
def handle_starttag( self, tag, attrs ):
|
||||
if tag == 'a' and 'href' in dict( attrs ):
|
||||
self.links.append( dict( attrs )['href'] )
|
||||
parser = LinkParser()
|
||||
try:
|
||||
parser.feed( urllib2.urlopen( self.url + '/' ).read() )
|
||||
except urllib2.HTTPError, e:
|
||||
if e.code == 404:
|
||||
return None
|
||||
parser.close()
|
||||
for link in parser.links:
|
||||
file = urllib.unquote( link ).rsplit( '/', 1 )[-1]
|
||||
tmp_dist = pkg_resources.Distribution.from_filename( file )
|
||||
if tmp_dist.platform is not None and \
|
||||
self.distribution.project_name == tmp_dist.project_name and \
|
||||
self.distribution.version == tmp_dist.version and \
|
||||
self.distribution.py_version == tmp_dist.py_version and \
|
||||
compatible_platforms( tmp_dist.platform, self.distribution.platform ):
|
||||
return file
|
||||
return None
|
||||
if self.url is None:
|
||||
return None
|
||||
alternative = None
|
||||
try:
|
||||
url = self.url + '/' + self.distribution.egg_name() + '.egg'
|
||||
URLRetriever().retrieve( url, self.distribution.location )
|
||||
log.debug( "Fetched %s" % url )
|
||||
except IOError, e:
|
||||
if e[1] == 404 and self.distribution.platform != py:
|
||||
alternative = find_alternative()
|
||||
if alternative is None:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
if alternative is not None:
|
||||
try:
|
||||
url = '/'.join( ( self.url, alternative ) )
|
||||
URLRetriever().retrieve( url, os.path.join( self.dir, alternative ) )
|
||||
log.debug( "Fetched %s" % url )
|
||||
except IOError, e:
|
||||
return None
|
||||
self.platform = alternative.split( '-', 2 )[-1].rsplit( '.egg', 1 )[0]
|
||||
self.set_distribution()
|
||||
self.unpack_if_needed()
|
||||
self.remove_doppelgangers()
|
||||
global env
|
||||
env = get_env() # reset the global Environment object now that we've obtained a new egg
|
||||
return self.distribution
|
||||
|
||||
|
||||
def create_zip():
|
||||
fname = 'galaxy_eggs-%s.zip' % platform
|
||||
z = zipfile.ZipFile( fname, 'w', zipfile.ZIP_STORED )
|
||||
for egg in glob.glob( os.path.join( tmpd, '*.egg' ) ):
|
||||
z.write( egg, 'eggs/' + os.path.basename( egg ) )
|
||||
z.close()
|
||||
print 'Egg package is in %s' % fname
|
||||
print "To install the eggs, please copy this file to your Galaxy installation's root"
|
||||
print "directory and unpack with:"
|
||||
print " unzip %s" % fname
|
||||
|
||||
|
||||
def clean():
|
||||
shutil.rmtree( tmpd )
|
||||
|
||||
import tempfile
|
||||
tmpd = tempfile.mkdtemp()
|
||||
|
||||
failures = []
|
||||
platform = None
|
||||
py = None
|
||||
url = None
|
||||
|
||||
# Automatically generated egg definitions follow
|
||||
@@ -16,20 +16,8 @@ sys.path = new_path
|
||||
from base.test_logging import logging_config_file
|
||||
from base.tool_shed_util import parse_tool_panel_config
|
||||
|
||||
from galaxy import eggs
|
||||
from galaxy.util.properties import load_app_properties
|
||||
|
||||
eggs.require( "nose" )
|
||||
eggs.require( "NoseHTML" )
|
||||
eggs.require( "NoseTestDiff" )
|
||||
eggs.require( "Paste" )
|
||||
eggs.require( "PasteDeploy" )
|
||||
eggs.require( "Cheetah" )
|
||||
|
||||
# this should not be required, but it is under certain conditions, thanks to this bug:
|
||||
# http://code.google.com/p/python-nose/issues/detail?id=284
|
||||
eggs.require( "pysqlite" )
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import time
|
||||
|
||||
@@ -8,15 +8,6 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
eggs.require( "decorator" )
|
||||
eggs.require( "Tempita" )
|
||||
eggs.require( "SQLAlchemy" )
|
||||
eggs.require( "six" ) # Required by sqlalchemy-migrate
|
||||
eggs.require( "sqlparse" ) # Required by sqlalchemy-migrate
|
||||
eggs.require( "sqlalchemy_migrate" )
|
||||
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
from galaxy.model.orm.scripts import get_config
|
||||
|
||||
@@ -6,19 +6,9 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
eggs.require( "SQLAlchemy" )
|
||||
eggs.require( "decorator" )
|
||||
eggs.require( "Tempita " )
|
||||
eggs.require( "six" ) # Required by sqlalchemy-migrate
|
||||
eggs.require( "sqlparse" ) # Required by sqlalchemy-migrate
|
||||
eggs.require( "sqlalchemy-migrate" )
|
||||
|
||||
from migrate.versioning.shell import main
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
from galaxy.model.orm.scripts import require_dialect_egg
|
||||
from galaxy.model.orm.scripts import read_config_file_arg
|
||||
from galaxy.util.properties import load_app_properties
|
||||
|
||||
@@ -46,6 +36,4 @@ elif "database_file" in properties:
|
||||
else:
|
||||
db_url = "sqlite:///./database/universe.sqlite?isolation_level=IMMEDIATE"
|
||||
|
||||
require_dialect_egg( db_url )
|
||||
|
||||
main( repository=repo, url=db_url )
|
||||
|
||||
@@ -4,14 +4,6 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( 'nose' )
|
||||
eggs.require( 'NoseHTML' )
|
||||
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
@@ -4,13 +4,10 @@ Fetch jobs using gops_intersect, gops_merge, gops_subtract, gops_complement, gop
|
||||
wherein the second dataset doesn't have chr, start and end in standard columns 1, 2 and 3.
|
||||
"""
|
||||
|
||||
from galaxy import eggs
|
||||
import sys, os, ConfigParser, tempfile
|
||||
import galaxy.app
|
||||
import galaxy.model.mapping
|
||||
import pkg_resources
|
||||
|
||||
pkg_resources.require( "SQLAlchemy >= 0.4" )
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
@@ -3,13 +3,10 @@
|
||||
Fetch gops_join wherein the use specified minimum coverage is not 1.
|
||||
"""
|
||||
|
||||
from galaxy import eggs
|
||||
import sys, os, ConfigParser, tempfile
|
||||
import galaxy.app
|
||||
import galaxy.model.mapping
|
||||
import pkg_resources
|
||||
|
||||
pkg_resources.require( "SQLAlchemy >= 0.4" )
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
assert sys.version_info[:2] >= ( 2, 4 )
|
||||
|
||||
@@ -19,14 +19,9 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
if 'LOG_TEMPFILES' in os.environ:
|
||||
from log_tempfile import TempFile
|
||||
_log_tempfile = TempFile()
|
||||
|
||||
eggs.require( "Paste" )
|
||||
eggs.require( "PasteDeploy" )
|
||||
|
||||
from galaxy.util.pastescript import serve
|
||||
serve.run()
|
||||
|
||||
@@ -3,21 +3,12 @@ from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
|
||||
new_path = [ os.path.join( os.path.dirname(__file__), os.pardir, "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
try:
|
||||
from argparse import ArgumentParser
|
||||
except ImportError:
|
||||
ArgumentParser = None
|
||||
import re
|
||||
|
||||
try:
|
||||
from galaxy import eggs
|
||||
eggs.require("numpy")
|
||||
except ImportError:
|
||||
pass
|
||||
import numpy
|
||||
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ from galaxy.webapps.tool_shed import config
|
||||
from galaxy.webapps.tool_shed import model
|
||||
from galaxy.tools.loader_directory import load_tool_elements_from_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( "SQLAlchemy" )
|
||||
eggs.require( "Whoosh" )
|
||||
from whoosh.filedb.filestore import FileStorage
|
||||
from whoosh.fields import Schema, STORED, TEXT
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require( "psycopg2" )
|
||||
import psycopg2
|
||||
|
||||
import galaxy.webapps.tool_shed.app
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#Dan Blankenberg
|
||||
#This script checks maf_index.loc file for inconsistencies between what is listed as available and what is really available.
|
||||
#Make sure that required dependencies (e.g. galaxy_root/lib and galaxy_root/eggs) are included in your PYTHONPATH
|
||||
from galaxy import eggs
|
||||
import pkg_resources; pkg_resources.require( "bx-python" )
|
||||
import bx.align.maf
|
||||
from galaxy.tools.util import maf_utilities
|
||||
import sys
|
||||
|
||||
+1
-8
@@ -9,24 +9,18 @@ import os, sys, optparse, ConfigParser, socket, SocketServer, threading, logging
|
||||
galaxy_root = os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir ) )
|
||||
sys.path.insert( 0, os.path.abspath( os.path.join( galaxy_root, 'lib' ) ) )
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
try:
|
||||
import pexpect
|
||||
except ImportError:
|
||||
pexpect = None
|
||||
|
||||
eggs.require( "SQLAlchemy >= 0.4" )
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import *
|
||||
from galaxy.model.mapping import load_egg_for_url
|
||||
from daemon import DaemonContext
|
||||
|
||||
import galaxy.model
|
||||
from galaxy.util import json, bunch
|
||||
|
||||
eggs.require( 'python_daemon' )
|
||||
from daemon import DaemonContext
|
||||
|
||||
PEXPECT_IMPORT_MESSAGE = ('The Python pexpect package is required to use this '
|
||||
'feature, please install it')
|
||||
@@ -88,7 +82,6 @@ class GalaxyApp( object ):
|
||||
dburl = self.config.get( 'app:main', 'database_connection' )
|
||||
except ConfigParser.NoOptionError:
|
||||
dburl = default_dburl
|
||||
load_egg_for_url( dburl )
|
||||
engine = create_engine( dburl )
|
||||
metadata = MetaData( engine )
|
||||
self.sa_session = scoped_session( sessionmaker( bind=engine, autoflush=False, autocommit=True ) )
|
||||
|
||||
@@ -6,8 +6,6 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require('SQLAlchemy')
|
||||
from sqlalchemy import create_engine, MetaData
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
@@ -41,25 +39,6 @@ def create_database( config_file ):
|
||||
exit(1)
|
||||
|
||||
'''Initialize the database file.'''
|
||||
dialect_to_egg = {
|
||||
"sqlite" : "pysqlite>=2",
|
||||
"postgres" : "psycopg2",
|
||||
"postgresql" : "psycopg2",
|
||||
"mysql" : "MySQL_python"
|
||||
}
|
||||
dialect = ( database_connection.split( ':', 1 ) )[0]
|
||||
try:
|
||||
egg = dialect_to_egg[ dialect ]
|
||||
try:
|
||||
eggs.require( egg )
|
||||
print( "%s egg successfully loaded for %s dialect" % ( egg, dialect ) )
|
||||
except:
|
||||
# If the module is in the path elsewhere (i.e. non-egg), it'll still load.
|
||||
print( "%s egg not found, but an attempt will be made to use %s anyway" % ( egg, dialect ) )
|
||||
except KeyError:
|
||||
# Let this go, it could possibly work with db's we don't support.
|
||||
print( "database_connection contains an unknown SQLAlchemy database dialect: %s" % dialect )
|
||||
|
||||
# Initialize the database connection.
|
||||
engine = create_engine( database_connection )
|
||||
MetaData( bind=engine )
|
||||
|
||||
Reference in New Issue
Block a user