<s> """<STR_LIT>""" <EOL> import logging <EOL> from envisage import Runnable <EOL> from envisage . workbench . services import IWORKBENCH <EOL> from pyface . api import information <EOL> from . services import IPROJECT_MODEL , IPROJECT_UI <EOL> logger = logging . getLogger ( __name__ ) <EOL> class ProjectRunnable ( Runnable ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , application ) : <EOL> """<STR_LIT>""" <EOL> ui_service = application . get_service ( IPROJECT_UI ) <EOL> ui_service . listen_for_application_exit ( ) <EOL> model_service = application . get_service ( IPROJECT_MODEL ) <EOL> location = model_service . preferences . get ( '<STR_LIT>' , <EOL> default = None ) <EOL> if location and len ( location ) > <NUM_LIT:0> : <EOL> logger . info ( "<STR_LIT>" , location ) <EOL> try : <EOL> project = model_service . factory . open ( location ) <EOL> except : <EOL> logger . exception ( '<STR_LIT>' ) <EOL> project = None <EOL> if project is not None : <EOL> model_service . project = project <EOL> else : <EOL> information ( self . _get_parent_window ( application ) , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( location ) + '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> else : <EOL> logger . info ( '<STR_LIT>' ) <EOL> return <EOL> def _get_parent_window ( self , application ) : <EOL> """<STR_LIT>""" <EOL> window = None <EOL> try : <EOL> workbench = application . get_service ( IWORKBENCH ) <EOL> window = workbench . active_window . control <EOL> except : <EOL> logger . warn ( '<STR_LIT>' ) <EOL> return window </s>
