def __init__(self, filename=None, data_path=None): # Based in Django's approach -> http://code.djangoproject.com/svn/django/trunk/django/__init__.py self.version = __import__('pytrainer').get_version() #Process command line options self.startup_options = self.get_options() #Setup logging self.environment = Environment(platform.get_platform(), self.startup_options.conf_dir) self.environment.create_directories() self.set_logging(self.startup_options.log_level, self.startup_options.log_type) logging.debug('>>') logging.debug("pytrainer version %s" % (self.version)) self.data_path = data_path self.date = Date() self.ddbb = None # Checking profile logging.debug('Checking configuration and profile...') self.profile = Profile(self.environment, self.data_path, self) self.uc = UC() self.windowmain = None self.ddbb = DDBB(self.profile, self) logging.debug('connecting to DDBB') self.ddbb.connect() initialize_data(self.ddbb, self.environment.conf_dir) self._sport_service = SportService(self.ddbb) self.record = Record(self._sport_service, data_path, self) self.athlete = Athlete(data_path, self) self.stats = Stats(self._sport_service, self) pool_size = self.profile.getIntValue("pytraining", "activitypool_size", default=1) self.activitypool = ActivityPool(self, size=pool_size) #preparamos la ventana principal self.windowmain = Main(self._sport_service, data_path, self, self.version, gpxDir=self.profile.gpxdir) self.date = Date(self.windowmain.calendar) self.waypoint = Waypoint(data_path, self) self.extension = Extension(data_path, self) self.plugins = Plugins(data_path, self) self.importdata = Importdata(self._sport_service, data_path, self, self.profile) self.loadPlugins() self.loadExtensions() self.windowmain.setup() self.windowmain.on_calendar_selected(None) self.refreshMainSportList() self.windowmain.run() logging.debug('<<')
def __init__(self,filename = None, data_path = None): #Version constants self.version ="1.10.0-dev" #Process command line options self.startup_options = self.get_options() #Setup logging self.environment = Environment(platform.get_platform(), self.startup_options.conf_dir) self.environment.create_directories() self.set_logging(self.startup_options.log_level, self.startup_options.log_type) logging.debug('>>') logging.debug("PyTrainer version %s" % (self.version)) self.data_path = data_path self.date = Date() self.ddbb = None # Checking profile logging.debug('Checking configuration and profile...') self.profile = Profile(self.environment, self.data_path,self) self.uc = UC() self.windowmain = None self.ddbb = DDBB(self.profile, self) logging.debug('connecting to DDBB') self.ddbb.connect() initialize_data(self.ddbb, self.environment.conf_dir) self._sport_service = SportService(self.ddbb) self.record = Record(self._sport_service, data_path, self) self.athlete = Athlete(data_path,self) self.stats = Stats(self._sport_service, self) pool_size = self.profile.getIntValue("pytraining","activitypool_size", default=1) self.activitypool = ActivityPool(self, size=pool_size) #preparamos la ventana principal self.windowmain = Main(self._sport_service, data_path,self,self.version, gpxDir=self.profile.gpxdir) self.date = Date(self.windowmain.calendar) self.waypoint = Waypoint(data_path,self) self.extension = Extension(data_path, self) self.plugins = Plugins(data_path, self) self.importdata = Importdata(self._sport_service, data_path, self, self.profile) self.loadPlugins() self.loadExtensions() self.windowmain.setup() self.windowmain.on_calendar_selected(None) self.refreshMainSportList() self.windowmain.run() logging.debug('<<')
def __init__(self, filename=None, data_path=None): # Based on Django's approach -> http://code.djangoproject.com/svn/django/trunk/django/__init__.py self.version = __import__('pytrainer').get_version() #Process command line options self.startup_options = self.get_options() #Setup logging self.environment = Environment(self.startup_options.conf_dir, data_path) self.environment.create_directories() self.environment.clear_temp_dir() self.set_logging(self.startup_options.log_level, self.startup_options.log_type) logging.debug('>>') logging.info("pytrainer version %s" % (self.version)) self.data_path = data_path # Checking profile logging.debug('Checking configuration and profile...') self.profile = Profile() # Write the default config to disk self.profile.saveProfile() self.uc = UC() self.profilewindow = None self.ddbb = DDBB(self.profile.sqlalchemy_url) logging.debug('connecting to DDBB') self.ddbb.connect() logging.info('Checking if some upgrade action is needed...') initialize_data(self.ddbb, self.environment.conf_dir) # Loading shared services logging.debug('Loading sport service...') self._sport_service = SportService(self.ddbb) logging.debug('Loading record service...') self.record = Record(self._sport_service, data_path, self) logging.debug('Loading athlete service...') self.athlete = Athlete(data_path, self) logging.debug('Loading stats service...') self.stats = Stats(self) logging.debug('Initializing activity pool...') pool_size = self.profile.getIntValue("pytraining", "activitypool_size", default=1) self.activitypool = ActivityService(self, size=pool_size) #Loading main window self.windowmain = None logging.debug('Loading main window...') self.windowmain = Main(self._sport_service, data_path, self, self.version, gpxDir=self.profile.gpxdir) # Select initial date depending on user's preference self.selectInitialDate() logging.debug('Loading waypoint service...') self.waypoint = WaypointService(data_path, self) logging.debug('Loading extension service...') self.extension = Extension(data_path, self) logging.debug('Loading plugins service...') self.plugins = Plugins(data_path, self) self.importdata = Importdata(self._sport_service, data_path, self, self.profile) logging.debug('Loading plugins...') self.loadPlugins() logging.debug('Loading extensions...') self.loadExtensions() logging.debug('Setting values for graphs, maps and waypoint editor...') self.windowmain.setup() self.windowmain.on_calendar_selected(None) logging.debug('Refreshing sport list... is this needed?') self.refreshMainSportList() logging.debug('Launching main window...') self.windowmain.run() logging.debug('<<')