コード例 #1
0
ファイル: environment.py プロジェクト: ymae/pytrainer
    def __init__(self, conf_dir=None, data_path=None):
        """Initialise an environment.
        
        Arguments:
        conf_dir -- the directory where program configuration should be stored. If None, then the default for the platform is used.
        
        """
        if not hasattr(self, 'conf_dir'):
            if conf_dir:
                self.conf_dir = conf_dir
            else:
                self.conf_dir = get_platform().get_default_conf_dir()

        if not hasattr(self, 'data_path'):
            if data_path:
                self.data_path = data_path
            else:
                self.data_path = get_platform().get_default_data_path()
コード例 #2
0
ファイル: environment.py プロジェクト: pytrainer/pytrainer
    def __init__(self, conf_dir=None, data_path=None):
        """Initialise an environment.
        
        Arguments:
        conf_dir -- the directory where program configuration should be stored. If None, then the default for the platform is used.
        
        """
        if not hasattr(self, 'conf_dir'):
            if conf_dir:
                self.conf_dir = conf_dir
            else:
                self.conf_dir = get_platform().get_default_conf_dir()

        if not hasattr(self, 'data_path'):
            if data_path:
                self.data_path = data_path
            else:
                self.data_path = get_platform().get_default_data_path()
コード例 #3
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('<<')
コード例 #4
0
    def for_week_containing(clazz, date):
        """Get the date range for the week containing the given date.

        The date range will start on the first day of the week and end on the
        last day of the week. The week start and end days are locale dependent.

        Args:
            date (datetime.date): a date within the week to get the date range for.
        Returns:
            (DateRange): the date range for a week.
        """
        day_of_week = (int(date.strftime("%w")) - get_platform().get_first_day_of_week()) % 7
        date_start = date + datetime.timedelta(days = 0 - day_of_week)
        date_end = date + datetime.timedelta(days = 6 - day_of_week)
        return DateRange(date_start, date_end)
コード例 #5
0
ファイル: date.py プロジェクト: pytrainer/pytrainer
    def for_week_containing(clazz, date):
        """Get the date range for the week containing the given date.

        The date range will start on the first day of the week and end on the
        last day of the week. The week start and end days are locale dependent.

        Args:
            date (datetime.date): a date within the week to get the date range for.
        Returns:
            (DateRange): the date range for a week.
        """
        day_of_week = (int(date.strftime("%w")) - get_platform().get_first_day_of_week()) % 7
        date_start = date + datetime.timedelta(days = 0 - day_of_week)
        date_end = date + datetime.timedelta(days = 6 - day_of_week)
        return DateRange(date_start, date_end)
コード例 #6
0
ファイル: main.py プロジェクト: dantleech/pytrainer
 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('<<')
コード例 #7
0
ファイル: test_platform.py プロジェクト: pytrainer/pytrainer
 def test_first_day_of_week_should_be_less_than_seven(self):
     first_day = get_platform().get_first_day_of_week()
     self.assertTrue(first_day < 7)
コード例 #8
0
ファイル: test_platform.py プロジェクト: pytrainer/pytrainer
 def test_first_day_of_week_should_be_non_negative_integer(self):
     first_day = get_platform().get_first_day_of_week()
     self.assertTrue(first_day >= 0)
コード例 #9
0
ファイル: test_platform.py プロジェクト: ymae/pytrainer
 def test_first_day_of_week_should_be_less_than_seven(self):
     first_day = get_platform().get_first_day_of_week()
     self.assertTrue(first_day < 7)
コード例 #10
0
ファイル: test_platform.py プロジェクト: ymae/pytrainer
 def test_first_day_of_week_should_be_non_negative_integer(self):
     first_day = get_platform().get_first_day_of_week()
     self.assertTrue(first_day >= 0)