root/galaxy-central/lib/galaxy/app.py

リビジョン 2, 4.1 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1import sys, os, atexit
2
3from galaxy import config, jobs, util, tools, web
4import galaxy.tools.search
5import galaxy.tools.data
6from galaxy.web import security
7import galaxy.model
8import galaxy.datatypes.registry
9import galaxy.security
10from galaxy.tags.tag_handler import GalaxyTagHandler
11from galaxy.tools.imp_exp import load_history_imp_exp_tools
12
13class UniverseApplication( object ):
14    """Encapsulates the state of a Universe application"""
15    def __init__( self, **kwargs ):
16        print >> sys.stderr, "python path is: " + ", ".join( sys.path )
17        # Read config file and check for errors
18        self.config = config.Configuration( **kwargs )
19        self.config.check()
20        config.configure_logging( self.config )
21        # Set up datatypes registry
22        self.datatypes_registry = galaxy.datatypes.registry.Registry( self.config.root, self.config.datatypes_config )
23        galaxy.model.set_datatypes_registry( self.datatypes_registry )
24        # Determine the database url
25        if self.config.database_connection:
26            db_url = self.config.database_connection
27        else:
28            db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database
29        # Initialize database / check for appropriate schema version
30        from galaxy.model.migrate.check import create_or_verify_database
31        create_or_verify_database( db_url, self.config.database_engine_options )
32        # Setup the database engine and ORM
33        from galaxy.model import mapping
34        self.model = mapping.init( self.config.file_path,
35                                   db_url,
36                                   self.config.database_engine_options,
37                                   database_query_profiling_proxy = self.config.database_query_profiling_proxy )
38        # Security helper
39        self.security = security.SecurityHelper( id_secret=self.config.id_secret )
40        # Tag handler
41        self.tag_handler = GalaxyTagHandler()
42        # Tool data tables
43        self.tool_data_tables = galaxy.tools.data.ToolDataTableManager( self.config.tool_data_table_config_path )
44        # Initialize the tools
45        self.toolbox = tools.ToolBox( self.config.tool_config, self.config.tool_path, self )
46        # Search support for tools
47        self.toolbox_search = galaxy.tools.search.ToolBoxSearch( self.toolbox )
48        # Load datatype converters
49        self.datatypes_registry.load_datatype_converters( self.toolbox )
50        # Load history import/export tools
51        load_history_imp_exp_tools( self.toolbox )
52        #load external metadata tool
53        self.datatypes_registry.load_external_metadata_tool( self.toolbox )
54        # Load datatype indexers
55        self.datatypes_registry.load_datatype_indexers( self.toolbox )
56        #Load security policy
57        self.security_agent = self.model.security_agent
58        self.host_security_agent = galaxy.security.HostAgent( model=self.security_agent.model, permitted_actions=self.security_agent.permitted_actions )
59        # Heartbeat and memdump for thread / heap profiling
60        self.heartbeat = None
61        self.memdump = None
62        self.memory_usage = None
63        # Start the heartbeat process if configured and available
64        if self.config.use_heartbeat:
65            from galaxy.util import heartbeat
66            if heartbeat.Heartbeat:
67                self.heartbeat = heartbeat.Heartbeat( fname=self.config.heartbeat_log )
68                self.heartbeat.start()
69        # Enable the memdump signal catcher if configured and available
70        if self.config.use_memdump:
71            from galaxy.util import memdump
72            if memdump.Memdump:
73                self.memdump = memdump.Memdump()
74        # Start the job queue
75        self.job_manager = jobs.JobManager( self )
76        # FIXME: These are exposed directly for backward compatibility
77        self.job_queue = self.job_manager.job_queue
78        self.job_stop_queue = self.job_manager.job_stop_queue
79        # Track Store
80        ## self.track_store = store.TrackStoreManager( self.config.track_store_path )
81       
82    def shutdown( self ):
83        self.job_manager.shutdown()
84        if self.heartbeat:
85            self.heartbeat.shutdown()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。