diff --git a/flowspec/junos.py b/flowspec/junos.py index 215563b09fdbd6f2898a4e8e6f2332e3cf50dd47..1015daad8965002165211c65775f54c0f28785e6 100644 --- a/flowspec/junos.py +++ b/flowspec/junos.py @@ -229,11 +229,9 @@ def translate_frag_list(frag_list): def get_frag(rule): result='' if rule.fragmenttype: - tmp1 = translate_frag_list(rule.fragmenttype.all()) - if tmp1!="": - result = ',frag'+tmp1 - else: - result = '' + tmp = translate_frag_list(rule.fragmenttype.all()) + if tmp != "": + result = ',frag'+tmp return result def create_junos_name(rule): diff --git a/flowspec/snmpstats.py b/flowspec/snmpstats.py index 3b34f7374b90264904950d2e5628cb7348b4e678..f7cffca5c350dc24dffeb4be0f66e5c5255cc9a8 100644 --- a/flowspec/snmpstats.py +++ b/flowspec/snmpstats.py @@ -210,6 +210,16 @@ def helper_rule_ts_parse(ts_string): except Exception as e: logger.info("helper_rule_ts_parse(): ts_string="+str(ts_string)+": got exception "+str(e)) ts = None + + if ts==None: # other db may hav other time fmt: + logger.info("helper_rule_ts_parse(): trying with milli seconds fmt") + try: + ts = datetime.strptime(ts_string, '%Y-%m-%d %H:%M:%S.%f+00:00') # TODO TZ offset assumed to be 00:00 + except Exception as e: + logger.info("helper_rule_ts_parse(): ts_string="+str(ts_string)+": got exception "+str(e)) + ts = None + + logger.info("helper_rule_ts_parse(): => ts="+str(ts)) return ts def process_new_snmp_measurements__low_level(nowstr, samplecount, newdata, history): diff --git a/flowspec/views.py b/flowspec/views.py index e97af18828ac33a24e3b76450a5b55fac6a1bf1d..39baedcbe2a527743783cae4d17b9d468e0f4895 100644 --- a/flowspec/views.py +++ b/flowspec/views.py @@ -58,7 +58,8 @@ LOG_FILENAME = os.path.join(settings.LOG_FILE_LOCATION, 'gunicorn_views.log') # FORMAT = '%(asctime)s %(levelname)s: %(message)s' # logging.basicConfig(format=FORMAT) #formatter = logging.Formatter('%(asctime)s %(levelname)s %(clientip)s %(user)s: %(message)s') # leads to strange errors on test-lab -formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s') +#formatter = logging.Formatter('%(asctime)s %(levelname)s %(user)s: %(message)s') +formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s') logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG)