Jelajahi Sumber

added regex to sanitize datetime -stamps

Michael Honkoop 4 bulan lalu
induk
melakukan
adfb1fe793
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      edir-monitor.py

+ 3 - 0
edir-monitor.py

@@ -7,6 +7,7 @@
 import sys
 import ldap
 import json
+import re
 
 def print_list(the_list):
     for each_item in the_list:
@@ -31,6 +32,8 @@ def print_list(the_list):
                     keytxtresult = (' '.join(keyresult).replace('cn=Monitor', '').replace('cn=', '').strip())
                     # join the values into a string
                     valueresult = ' '.join(str(e) for e in v)
+                    # sanitize the timestamps if they are present
+                    valueresult = re.sub('(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})([Z])$', r'\3-\2-\1 \4:\5:\6', valueresult)
                     # usecases of formatting data differently
                     if "BackGroundProc" in keytxtresult:
                         resultArray.append("- ")