Esempio n. 1
0
 def __init__(self, verbose, *args, **kwargs):
     AppClass.__init__(self, *args, **kwargs)
     self.settings = QSettings('everpad', 'everpad-provider')
     self.verbose = verbose
     session_bus = dbus.SessionBus()
     self.bus = dbus.service.BusName("com.everpad.Provider", session_bus)
     self.service = ProviderService(session_bus, '/EverpadProvider')
     self.sync_thread = SyncThread()
     self.sync_thread.sync_state_changed.connect(
         Slot(int)(self.service.sync_state_changed), )
     self.sync_thread.data_changed.connect(
         Slot()(self.service.data_changed), )
     if get_auth_token():
         self.sync_thread.start()
     self.service.qobject.authenticate_signal.connect(
         self.on_authenticated, )
     self.service.qobject.remove_authenticate_signal.connect(
         self.on_remove_authenticated, )
     self.service.qobject.terminate.connect(self.terminate)
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     QThread.__init__(self, *args, **kwargs)
     self.app = AppClass.instance()
     self.status = STATUS_NONE
     self.last_sync = datetime.now()
     self.update_count = 0
     self.timer = QTimer()
     self.timer.timeout.connect(self.sync)
     self.update_timer()
     self.wait_condition = QWaitCondition()
     self.mutex = QMutex()
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     QThread.__init__(self, *args, **kwargs)
     self.app = AppClass.instance()
     self.status = STATUS_NONE
     self.last_sync = datetime.now()
     self.update_count = 0
     self.timer = QTimer()
     self.timer.timeout.connect(self.sync)
     self.update_timer()
     self.wait_condition = QWaitCondition()
     self.mutex = QMutex()
Esempio n. 4
0
 def __init__(self, verbose, *args, **kwargs):
     AppClass.__init__(self, *args, **kwargs)
     self.settings = QSettings('everpad', 'everpad-provider')
     self.verbose = verbose
     session_bus = dbus.SessionBus()
     self.bus = dbus.service.BusName("com.everpad.Provider", session_bus)
     self.service = ProviderService(session_bus, '/EverpadProvider')
     self.sync_thread = SyncThread()
     self.sync_thread.sync_state_changed.connect(
         Slot(int)(self.service.sync_state_changed),
     )
     self.sync_thread.data_changed.connect(
         Slot()(self.service.data_changed),
     )
     if get_auth_token():
         self.sync_thread.start()
     self.service.qobject.authenticate_signal.connect(
         self.on_authenticated,
     )
     self.service.qobject.remove_authenticate_signal.connect(
         self.on_remove_authenticated,
     )
     self.service.qobject.terminate.connect(self.terminate)
Esempio n. 5
0
    def __init__(self, verbose, *args, **kwargs):

        # non-kde:
        # from PySide.QtCore import QCoreApplication
        # AppClass = QCoreApplication
        AppClass.__init__(self, *args, **kwargs)

        # ************************************************************
        #                   Configure logger
        # ************************************************************
        # https://docs.python.org/2/library/logging.html
        # good ref:
        # http://victorlin.me/posts/2012/08/26/good-logging-practice-in-python
        # Yes, quite drawn out with all my if verbose, but readable for me when
        # I come back to this in a couple weeks or more

        #logging.basicConfig(level=logging.INFO)

        # create logger and set to debug
        self.logger = logging.getLogger('gevernote-provider')
        self.logger.setLevel(logging.DEBUG)

        fh = logging.FileHandler(
            os.path.expanduser('~/.everpad/logs/gevernote-provider.log'))
        fh.setLevel(logging.DEBUG)
        fh.setFormatter(
            logging.Formatter(
                '%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
        self.logger.addHandler(fh)
        if verbose:
            ch = logging.StreamHandler()
            ch.setLevel(logging.DEBUG)
            ch.setFormatter(logging.Formatter('%(asctime)s - %(message)s'))
            self.logger.addHandler(ch)

        self.logger.info('Logging started.')

        # ref:  http://qt-project.org/doc/qt-4.8/qsettings.html
        #
        # For example, if your product is called Star Runner and your company
        # is called MySoft, you would construct the QSettings object as follows:
        #     QSettings settings("MySoft", "Star Runner");
        #  Backwards?
        self.settings = QSettings('everpad', 'everpad-provider')

        # going to do more here - gsettings
        self.logger.debug('Setting parsed.')

        # Ref: http://excid3.com/blog/an-actually-decent-python-dbus-tutorial/
        # SessionBus because service is a session level daemon
        session_bus = dbus.SessionBus()

        # for future name change
        #self.bus = dbus.service.BusName("com.gevernote.Provider", session_bus)
        #self.service = ProviderService(session_bus, '/GrevernoteProvider')
        self.bus = dbus.service.BusName("com.everpad.Provider", session_bus)
        self.service = ProviderService(session_bus, '/EverpadProvider')

        self.logger.debug("dbus setup complete")

        # subclass PySide.QtCore.QThread  - agent.py
        # setup Sync thread
        self.sync_thread = SyncThread()

        # connect Sync thread sync_state_changed
        self.sync_thread.sync_state_changed.connect(
            Slot(int)(self.service.sync_state_changed), )

        # connect Sync thread data_changed
        self.sync_thread.data_changed.connect(
            Slot()(self.service.data_changed), )

        self.logger.debug("SyncThread init complete")

        # Start Sync Thread if provider is authenticated
        if get_auth_token():
            self.logger.debug('Auth - Starting Sync Thread.')
            self.sync_thread.start()
        else:
            self.logger.debug('No Auth - Sync Thread not started.')

        # ************************************************************
        #    Authentication and Termination Signals Setup
        # ************************************************************

        # provider_authenticate @Slot
        self.service.qobject.authenticate_signal.connect(
            self.provider_authenticate, )
        # on_authenticated @Slot
        #self.service.qobject.authenticate_signal.connect(
        #    self.on_authenticated,
        #)
        # on_remove_authenticated @Slot
        self.service.qobject.remove_authenticate_signal.connect(
            self.on_remove_authenticated, )
        self.service.qobject.terminate.connect(self.terminate)

        self.logger.info('Provider started.')
Esempio n. 6
0
 def __init__(self, *args, **kwargs):
     super(ProviderService, self).__init__(*args, **kwargs)
     self.qobject = ProviderServiceQObject()
     self.app = AppClass.instance()
Esempio n. 7
0
    def __init__(self, verbose, *args, **kwargs):

        # non-kde:
        # from PySide.QtCore import QCoreApplication    
        # AppClass = QCoreApplication
        AppClass.__init__(self, *args, **kwargs)

        # ************************************************************
        #                   Configure logger
        # ************************************************************
        # https://docs.python.org/2/library/logging.html
        # good ref: 
        # http://victorlin.me/posts/2012/08/26/good-logging-practice-in-python
        # Yes, quite drawn out with all my if verbose, but readable for me when 
        # I come back to this in a couple weeks or more

        #logging.basicConfig(level=logging.INFO)
        
        # create logger and set to debug
        self.logger = logging.getLogger('gevernote-provider')
        self.logger.setLevel(logging.DEBUG)
        
        fh = logging.FileHandler(
            os.path.expanduser('~/.everpad/logs/gevernote-provider.log'))
        fh.setLevel(logging.DEBUG)
        fh.setFormatter(logging.Formatter( 
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
        self.logger.addHandler(fh)
        if verbose:
            ch = logging.StreamHandler( )
            ch.setLevel(logging.DEBUG)
            ch.setFormatter(logging.Formatter('%(asctime)s - %(message)s'))
            self.logger.addHandler(ch)

        self.logger.info('Logging started.')
        
        # ref:  http://qt-project.org/doc/qt-4.8/qsettings.html
        #
        # For example, if your product is called Star Runner and your company 
        # is called MySoft, you would construct the QSettings object as follows:
        #     QSettings settings("MySoft", "Star Runner");
        #  Backwards?
        self.settings = QSettings('everpad', 'everpad-provider')

        # going to do more here - gsettings        
        self.logger.debug('Setting parsed.')

        # Ref: http://excid3.com/blog/an-actually-decent-python-dbus-tutorial/
        # SessionBus because service is a session level daemon
        session_bus = dbus.SessionBus()
        
        # for future name change
        #self.bus = dbus.service.BusName("com.gevernote.Provider", session_bus)
        #self.service = ProviderService(session_bus, '/GrevernoteProvider')
        self.bus = dbus.service.BusName("com.everpad.Provider", session_bus)
        self.service = ProviderService(session_bus, '/EverpadProvider')
        
        self.logger.debug("dbus setup complete")
        
        # subclass PySide.QtCore.QThread  - agent.py
        # setup Sync thread
        self.sync_thread = SyncThread()

        # connect Sync thread sync_state_changed
        self.sync_thread.sync_state_changed.connect(
            Slot(int)(self.service.sync_state_changed),
        )

        # connect Sync thread data_changed
        self.sync_thread.data_changed.connect(
            Slot()(self.service.data_changed),
        )
        
        self.logger.debug("SyncThread init complete")
                
        # Start Sync Thread if provider is authenticated
        if get_auth_token( ):
            self.logger.debug('Auth - Starting Sync Thread.')
            self.sync_thread.start()
        else:
            self.logger.debug('No Auth - Sync Thread not started.')

        # ************************************************************
        #    Authentication and Termination Signals Setup
        # ************************************************************

        # provider_authenticate @Slot
        self.service.qobject.authenticate_signal.connect(
            self.provider_authenticate,
        )
        # on_authenticated @Slot
        #self.service.qobject.authenticate_signal.connect(
        #    self.on_authenticated,
        #)
        # on_remove_authenticated @Slot
        self.service.qobject.remove_authenticate_signal.connect(
            self.on_remove_authenticated,
        )
        self.service.qobject.terminate.connect(self.terminate)
        
        self.logger.info('Provider started.')