mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Use __file__ when adding paths to sys.path instead of os.getcwd() .
Also insert additional paths in position 1 unless strictly necessary.
This commit is contained in:
+4
-2
@@ -11,12 +11,14 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os, datetime
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
####### REQUIRED GALAXY INCLUDES
|
||||
|
||||
sys.path.append(os.path.join(os.getcwd(), '../../lib'))
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'lib')))
|
||||
|
||||
#######
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ REQUIRES_DAEMONIZE_MESSAGE = "Attempted to use Galaxy in daemon mode, but daemon
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
GALAXY_ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
GALAXY_ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
GALAXY_LIB_DIR = os.path.join(GALAXY_ROOT_DIR, "lib")
|
||||
DEFAULT_INI_APP = "main"
|
||||
DEFAULT_INIS = ["config/galaxy.ini", "universe_wsgi.ini", "config/galaxy.ini.sample"]
|
||||
|
||||
@@ -11,28 +11,30 @@ set to the path of the dataset on which metadata is being set
|
||||
constructed automatically).
|
||||
"""
|
||||
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
import cPickle
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
# insert *this* galaxy before all others on sys.path
|
||||
sys.path.insert( 1, os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir ) ) )
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require('SQLAlchemy')
|
||||
from sqlalchemy.orm import clear_mappers
|
||||
|
||||
import galaxy.model.mapping # need to load this before we unpickle, in order to setup properties assigned by the mappers
|
||||
from galaxy.model.custom_types import total_size
|
||||
from galaxy.util import stringify_dictionary_keys
|
||||
|
||||
# ensure supported version
|
||||
assert sys.version_info[:2] >= ( 2, 6 ) and sys.version_info[:2] <= ( 2, 7 ), 'Python version must be 2.6 or 2.7, this is: %s' % sys.version
|
||||
|
||||
# insert *this* galaxy before all others on sys.path
|
||||
new_path = os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir ) )
|
||||
sys.path.insert( 0, new_path )
|
||||
|
||||
import galaxy.model.mapping # need to load this before we unpickle, in order to setup properties assigned by the mappers
|
||||
from galaxy.model.custom_types import total_size
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
galaxy.model.Job() # this looks REAL stupid, but it is REQUIRED in order for SA to insert parameters into the classes defined by the mappers --> it appears that instantiating ANY mapper'ed class would suffice here
|
||||
from galaxy.util import stringify_dictionary_keys
|
||||
from sqlalchemy.orm import clear_mappers
|
||||
|
||||
|
||||
def set_meta_with_tool_provided( dataset_instance, file_dict, set_meta_kwds, datatypes_registry ):
|
||||
|
||||
@@ -2,14 +2,8 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
cwd = os.getcwd()
|
||||
if cwd not in sys.path:
|
||||
sys.path.append( cwd )
|
||||
|
||||
new_path = [ os.path.join( cwd, "lib" ) ]
|
||||
if new_path not in sys.path:
|
||||
new_path.extend( sys.path )
|
||||
sys.path = new_path
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
|
||||
sys.path.insert(1, os.path.join(galaxy_root, 'lib'))
|
||||
|
||||
from galaxy.util import parse_xml
|
||||
|
||||
@@ -70,7 +64,7 @@ def parse_tool_panel_config( config, shed_tools_dict ):
|
||||
has_test_data = True
|
||||
if galaxy_test_file_dir != last_galaxy_test_file_dir:
|
||||
if not os.path.isabs( galaxy_test_file_dir ):
|
||||
galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir )
|
||||
galaxy_test_file_dir = os.path.join( galaxy_root, galaxy_test_file_dir )
|
||||
guid = elem.get( 'guid' )
|
||||
shed_tools_dict[ guid ] = galaxy_test_file_dir
|
||||
last_galaxy_test_file_dir = galaxy_test_file_dir
|
||||
@@ -89,7 +83,7 @@ def parse_tool_panel_config( config, shed_tools_dict ):
|
||||
has_test_data = True
|
||||
if galaxy_test_file_dir != last_galaxy_test_file_dir:
|
||||
if not os.path.isabs( galaxy_test_file_dir ):
|
||||
galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir )
|
||||
galaxy_test_file_dir = os.path.join( galaxy_root, galaxy_test_file_dir )
|
||||
guid = section_elem.get( 'guid' )
|
||||
shed_tools_dict[ guid ] = galaxy_test_file_dir
|
||||
last_galaxy_test_file_dir = galaxy_test_file_dir
|
||||
|
||||
@@ -8,13 +8,10 @@ import sys
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
cwd = os.getcwd()
|
||||
sys.path.append( cwd )
|
||||
new_path = [ os.path.join( cwd, "lib" ),
|
||||
os.path.join( cwd, 'test' ),
|
||||
os.path.join( cwd, 'lib', 'tool_shed', 'scripts', 'api' ) ]
|
||||
new_path.extend( sys.path )
|
||||
sys.path = new_path
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, os.path.pardir))
|
||||
sys.path[1:1] = [ os.path.join( galaxy_root, "lib" ),
|
||||
os.path.join( galaxy_root, 'test' ),
|
||||
os.path.join( galaxy_root, 'lib', 'tool_shed', 'scripts', 'api' ) ]
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( 'mercurial' )
|
||||
@@ -455,8 +452,7 @@ def get_static_settings():
|
||||
Return a dictionary of the settings necessary for a Galaxy application to be wrapped in the static
|
||||
middleware. This mainly consists of the file system locations of url-mapped static resources.
|
||||
"""
|
||||
cwd = os.getcwd()
|
||||
static_dir = os.path.join( cwd, 'static' )
|
||||
static_dir = os.path.join( galaxy_root, 'static' )
|
||||
# TODO: these should be copied from galaxy.ini
|
||||
# TODO: static_enabled needed here?
|
||||
return dict( static_enabled=True,
|
||||
|
||||
+6
-10
@@ -16,15 +16,11 @@ import tempfile
|
||||
import threading
|
||||
import time
|
||||
|
||||
# Assume we are run from the galaxy root directory, add lib to the python path
|
||||
cwd = os.getcwd()
|
||||
sys.path.append( cwd )
|
||||
new_path = [ os.path.join( cwd, "scripts" ),
|
||||
os.path.join( cwd, "lib" ),
|
||||
os.path.join( cwd, 'test' ),
|
||||
os.path.join( cwd, 'scripts', 'api' ) ]
|
||||
new_path.extend( sys.path )
|
||||
sys.path = new_path
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, os.path.pardir))
|
||||
sys.path[1:1] = [ os.path.join( galaxy_root, "scripts" ),
|
||||
os.path.join( galaxy_root, "lib" ),
|
||||
os.path.join( galaxy_root, 'test' ),
|
||||
os.path.join( galaxy_root, 'scripts', 'api' ) ]
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( "nose" )
|
||||
@@ -48,7 +44,7 @@ from galaxy.web import buildapp
|
||||
log = logging.getLogger( 'install_and_test_repositories_with_tools' )
|
||||
|
||||
assert sys.version_info[ :2 ] >= ( 2, 6 )
|
||||
test_home_directory = os.path.join( cwd, 'test', 'install_and_test_tool_shed_repositories', 'repositories_with_tools' )
|
||||
test_home_directory = os.path.join( galaxy_root, 'test', 'install_and_test_tool_shed_repositories', 'repositories_with_tools' )
|
||||
|
||||
# Here's the directory where everything happens. Temporary directories are created within this directory to contain
|
||||
# the database, new repositories, etc.
|
||||
|
||||
+6
-10
@@ -15,15 +15,11 @@ import tempfile
|
||||
import threading
|
||||
import time
|
||||
|
||||
# Assume we are run from the galaxy root directory, add lib to the python path
|
||||
cwd = os.getcwd()
|
||||
sys.path.append( cwd )
|
||||
new_path = [ os.path.join( cwd, "scripts" ),
|
||||
os.path.join( cwd, "lib" ),
|
||||
os.path.join( cwd, 'test' ),
|
||||
os.path.join( cwd, 'scripts', 'api' ) ]
|
||||
new_path.extend( sys.path )
|
||||
sys.path = new_path
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, os.path.pardir))
|
||||
sys.path[1:1] = [ os.path.join( galaxy_root, "scripts" ),
|
||||
os.path.join( galaxy_root, "lib" ),
|
||||
os.path.join( galaxy_root, 'test' ),
|
||||
os.path.join( galaxy_root, 'scripts', 'api' ) ]
|
||||
|
||||
from galaxy import eggs
|
||||
eggs.require( "Paste" )
|
||||
@@ -43,7 +39,7 @@ from galaxy.web import buildapp
|
||||
log = logging.getLogger( 'install_and_test_tool_dependency_definitions' )
|
||||
|
||||
assert sys.version_info[ :2 ] >= ( 2, 6 )
|
||||
test_home_directory = os.path.join( cwd, 'test', 'install_and_test_tool_shed_repositories', 'tool_dependency_definitions' )
|
||||
test_home_directory = os.path.join( galaxy_root, 'test', 'install_and_test_tool_shed_repositories', 'tool_dependency_definitions' )
|
||||
|
||||
# Here's the directory where everything happens. Temporary directories are created within this directory to contain
|
||||
# the database, new repositories, etc.
|
||||
|
||||
@@ -6,20 +6,14 @@ import sys
|
||||
from threading import Thread
|
||||
from uuid import uuid4
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
galaxy_root = os.path.join(script_dir, os.path.pardir, os.path.pardir)
|
||||
new_path = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
|
||||
sys.path[1:1] = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ]
|
||||
|
||||
try:
|
||||
from argparse import ArgumentParser
|
||||
except ImportError:
|
||||
ArgumentParser = None
|
||||
|
||||
from api import yaml_to_workflow
|
||||
from api import helpers
|
||||
|
||||
try:
|
||||
from galaxy import eggs
|
||||
eggs.require("requests")
|
||||
@@ -29,6 +23,8 @@ except ImportError:
|
||||
import requests
|
||||
from bioblend import galaxy
|
||||
|
||||
from api import helpers, yaml_to_workflow
|
||||
|
||||
LONG_TIMEOUT = 1000000000
|
||||
DESCRIPTION = "Script to exercise the workflow engine."
|
||||
|
||||
|
||||
@@ -14,21 +14,18 @@ import threading
|
||||
import time
|
||||
import urllib
|
||||
|
||||
# Assume we are run from the galaxy root directory, add lib to the python path
|
||||
cwd = os.getcwd()
|
||||
tool_shed_home_directory = os.path.join( cwd, 'test', 'tool_shed' )
|
||||
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
|
||||
tool_shed_home_directory = os.path.join( galaxy_root, 'test', 'tool_shed' )
|
||||
default_tool_shed_test_file_dir = os.path.join( tool_shed_home_directory, 'test_data' )
|
||||
# Here's the directory where everything happens. Temporary directories are created within this directory to contain
|
||||
# the hgweb.config file, the database, new repositories, etc. Since the tool shed browses repository contents via HTTP,
|
||||
# the full path to the temporary directroy wher eht repositories are located cannot contain invalid url characters.
|
||||
tool_shed_test_tmp_dir = os.path.join( tool_shed_home_directory, 'tmp' )
|
||||
os.environ[ 'TOOL_SHED_TEST_TMP_DIR' ] = tool_shed_test_tmp_dir
|
||||
new_path = [ os.path.join( cwd, "lib" ), os.path.join( cwd, "test" ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
# Need to remove this directory from sys.path
|
||||
sys.path[0:1] = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ]
|
||||
|
||||
from galaxy import eggs
|
||||
|
||||
eggs.require( "nose" )
|
||||
eggs.require( "NoseHTML" )
|
||||
eggs.require( "NoseTestDiff" )
|
||||
@@ -53,8 +50,8 @@ from galaxy.app import UniverseApplication as GalaxyUniverseApplication
|
||||
from galaxy.util import asbool
|
||||
from galaxy.web import buildapp as galaxybuildapp
|
||||
|
||||
from functional import database_contexts
|
||||
from base import nose_util
|
||||
from functional import database_contexts
|
||||
|
||||
log = logging.getLogger( "tool_shed_functional_tests.py" )
|
||||
|
||||
@@ -82,8 +79,7 @@ def get_static_settings():
|
||||
This mainly consists of the filesystem locations of url-mapped
|
||||
static resources.
|
||||
"""
|
||||
cwd = os.getcwd()
|
||||
static_dir = os.path.join( cwd, 'static' )
|
||||
static_dir = os.path.join( galaxy_root, 'static' )
|
||||
# TODO: these should be copied from galaxy.ini
|
||||
return dict(
|
||||
# TODO: static_enabled needed here?
|
||||
@@ -426,10 +422,6 @@ def main():
|
||||
else:
|
||||
raise Exception( "Test HTTP server did not return '200 OK' after 10 tries" )
|
||||
log.info( "Embedded galaxy web server started" )
|
||||
# We don't add the tests to the path until everything is up and running
|
||||
new_path = [ os.path.join( cwd, 'test' ) ]
|
||||
new_path.extend( sys.path[1:] )
|
||||
sys.path = new_path
|
||||
# ---- Find tests ---------------------------------------------------------
|
||||
if tool_shed_test_proxy_port:
|
||||
log.info( "Functional tests will be run against %s:%s" % ( tool_shed_test_host, tool_shed_test_proxy_port ) )
|
||||
|
||||
@@ -14,12 +14,12 @@ else:
|
||||
|
||||
# =============================================================================
|
||||
def get_unittest_utils_path():
|
||||
return os.path.normpath( os.path.join( os.getcwd(), os.path.dirname( __file__ ) ) )
|
||||
return os.path.abspath( os.path.dirname( __file__ ) )
|
||||
|
||||
|
||||
def get_galaxy_root():
|
||||
# precondition: this file must be at <GALAXY_ROOT>/test/unit/unittest_utils/utility.py
|
||||
return os.path.normpath( os.path.join( get_unittest_utils_path(), '../../../' ) )
|
||||
return os.path.normpath( os.path.join( get_unittest_utils_path(), os.pardir, os.pardir, os.pardir ) )
|
||||
|
||||
|
||||
def get_galaxy_libpath():
|
||||
@@ -42,8 +42,7 @@ def clean_multiline_string( multiline_string, sep='\n' ):
|
||||
|
||||
|
||||
# =============================================================================
|
||||
sys.path.insert( 0, get_galaxy_libpath() )
|
||||
sys.path.insert( 1, get_unittest_utils_path() )
|
||||
sys.path[1:1] = [ get_galaxy_libpath(), get_unittest_utils_path() ]
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
||||
Reference in New Issue
Block a user