示例#1
0
    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('<<')
示例#2
0
    def __init__(self, environment, data_path=None, parent=None):
        logging.debug(">>")
        self.environment = environment
        self.pytrainer_main = parent
        self.data_path = data_path
        self.xml_tree = None
        self.tmpdir = environment.temp_dir
        self.confdir = environment.conf_dir
        self.conffile = environment.conf_file
        self.gpxdir = environment.gpx_dir
        self.extensiondir = environment.extension_dir
        self.plugindir = environment.plugin_dir
        self.uc = UC()
        self.profilewindow = None

        environment.clear_temp_dir()

        #Profile Options and Defaults
        self.profile_options = {
            "prf_name": "default",
            "prf_gender": "",
            "prf_weight": "",
            "prf_height": "",
            "prf_age": "",
            "prf_ddbb": "sqlite",
            "prf_ddbbhost": "",
            "prf_ddbbname": "",
            "prf_ddbbuser": "",
            "prf_ddbbpass": "",
            "version": "0.0",
            "prf_us_system": "False",
            "prf_hrzones_karvonen": "False",
            "prf_maxhr": "",
            "prf_minhr": "",
            "auto_launch_file_selection": "False",
            "import_default_tab": "0",
            "default_viewer": "0",
            "window_size": "800, 640",
            "activitypool_size": "10",
        }

        #Parse pytrainer configuration file
        self.config_file = environment.conf_file
        self.configuration = self._parse_config_file(self.config_file)
        logging.debug("Configuration retrieved: " + str(self.configuration))
        #self.pytrainer_main.ddbb = DDBB(self, pytrainer_main=self.pytrainer_main)
        self.uc.set_us(self.prf_us_system)
        self._setZones()
        logging.debug("<<")
示例#3
0
    def __init__(self):
        logging.debug(">>")
        # The first two variables are singletons themselves, profile_options
        # doesn't change, only xml_tree needs to be protected by has_attr.
        self.environment = Environment()
        self.uc = UC()
        #Profile Options and Defaults
        self.profile_options = {
            "prf_name": "default",
            "prf_gender": "",
            "prf_weight": "",
            "prf_height": "",
            "prf_age": "",
            "prf_ddbb": "sqlite",
            "prf_ddbbhost": "",
            "prf_ddbbname": "",
            "prf_ddbbuser": "",
            "prf_ddbbpass": "",
            "version": "0.0",
            "prf_us_system": "False",
            "prf_hrzones_karvonen": "False",
            "prf_maxhr": "",
            "prf_minhr": "",
            "auto_launch_file_selection": "False",
            "import_default_tab": "0",
            "default_viewer": "0",
            "window_size": "800, 640",
            "activitypool_size": "10",
            "prf_startscreen": "current_day",
        }

        if not hasattr(self, 'xml_tree'):
            self.xml_tree = None
            #Parse pytrainer configuration file
            self.refreshConfiguration()

        logging.debug("<<")
示例#4
0
    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('<<')