예제 #1
0
파일: asynk.py 프로젝트: jt74/emacs
    def op_sync (self):
        conf  = self.get_config()
        pname = self._load_profile()

        sync = Sync(conf, pname, self.get_db(), dr=self.is_dry_run())
        if self.is_dry_run():
            sync.prep_lists(self.get_sync_dir())
        else:
            try:
                startt = conf.get_curr_time()
                result = sync.sync(self.get_sync_dir())
                if result:
                    conf.set_last_sync_start(pname, val=startt)
                    conf.set_last_sync_stop(pname)
                    logging.info('Updating item inventory...')
                    sync.save_item_lists()
                    logging.info('Updating item inventory...done')
                else:
                    logging.info('timestamps not reset for profile %s due to '
                                 'errors (previously identified).', pname)
            except Exception, e:
                logging.critical('Exception (%s) while syncing profile %s', 
                                 str(e), pname)
                logging.critical(traceback.format_exc())
                return False
예제 #2
0
파일: asynk.py 프로젝트: jdodds/ASynK
    def op_sync (self):
        conf  = self.get_config()
        pname = self._load_profile()

        sync = Sync(conf, pname, self.get_db(), dr=self.is_dry_run())
        if self.is_dry_run():
            sync.prep_lists(self.get_sync_dir())
        else:
            try:
                startt = conf.get_curr_time()
                result = sync.sync(self.get_sync_dir())
                if result:
                    conf.set_last_sync_start(pname, val=startt)
                    conf.set_last_sync_stop(pname)
                    logging.info('Updating item inventory...')
                    sync.save_item_lists()
                    logging.info('Updating item inventory...done')
                else:
                    logging.info('timestamps not reset for profile %s due to '
                                 'errors (previously identified).', pname)
            except Exception, e:
                logging.critical('Exception (%s) while syncing profile %s', 
                                 str(e), pname)
                logging.critical(traceback.format_exc())
                return False
예제 #3
0
    def op_sync(self):
        conf = self.get_config()
        pname = self._load_profile()

        startt_old = conf.get_last_sync_start(pname)
        stopt_old = conf.get_last_sync_stop(pname)

        if self.is_sync_all():
            # This is the case the user wants to force a sync ignoring the
            # earlier sync states. This is useful when ASynK code changes -
            # and let's say we add support for synching a enw field, or some
            # such.
            #
            # This works by briefly resetting the last sync start and stop
            # times to fool the system. If the user is doing a dry run, we
            # will restore his earlier times dutifully.
            if self.is_dry_run():
                logging.debug('Temporarily resetting last sync times...')
            conf.set_last_sync_start(pname, val="1980-01-01T00:00:00.00+00:00")
            conf.set_last_sync_stop(pname, val="1980-01-01T00:00:00.00+00:00")

        sync = Sync(conf, pname, self.get_db(), dr=self.is_dry_run())
        if self.is_dry_run():
            sync.prep_lists(self.get_sync_dir())
            # Since it is only a dry run, resetting to the timestamps to the
            # real older sync is sort of called for.
            conf.set_last_sync_start(pname, val=startt_old)
            conf.set_last_sync_stop(pname, val=stopt_old)
            logging.debug('Reset last sync timestamps to real values')
        else:
            try:
                startt = conf.get_curr_time()
                result = sync.sync(self.get_sync_dir())
                if result:
                    conf.set_last_sync_start(pname, val=startt)
                    conf.set_last_sync_stop(pname)
                    logging.info('Updating item inventory...')
                    sync.save_item_lists()
                    logging.info('Updating item inventory...done')
                else:
                    logging.info(
                        'timestamps not reset for profile %s due to '
                        'errors (previously identified).', pname)
            except Exception, e:
                logging.critical('Exception (%s) while syncing profile %s',
                                 str(e), pname)
                logging.critical(traceback.format_exc())
                return False
예제 #4
0
파일: asynk_core.py 프로젝트: xgid/ASynK
    def op_sync (self):
        conf  = self.get_config()
        pname = self._load_profile()

        startt_old = conf.get_last_sync_start(pname)
        stopt_old  = conf.get_last_sync_stop(pname)

        if self.is_sync_all():
            # This is the case the user wants to force a sync ignoring the
            # earlier sync states. This is useful when ASynK code changes -
            # and let's say we add support for synching a enw field, or some
            # such.
            #
            # This works by briefly resetting the last sync start and stop
            # times to fool the system. If the user is doing a dry run, we
            # will restore his earlier times dutifully.
            if self.is_dry_run():
                logging.debug('Temporarily resetting last sync times...')
            conf.set_last_sync_start(pname, val=utils.time_start)
            conf.set_last_sync_stop(pname, val=utils.time_start)
        sync = Sync(conf, pname, [x.get_db() for x in self.get_colls()],
                    dr=self.is_dry_run())
        if self.is_dry_run():
            sync.prep_lists(self.get_sync_dir())
            # Since it is only a dry run, resetting to the timestamps to the
            # real older sync is sort of called for.
            conf.set_last_sync_start(pname, val=startt_old)
            conf.set_last_sync_stop(pname, val=stopt_old)
            logging.debug('Reset last sync timestamps to real values')
        else:
            try:
                startt = conf.get_curr_time()
                result = sync.sync(self.get_sync_dir())
                if result:
                    conf.set_last_sync_start(pname, val=startt)
                    conf.set_last_sync_stop(pname)
                    logging.info('Updating item inventory...')
                    sync.save_item_lists()
                    logging.info('Updating item inventory...done')
                else:
                    logging.info('timestamps not reset for profile %s due to '
                                 'errors (previously identified).', pname)
            except Exception, e:
                logging.critical('Exception (%s) while syncing profile %s', 
                                 str(e), pname)
                logging.critical(traceback.format_exc())
                return False