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, sport_service, data_path=None, parent=None): logging.debug('>>') self._sport_service = sport_service self.parent = parent self.pytrainer_main = parent self._equipment_service = EquipmentService(self.pytrainer_main.ddbb) self.data_path = data_path logging.debug('setting date...') self.date = Date() logging.debug('<<')
def selectInitialDate(self): logging.debug('>>') # self.windowmain.calendar comes from SimpleGladeApp initialisation, not really sure how... :? self.date = Date(self.windowmain.calendar) if self.profile.getValue("pytraining", "prf_startscreen") == "last_entry": logging.info( "User selection is to display last entry in start screen") last_entry_date = self.record.getLastRecordDateString() try: logging.info("Last activity found on %s" % last_entry_date) self.date.setDate(last_entry_date) except: logging.error( "No data available regarding last activity date. Default date will be today" ) logging.debug("Traceback: %s" % traceback.format_exc()) else: logging.info( "User selection is to display current day in start screen") logging.debug('Setting date to %s' % self.date.getDate().strftime("%Y-%m-%d")) logging.debug('<<')