def get_sync_status(self): """ check if cache and config db are synced if sync is True, the synctime is returned else, the difference (cache-time - database_time) is given :return: dict with keys 'sync' and 'synctime' """ result = {'sync': False} linotp_conf = LinOtpConfig() linotp_time = linotp_conf.get('linotp.Config') # get db entry for config entry = Session.query(config_model).filter( config_model.Key == 'linotp.Config').one() db_time = entry.Value # if the times are not in syc, LinOTP keeps its status # cached but does not update its timestamp of sync if db_time == linotp_time: result['sync'] = True result['synctime'] = db_time now = datetime.datetime.now() result['now'] = unicode(now) else: format_string = '%Y-%m-%d %H:%M:%S.%f' linotp_t = datetime.datetime.strptime(str(linotp_time), format_string) db_t = datetime.datetime.strptime(str(db_time), format_string) result['cache_to_db_diff'] = unicode(linotp_t - db_t) result['db_time'] = db_time return result
def get_sync_status(self): """ check if cache and config db are synced if sync is True, the synctime is returned else, the difference (cache-time - database_time) is given :return: dict with keys 'sync' and 'synctime' """ result = {"sync": False} linotp_conf = LinOtpConfig() linotp_time = linotp_conf.get("linotp.Config") # get db entry for config entry = config_model.query.filter_by(Key="linotp.Config").one() db_time = entry.Value # if the times are not in syc, LinOTP keeps its status # cached but does not update its timestamp of sync if db_time == linotp_time: result["sync"] = True result["synctime"] = db_time now = datetime.datetime.now() result["now"] = str(now) else: format_string = "%Y-%m-%d %H:%M:%S.%f" linotp_t = datetime.datetime.strptime(str(linotp_time), format_string) db_t = datetime.datetime.strptime(str(db_time), format_string) result["cache_to_db_diff"] = str(linotp_t - db_t) result["db_time"] = db_time return result
def get_sync_status(self): """ check if cache and config db are synced if sync is True, the synctime is returned :return: dict with keys 'sync' and 'synctime' """ result = {'sync': False} linotp_conf = LinOtpConfig() linotp_time = linotp_conf.get('linotp.Config') # get db entry for config entry = Session.query(config_model).filter( config_model.Key == 'linotp.Config').one() db_time = entry.Value # if the times are not in syc, LinOTP keeps its status # cached but does not update its timestamp of sync if db_time == linotp_time: result['sync'] = True result['synctime'] = db_time return result