Ejemplo n.º 1
0
 def __init__(self):
     self.log = logging.getLogger('disper')
     self.log.setLevel(logging.WARNING)
     self._options_init()
     self.plugins = Plugins(self)
     #self.plugins.call('init') # can't really do here since list of plugins isn't read yet
     # add default options
     # TODO do initial parsing too so errors can be traced to config
     self.options_append(self.config_read_default())
Ejemplo n.º 2
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('<<')
Ejemplo n.º 3
0
 def __init__(self):
     self.plugins = Plugins()
     self.plugins.print()
Ejemplo n.º 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('<<')
Ejemplo n.º 5
0
        credential_key = getpass.getpass('Credential Key:')
    credential_manager = CredentialManager(credentials_file, credential_key)
    config.credential_manager = credential_manager

    ## -- test just resets the db everytime --
    from models import Base
    from db import engine
    if not settings.in_production():
        Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    from repos import repotracker
    from plugins import RepoWatcher, Plugins
    from plugins.base import PluginTestError

#-- Load plugins
    loaded_plugins = Plugins(configuration)

    if args.tests:
        print "=======================  Loading plugins ======================="
        plugins = loaded_plugins.enabled_plugins()

        print "=======================  Running Plugin Tests ======================="
        for plugin_area in plugins:
            for plugin in plugins[plugin_area]:
                print "Running test for ", plugin.__module__
                try:
                    plugin.test()
                except PluginTestError, pte:
                    print "Test Failed for ", plugin.__module__
                    print pte.message
                    sys.exit(1)
Ejemplo n.º 6
0
    def __init__(self, init_cfg: dict, init_state: dict, path: dict,
                 sig: SignalHandlerDummy):
        self._sig = sig
        self.reload = False
        self._restore_filename = None
        self._lock = threading.Lock()
        self._stts_lock = threading.Lock()
        self._join_lock = threading.Lock()

        self._pub = PubSub()
        self._sig.set_wakeup_callback(
            lambda: self.sub_call('default', 'terminal_stop', True))

        self._logger = logger.Logger(self)
        proxies.add_logger(self._logger.add('Proxy'))

        self._cfg = ConfigHandler(cfg=init_cfg,
                                  state=init_state,
                                  path=path,
                                  log=self._logger.add('CFG'),
                                  owner=self)
        self._logger.init(cfg=self._cfg, owner=self)
        self._log = self._logger.add('SYSTEM')

        self._listen = Listener(cfg=self._cfg,
                                log=self._logger.add('REC'),
                                owner=self)
        self._notifier = MajordomoNotifier(cfg=self._cfg,
                                           log=self._logger.add('Notifier'),
                                           owner=self)
        self._tts = stts.TextToSpeech(cfg=self._cfg,
                                      log=self._logger.add('TTS'))
        self._play = Player(cfg=self._cfg,
                            log=self._logger.add('Player'),
                            owner=self)
        self._music = music_constructor(cfg=self._cfg,
                                        logger=self._logger,
                                        owner=self)
        self._stt = stts.SpeechToText(cfg=self._cfg,
                                      log=self._logger.add('STT'),
                                      owner=self)
        self._mm = ModuleManager(cfg=self._cfg,
                                 log=self._logger.add('MM'),
                                 owner=self)
        self._updater = Updater(cfg=self._cfg,
                                log=self._logger.add('Updater'),
                                owner=self)
        self._backup = Backup(cfg=self._cfg,
                              log=self._logger.add('Backup'),
                              owner=self)
        self._terminal = MDTerminal(cfg=self._cfg,
                                    log=self._logger.add('Terminal'),
                                    owner=self)
        self._server = server_constructor(cfg=self._cfg,
                                          logger=self._logger,
                                          owner=self)
        self._plugins = Plugins(cfg=self._cfg,
                                log=self._logger.add('Plugins'),
                                owner=self)
        self._duplex_pool = DuplexPool(cfg=self._cfg,
                                       log=self._logger.add('DP'),
                                       owner=self)

        self._discovery = DiscoveryServer(cfg=self._cfg,
                                          log=self._logger.add('Discovery'))
Ejemplo n.º 7
0
 def setUp(self):
     configuration = config.Configuration(
         'tests/plugins/test_pluginloader.config.json')
     self.plugins = Plugins(configuration)