import datetime
import json
import threading
import time
from queue import Queue
# from sys
import platform
if 82 - 82: Iii1i
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from flask import Blueprint , render_template , request
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import or_ , and_
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
from vwAppConfigParam import vwAppConfigParam
from blueprints . wgcomm_console import WGControllerCenter2023 , checkConnectedSingle , getReacordFloorDescription
from exts import db
from decorators import login_required
from models . iccard import *
import vwAppConfig
if 98 - 98: I11iiIi11i1I % oOO
__all__ = [
 "bp" ,
 "background_task_realtimegetswipe" ,
 "background_task_wsudp" ,
 "background_task_checkControllerConnected" ,
 "background_backup_db" ,

# i1I . i1I1
]
bp = Blueprint ( 'wgcomm_realtimegetswipe' , __name__ , url_prefix = '/' )
if 22 - 22: i1I1 % I1I - oOO
if 97 - 97: I1I * oOo0O00 * IiIIii11Ii - I11iiIi11i1I - Oo - i1
if 29 - 29: i1iiIII111
if 3 - 3: i1 % i1 % i1i1i1111I . Ii * i1
if 9 - 9: i1iiIII111
if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
if 61 - 61: Ooo0Ooo - I1I
if 13 - 13: Ooo0Ooo
if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
if 60 - 60: iI1iII1I1I1i . oOO
if 13 - 13: oOO
if 2 - 2: i1
if 22 - 22: IIiIIiIi11I1 - ooo000 / I1Ii1I1 . ooo000
if 1 - 1: iI1iII1I1I1i + Ooo0Ooo + oOO * IIiIIiIi11I1
if 20 - 20: I1I + Ii
if 75 - 75: Ii % i1iiIII111 * Ii . IIiIIiIi11I1 % I11iiIi11i1I % I1Ii1I1
if 8 - 8: I1Ii1I1 . i1I1 . i1 . Oo - i1I
if 32 - 32: Ii % i1i1i1111I % i1I - I11iiIi11i1I % i1iiIII111
if 34 - 34: i1iiIII111 * i1
if 34 - 34: oOo0O00 / i1iiIII111 - Iii1i . iI1iII1I1I1i
if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
if 32 - 32: I1Ii1I1 + oOO - oOo0O00
if 79 - 79: Iii1i % oOO * Oo + ooOOO / Oo . oOO
if 20 - 20: i1I1 + i1iiIII111 / I1I
if 88 - 88: I11iiIi11i1I + ooOOO - i1i1i1111I . Ooo0Ooo * Ii + Iii1i
if 43 - 43: ooOOO * I1Ii1I1
if 95 - 95: Ooo0Ooo % Iii1i % i1i1i1111I . OooOoo
if 70 - 70: IiIIii11Ii
if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
if 88 - 88: Oo * IiIIii11Ii
if 100 - 100: i1I1 - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
if 29 - 29: IiIIii11Ii - oOo0O00
if 30 - 30: I1I . ooo000
if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
if 77 - 77: i1iiIII111 + i1I1 - Oo % ooo000
if 74 - 74: Ii + Ooo0Ooo
if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
if 37 - 37: i1I1 * i1i1i1111I + oOo0O00 / I1I / OooOoo
if 4 - 4: i1
if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
iIi = Queue ( )
if 23 - 23: iI1iII1I1I1i % oOO . Oo / OooOoo - I11iiIi11i1I - oOO
if 77 - 77: i1I1 - I11iiIi11i1I * Ooo0Ooo
class oOOOo0O0O0oOO :
 arrf_RecordFlashLocmax = dict ( )
 arrusersByCardNO = None
 arrdoorcontollersBySNDoor = None
 arrusercardChangeTimeLoadTime = 0
 arrdoorcontollersBySNDoorLoadTime = 0
 arrcontrollerSN = [ ]
 if 10 - 10: i1 + i1iiIII111 + oOO + OooOoo . i1 / ooo000
 if 89 - 89: I1I * i1i1i1111I
def background_task_realtimegetswipe ( ) :
 if 54 - 54: oOO + Ooo0Ooo - I1I . Ooo0Ooo
 if 50 - 50: Iii1i * ooo000 % Iii1i - oOo0O00 + ooo000
 if 54 - 54: oOO * i1 % i1 - Ooo0Ooo + IIiIIiIi11I1
 if 4 - 4: ooo000 + I1Ii1I1 * OooOoo - i1I1
 if 69 - 69: ooo000
 if 76 - 76: Iii1i * Ooo0Ooo . iI1iII1I1I1i / Ii / ooOOO
 if 49 - 49: iI1iII1I1I1i / i1iiIII111 + ooo000
 if 36 - 36: i1i1i1111I + Iii1i - oOO * Ii
 if 45 - 45: i1i1i1111I * Ii
 if 97 - 97: i1
 if 26 - 26: i1I1
 if 20 - 20: IIiIIiIi11I1 / Oo
 if 73 - 73: ooOOO - IiIIii11Ii
 if 22 - 22: Oo % oOo0O00 / i1I . oOo0O00 . i1I
 if 87 - 87: I1I - i1I . i1 * Oo
 if 90 - 90: i1I1 * i1I . Ii
 if 45 - 45: IiIIii11Ii - I11iiIi11i1I . i1iiIII111 * Ooo0Ooo . IIiIIiIi11I1
 if 14 - 14: iI1iII1I1I1i + OooOoo * I1Ii1I1 - I11iiIi11i1I
 if 84 - 84: oOO % iI1iII1I1I1i - Ooo0Ooo
 if 94 - 94: i1iiIII111 + i1i1i1111I / iI1iII1I1I1i + iI1iII1I1I1i / i1I
 if 79 - 79: i1iiIII111 - IIiIIiIi11I1 . I1Ii1I1 + I1I - ooOOO + i1iiIII111
 if 36 - 36: ooOOO * Iii1i % I1I % i1 . Ooo0Ooo
 if 63 - 63: IIiIIiIi11I1 / IIiIIiIi11I1 * Iii1i - oOo0O00 . i1
 if 52 - 52: oOo0O00 / i1I * IIiIIiIi11I1 + I11iiIi11i1I % Ooo0Ooo + oOO
 if 43 - 43: iI1iII1I1I1i * oOo0O00 + ooOOO
 if 30 - 30: I1I
 if 41 - 41: oOO
 if 98 - 98: I1I / IIiIIiIi11I1 / i1I + i1I1 % Oo + I1I
 if 38 - 38: I1Ii1I1 + oOo0O00
 if 2 - 2: OooOoo % Ii + oOO . OooOoo + IIiIIiIi11I1 * Oo
 if 2 - 2: IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + ooOOO . IIiIIiIi11I1
 if 15 - 15: ooo000
 if 63 - 63: i1I
 if 81 - 81: OooOoo . i1I / i1i1i1111I + Oo / Ooo0Ooo % i1I1
 if 77 - 77: I11iiIi11i1I / iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % oOo0O00
 if 73 - 73: i1I1 . Oo * I1I / i1i1i1111I + I1Ii1I1
 if 31 - 31: i1i1i1111I % I1Ii1I1
 if 1 - 1: i1I1 - oOo0O00 - i1 . oOo0O00
 if 91 - 91: iI1iII1I1I1i * i1 . ooOOO
 if 81 - 81: I1I * Oo - i1 % OooOoo * ooOOO
 if 19 - 19: Ii
 if 22 - 22: i1I % iI1iII1I1I1i + Oo
 if 60 - 60: ooo000 + I11iiIi11i1I + IIiIIiIi11I1 % i1i1i1111I - Ii % Ooo0Ooo
 if 95 - 95: ooOOO % i1i1i1111I . i1
 if 87 - 87: Iii1i % ooOOO * Ii % IIiIIiIi11I1 / I11iiIi11i1I
 if 84 - 84: I1Ii1I1 + Ooo0Ooo % IIiIIiIi11I1 * i1i1i1111I
 if 61 - 61: i1iiIII111 - Oo + I1Ii1I1
 if 43 - 43: IIiIIiIi11I1 * ooo000 + Ii % iI1iII1I1I1i
 if 12 - 12: i1iiIII111 + ooo000 . I11iiIi11i1I
 if 1 - 1: iI1iII1I1I1i % Ii - I11iiIi11i1I / i1I1 + iI1iII1I1I1i - Ii
 if 27 - 27: OooOoo % iI1iII1I1I1i + IIiIIiIi11I1
 if 16 - 16: i1I1
 if 31 - 31: oOo0O00 / Iii1i % Ooo0Ooo % i1 . iI1iII1I1I1i . Oo
 if 83 - 83: oOo0O00 - I11iiIi11i1I
 if 91 - 91: IIiIIiIi11I1 - i1 - iI1iII1I1I1i
 if 71 - 71: I1I - i1I1
 if 66 - 66: i1i1i1111I / Ooo0Ooo + I11iiIi11i1I + Iii1i + oOo0O00 + i1I
 if 75 - 75: OooOoo - oOO - IiIIii11Ii - oOO + ooo000 % iI1iII1I1I1i
 if 42 - 42: i1 * i1I
 if 50 - 50: Ii - i1iiIII111
 if 96 - 96: ooo000 * OooOoo - Ii - OooOoo
 if 65 - 65: Oo + Oo - iI1iII1I1I1i % OooOoo . Ooo0Ooo
 if 84 - 84: IIiIIiIi11I1 . ooOOO
 if 44 - 44: ooo000 * i1i1i1111I * oOO + i1iiIII111 - IIiIIiIi11I1
 if 70 - 70: i1I1
 if 9 - 9: oOo0O00 * i1
 if 96 - 96: Ooo0Ooo
 if 13 - 13: Oo * I1Ii1I1 - oOo0O00 * Ii . Ii + oOo0O00
 if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
 if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
 if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
 if 37 - 37: I1Ii1I1 % iI1iII1I1I1i . i1I + Ooo0Ooo + ooOOO * iI1iII1I1I1i
 if 39 - 39: IIiIIiIi11I1 - Oo
 if 31 - 31: IiIIii11Ii % oOo0O00 % oOo0O00 * Iii1i
 if 85 - 85: Iii1i + Ii % IIiIIiIi11I1 % oOo0O00
 if 100 - 100: IiIIii11Ii % i1
 if 82 - 82: ooOOO % OooOoo
 if 81 - 81: Ii
 if 40 - 40: i1I . OooOoo + oOo0O00 . i1iiIII111
 if 96 - 96: I1I / oOO / I11iiIi11i1I + I11iiIi11i1I
 if 35 - 35: IIiIIiIi11I1 + oOo0O00
 if 96 - 96: iI1iII1I1I1i . OooOoo . i1
 if 87 - 87: ooo000 * IiIIii11Ii % ooo000 . ooOOO . Oo % iI1iII1I1I1i
 if 48 - 48: ooOOO * ooo000 % IiIIii11Ii * i1 . Iii1i - i1I1
 if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
 with vwAppConfigParam . application . app_context ( ) :
  if 90 - 90: Ooo0Ooo * OooOoo . Ii
  if 5 - 5: Oo - i1 . oOO
  if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
  if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
  if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
  if 51 - 51: Oo / i1i1i1111I - I1I
  if 83 - 83: Iii1i % i1iiIII111 . OooOoo / I1I % oOO . I1I
  if 76 - 76: i1iiIII111 / OooOoo
  if 77 - 77: ooOOO
  if 19 - 19: ooOOO % I1Ii1I1
  if 15 - 15: OooOoo . IiIIii11Ii . i1I / Iii1i + ooOOO / Ii
  if 17 - 17: I11iiIi11i1I - i1i1i1111I . iI1iII1I1I1i - I11iiIi11i1I + Oo % iI1iII1I1I1i
  if 65 - 65: Ii % I11iiIi11i1I
  vwAppConfig . setcontrollerdoorChangeTime ( )
  OooOOO0oO0Oo ( )
  if 11 - 11: OooOoo % OooOoo . ooOOO
  if 80 - 80: oOO % i1iiIII111 * i1I1 - oOo0O00 % I11iiIi11i1I - i1I1
  if 56 - 56: Oo
  if 84 - 84: I1I % iI1iII1I1I1i - Ooo0Ooo / iI1iII1I1I1i + Ooo0Ooo - Oo
  O0OOo0O = time . time ( ) + 5
  while True :
   if 9 - 9: i1i1i1111I
   try :
    I11 = iIi . get ( block = False )
    if I11 :
     oo000O0oOO ( I11 )
     iIi . task_done ( )
   except Exception as o0OOo0 :
    pass
    if 65 - 65: IIiIIiIi11I1 / i1
    if 14 - 14: IiIIii11Ii % ooOOO . i1I
    if 29 - 29: i1I1 % oOO % i1I1 . ooOOO
   time . sleep ( 0.1 )
   if 4 - 4: oOo0O00 + i1iiIII111
   if time . time ( ) > O0OOo0O :
    O0OOo0O = time . time ( ) + 5
    OooOOO0oO0Oo ( )
    oo00 ( )
    if 52 - 52: OooOoo
    if 95 - 95: i1i1i1111I . I11iiIi11i1I * ooo000 / iI1iII1I1I1i - I1Ii1I1 + IiIIii11Ii
def background_backup_db ( ) :
 with vwAppConfigParam . application . app_context ( ) :
  O0OOo0O = time . time ( ) + 5 * 60
  while True :
   if 40 - 40: i1I + i1i1i1111I % OooOoo . i1I1 / i1i1i1111I . ooOOO
   O0OOOo0oO = time . time ( )
   o000O0 = time . localtime ( O0OOOo0oO )
   if time . time ( ) > O0OOo0O :
    O0OOo0O = time . time ( ) + 5 * 60
    if 3 == o000O0 . tm_hour :
     O0OOo0O = time . time ( ) + 2 * 60 * 60
     try :
      if vwAppConfigParam . bmysql :
       pass
       if 86 - 86: i1 . i1I1 - Ii
       if 1 - 1: I1I + OooOoo
       if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
      else :
       if 96 - 96: OooOoo / oOO - i1 * I11iiIi11i1I
       if 72 - 72: i1i1i1111I + Ii - Iii1i - i1i1i1111I - i1I + Ooo0Ooo
       if 74 - 74: Ooo0Ooo * Oo + Iii1i - i1iiIII111
       if 22 - 22: IiIIii11Ii - Ooo0Ooo . i1 . i1I - ooo000
       I1IiIi = vwAppConfigParam . wgcloudpathdir
       i1iII11iii = vwAppConfigParam . wgcloudpathdir [ 0 : - 1 ]
       Ii1i1 = i1iII11iii
       if str ( platform . system ( ) . lower ( ) ) == 'windows' :
        I1IiIi = '{}\\db\\sql3iccard.db' . format ( i1iII11iii )
        if 10 - 10: IIiIIiIi11I1 * iI1iII1I1I1i
        OOoOoOO0OO0o ( '{}\\db' . format ( i1iII11iii ) )
       else :
        I1IiIi = '{}/db/sql3iccard.db' . format ( i1iII11iii )
        OOoOoOO0OO0o ( '{}/db' . format ( i1iII11iii ) )
        if 46 - 46: oOo0O00 . iI1iII1I1I1i - Ii . oOo0O00 + i1i1i1111I
       import shutil
       try :
        if 83 - 83: i1I1
        if 77 - 77: iI1iII1I1I1i - oOO % Ii * i1I - I1I
        if 42 - 42: I11iiIi11i1I - Ii / Oo - i1i1i1111I + I11iiIi11i1I
        shutil . copyfile ( I1IiIi , I1IiIi [ 0 : len ( I1IiIi ) - 3 ] + (
 datetime . datetime . now ( ) . strftime (
 "%Y%m%d_%H%M%S" ) ) + "_auto" + ".bak" )
       except Exception as i1II1 :
        print ( i1II1 )
        if 67 - 67: IiIIii11Ii / oOo0O00 + Ooo0Ooo - i1I1 + Ii
        if 81 - 81: i1i1i1111I + Oo + ooo000 % ooOOO + i1I1 * OooOoo
        if 43 - 43: i1I
        if 85 - 85: oOo0O00 + ooo000
     except Exception as o0OOo0 :
      pass
      if 17 - 17: i1i1i1111I * oOO + i1iiIII111 - I11iiIi11i1I / i1i1i1111I
      if 83 - 83: I11iiIi11i1I - Iii1i + oOo0O00 + I1I / IIiIIiIi11I1 + I1I
   time . sleep ( 5 * 60 )
   if 29 - 29: i1i1i1111I / oOo0O00
   if 13 - 13: I11iiIi11i1I % i1iiIII111 . OooOoo % ooo000 % OooOoo
   if 21 - 21: i1I1 * I1Ii1I1
   if 93 - 93: Ooo0Ooo . i1 + i1I1 - oOo0O00
def oo00 ( ) :
 if int ( datetime . datetime . now ( ) . timestamp ( ) ) > vwAppConfigParam . nexttimeClearAllFaceLog :
  vwAppConfigParam . nexttimeClearAllFaceLog = int ( datetime . datetime . now ( ) . timestamp ( ) ) + 3600 * 24 * 30
  ooOOoO00OO = TBThirdpartynetdevice . query
  O0Ooo0oOo0 = ooOOoO00OO . all ( )
  if O0Ooo0oOo0 :
   Oo00oOooOO = [ ]
   for IiI in O0Ooo0oOo0 :
    ooO0OoOo = IiI . f_DeviceIP
    Oo00oOooOO . append ( ooO0OoOo )
    if 48 - 48: i1iiIII111 . Oo
   ooOO = {
 "jsonrpc" : "2.0" ,
 "method" : "ExternFunctions" ,
 "params" : [
 {
 "FunctionName" : "ClearFaceReaderLog" ,
 "FaceReaderIP" : Oo00oOooOO
 }
 ] ,
 "id" : 4001
 }
   vwAppConfig . vwlog ( "Clear FaceReader Log: {0}" . format ( Oo00oOooOO ) )
   I1iiiIii1 = vwAppConfig . sendByHttpWithMsg ( ooOO )
   if 94 - 94: Ooo0Ooo % oOo0O00 . oOo0O00 / Ii . i1
   if 54 - 54: iI1iII1I1I1i % Oo . i1I1 - Iii1i % I11iiIi11i1I * i1I
   if 31 - 31: oOo0O00 / Iii1i - IiIIii11Ii % i1I / I1Ii1I1 - i1i1i1111I
   if 68 - 68: I11iiIi11i1I . I11iiIi11i1I % I11iiIi11i1I
   if 71 - 71: ooo000
   if 61 - 61: ooo000
   if 48 - 48: Iii1i * i1i1i1111I + IiIIii11Ii
   if 31 - 31: Oo * i1iiIII111 % Ii / oOO + I1Ii1I1 + iI1iII1I1I1i
   if 90 - 90: I1Ii1I1 * i1i1i1111I / iI1iII1I1I1i * Ii
   if 38 - 38: I1I . Ii
   if 41 - 41: ooo000 % IIiIIiIi11I1 % ooOOO
   if 5 - 5: oOo0O00 / Ii + i1iiIII111 * Oo + Ooo0Ooo + ooo000
   if 96 - 96: i1iiIII111 - IIiIIiIi11I1 / IIiIIiIi11I1 * IiIIii11Ii
   if 67 - 67: Ooo0Ooo . Ooo0Ooo . i1I1
   if 24 - 24: i1iiIII111 + i1i1i1111I . oOo0O00 + iI1iII1I1I1i + i1I1
   if 92 - 92: iI1iII1I1I1i / iI1iII1I1I1i + IiIIii11Ii . i1I1
   if 56 - 56: Ii * ooo000 . IiIIii11Ii
   if 66 - 66: I1Ii1I1 * OooOoo . iI1iII1I1I1i % OooOoo . i1 . IiIIii11Ii
   if 47 - 47: Ii % OooOoo % iI1iII1I1I1i * IiIIii11Ii
   if 48 - 48: i1I . I11iiIi11i1I / ooo000 + i1iiIII111
   if 84 - 84: Oo / I1Ii1I1 . IIiIIiIi11I1
   if 67 - 67: Oo % ooOOO + iI1iII1I1I1i * I1I
   if 79 - 79: IIiIIiIi11I1 * Oo / OooOoo
   if 10 - 10: iI1iII1I1I1i / i1iiIII111 . IiIIii11Ii * i1i1i1111I
   if 71 - 71: oOo0O00 + I1Ii1I1 / I11iiIi11i1I + Oo / I1I
   if 18 - 18: Iii1i - IiIIii11Ii
   if 71 - 71: iI1iII1I1I1i + OooOoo % i1i1i1111I % oOo0O00 . ooo000
   if 92 - 92: I11iiIi11i1I - Ooo0Ooo - i1i1i1111I % i1iiIII111 / i1i1i1111I * iI1iII1I1I1i
   if 60 - 60: IiIIii11Ii % oOO / i1I * OooOoo / I11iiIi11i1I - Ii
   if 16 - 16: oOo0O00 / I1Ii1I1 / i1 + I11iiIi11i1I + oOo0O00
   if 11 - 11: oOO / OooOoo + oOo0O00
   if 79 - 79: I11iiIi11i1I . I1Ii1I1 * i1I % I1Ii1I1 / i1I1
   if 93 - 93: i1I + Iii1i . Ii . i1I * ooOOO
   if 84 - 84: Ooo0Ooo % i1I1
   if 82 - 82: IIiIIiIi11I1
   if 81 - 81: oOo0O00 + i1 - ooo000 * iI1iII1I1I1i + i1i1i1111I
   if 89 - 89: I1Ii1I1
   if 57 - 57: iI1iII1I1I1i - i1iiIII111 / OooOoo % i1iiIII111
   if 92 - 92: IiIIii11Ii * OooOoo - IiIIii11Ii
   if 66 - 66: i1iiIII111 . iI1iII1I1I1i / ooOOO . i1 - OooOoo
   if 13 - 13: oOo0O00
   if 50 - 50: i1 - i1iiIII111 / i1iiIII111 % I1Ii1I1 / IIiIIiIi11I1
   if 66 - 66: oOo0O00 - Iii1i - ooo000 . I11iiIi11i1I
   if 59 - 59: i1I / IiIIii11Ii
   if 7 - 7: oOo0O00
   if 64 - 64: IIiIIiIi11I1 * oOO + Oo . OooOoo - ooOOO
   if 94 - 94: IiIIii11Ii - ooo000 . Ii
   if 73 - 73: IiIIii11Ii / oOo0O00 % ooo000 . iI1iII1I1I1i % oOO
   if 36 - 36: i1I1 * OooOoo . ooo000 . i1iiIII111 + oOO
   if 47 - 47: i1I1 / I11iiIi11i1I
   if 52 - 52: Ii . OooOoo . i1iiIII111 * I11iiIi11i1I - iI1iII1I1I1i
   if 20 - 20: OooOoo % i1I1 + I1Ii1I1 + i1I1 - oOo0O00
   if 76 - 76: I11iiIi11i1I % IIiIIiIi11I1 % i1I
   if 39 - 39: IiIIii11Ii . Oo + i1I - oOo0O00
   if 93 - 93: Iii1i * IIiIIiIi11I1 % i1I + i1 % Ii * i1I
   if 62 - 62: i1I1 % ooo000
   if 19 - 19: Ii / Oo % Iii1i / i1iiIII111 - OooOoo - Ooo0Ooo
   if 89 - 89: I11iiIi11i1I - i1I1
   if 61 - 61: Ii * OooOoo * I1I % i1iiIII111 % IIiIIiIi11I1 * I11iiIi11i1I
   if 49 - 49: iI1iII1I1I1i / i1iiIII111 % oOO
   if 46 - 46: ooOOO * IIiIIiIi11I1 % i1 / oOO + i1 + oOo0O00
   if 99 - 99: I1I * IIiIIiIi11I1 * i1iiIII111
   if 62 - 62: ooOOO % Oo + i1I
   if 87 - 87: ooo000 - OooOoo + Ii + i1i1i1111I + IiIIii11Ii
   if 57 - 57: IIiIIiIi11I1 + I1I / ooOOO % ooOOO % Oo / i1I1
   if 95 - 95: i1 / I11iiIi11i1I . i1 / Oo . Ooo0Ooo
   if 43 - 43: Oo - OooOoo * oOO . Ooo0Ooo / IIiIIiIi11I1 * IIiIIiIi11I1
   if 84 - 84: i1iiIII111 + oOo0O00
   if 83 - 83: i1i1i1111I
   if 84 - 84: oOO / Ii * Ooo0Ooo / Ii / ooo000
   if 64 - 64: oOo0O00 * Ii
   if 2 - 2: i1I1 % i1iiIII111 . oOo0O00
   if 59 - 59: I11iiIi11i1I % OooOoo - iI1iII1I1I1i % I1I + i1iiIII111 . I1Ii1I1
   if 94 - 94: ooOOO * I1Ii1I1 * i1iiIII111 . oOo0O00
   if 73 - 73: I1Ii1I1 / ooo000 % I11iiIi11i1I - i1i1i1111I + Oo - I1Ii1I1
   if 18 - 18: i1 + ooOOO . i1 - iI1iII1I1I1i
   if 97 - 97: oOo0O00 + i1I % Iii1i
   if 34 - 34: i1 + Oo . oOo0O00 - ooo000 / I11iiIi11i1I * oOo0O00
   if 89 - 89: oOo0O00
   if 48 - 48: i1 / IIiIIiIi11I1 / iI1iII1I1I1i / i1I1 * IiIIii11Ii
   if 54 - 54: IIiIIiIi11I1 % I1I % i1I1 / I11iiIi11i1I . I11iiIi11i1I - IiIIii11Ii
   if 10 - 10: Ii . I11iiIi11i1I % i1I / OooOoo % I1Ii1I1
   if 42 - 42: Oo - I1I * i1I * i1i1i1111I - I11iiIi11i1I
   if 58 - 58: iI1iII1I1I1i
   if 17 - 17: iI1iII1I1I1i - Ii % iI1iII1I1I1i % oOo0O00 * Iii1i
   if 51 - 51: I1I . i1i1i1111I % Ii
   if 55 - 55: i1i1i1111I * Ii % i1i1i1111I
   if 61 - 61: oOo0O00
   if 53 - 53: Ooo0Ooo / IiIIii11Ii
   if 49 - 49: ooo000 - oOO . IiIIii11Ii / Oo
   if 23 - 23: I11iiIi11i1I - i1 / Iii1i . iI1iII1I1I1i + oOO
   if 55 - 55: i1 - iI1iII1I1I1i / OooOoo + I1I + Oo
   if 5 - 5: i1I1 - i1 . i1i1i1111I / i1I1 . iI1iII1I1I1i . i1I1
   if 87 - 87: i1 . Ii * iI1iII1I1I1i - oOO / Ii / OooOoo
   if 65 - 65: i1I / i1I + i1I1
import os
import glob
if 99 - 99: i1 + OooOoo + I11iiIi11i1I * Ooo0Ooo / ooOOO + Ii
if 72 - 72: I1Ii1I1 * Ooo0Ooo * IIiIIiIi11I1 % IiIIii11Ii . ooo000
def OOoOoOO0OO0o ( directory = "db" , suffix = "_auto.bak" , max_files = 15 , files_to_delete = 5 ) :
 try :
  if 68 - 68: Ooo0Ooo * OooOoo - oOo0O00
  if 49 - 49: IIiIIiIi11I1 % i1
  if 29 - 29: OooOoo * Ii - oOO
  if 53 - 53: I11iiIi11i1I % ooo000 / ooOOO / I1I
  if 43 - 43: iI1iII1I1I1i . i1i1i1111I + I1I % ooOOO . i1I1 - i1I1
  if 6 - 6: I1I
  if 98 - 98: oOO * IIiIIiIi11I1 / i1iiIII111 / Iii1i + I1I
  if 25 - 25: IIiIIiIi11I1 . i1I1 / I1I * i1 - i1iiIII111 % oOo0O00
  if 49 - 49: IiIIii11Ii % ooOOO + I11iiIi11i1I + IIiIIiIi11I1
  if 60 - 60: IIiIIiIi11I1
  if not os . path . exists ( directory ) or not os . path . isdir ( directory ) :
   print ( "Error: Directory '{0}' does not exist or is not a directory.  " . format ( directory ) )
   return False
   if 98 - 98: IiIIii11Ii / Ooo0Ooo + Ii
   if 73 - 73: OooOoo * Iii1i
  OooOoO = os . path . join ( directory , "*{0}" . format ( suffix ) )
  I11III111I = glob . glob ( OooOoO )
  if 59 - 59: IiIIii11Ii * I1Ii1I1
  print ( "Found {0} matching '*{1}' files in directory '{2}'.  " . format ( len ( I11III111I ) , suffix , directory ) )
  if 18 - 18: IIiIIiIi11I1 % oOO / Ii * Ii % Ii . Iii1i
  if 53 - 53: i1 * i1i1i1111I
  if len ( I11III111I ) <= max_files :
   print ( "Current file count {0} does not exceed the limit {1}; no deletion required.  " . format ( len ( I11III111I ) , max_files ) )
   return True
   if 91 - 91: I1I . I11iiIi11i1I
   if 59 - 59: i1I1 . i1I1 * IIiIIiIi11I1
  o0 = [ ]
  for o0O0 in I11III111I :
   try :
    if 90 - 90: I1Ii1I1 - Oo . OooOoo % I1I / I11iiIi11i1I % ooOOO
    OoOOO0o0 = os . path . getmtime ( o0O0 )
    if 29 - 29: i1i1i1111I * Ii * i1i1i1111I
    O0Oo0o0o = os . path . getsize ( o0O0 )
    o0 . append ( {
 'path' : o0O0 ,
 'mtime' : OoOOO0o0 ,
 'size' : O0Oo0o0o ,
 'filename' : os . path . basename ( o0O0 )
 } )
   except OSError as I1I1i1ii :
    print ( "Unable to retrieve information for file {0}: {1}.  " . format ( o0O0 , I1I1i1ii ) )
    continue
    if 28 - 28: IIiIIiIi11I1 % Ii + ooOOO . i1I % Ii * I1Ii1I1
    if 41 - 41: I1I
  o0 . sort ( key = lambda IIi : IIi [ 'mtime' ] )
  if 73 - 73: ooo000 % oOO
  print (
 "File count {0} exceeds the limit {1}. The earliest file will be retained, and the next earliest {2} files will be deleted.  " . format ( len ( I11III111I ) , max_files , files_to_delete ) )
  if 43 - 43: OooOoo * i1i1i1111I * IiIIii11Ii % Ii
  if 13 - 13: i1i1i1111I / i1I1 + i1I1 % ooo000
  if len ( o0 ) > 0 :
   oOOOoO0OOo00 = o0 [ 0 ]
   print ( "Retaining the earliest file: {0} (modified time: {1}).  " . format ( oOOOoO0OOo00 [ 'filename' ] , oOOOoO0OOo00 [ 'mtime' ] ) )
   if 85 - 85: i1I1 . i1 + i1i1i1111I * i1i1i1111I
   if 35 - 35: OooOoo - ooo000
  Ooo = min ( files_to_delete , len ( o0 ) - 1 )
  OOooooO = o0 [ 1 : 1 + Ooo ]
  if 58 - 58: I11iiIi11i1I % Oo - i1i1i1111I . oOO + i1i1i1111I
  if len ( OOooooO ) == 0 :
   print ( "No next earliest files available for deletion.  " )
   return True
   if 77 - 77: ooo000 + oOo0O00 . ooo000 - oOO . i1
  print ( "List of next earliest files to be deleted:  " )
  for IiII , OooO in enumerate ( OOooooO , 1 ) :
   print ( "  {0}. {1} (modified time: {2}, size: {3} bytes)  " . format ( IiII , OooO [ 'filename' ] , OooO [ 'mtime' ] , OooO [ 'size' ] ) )
   if 36 - 36: IIiIIiIi11I1 + IiIIii11Ii . i1 + IIiIIiIi11I1
   if 77 - 77: iI1iII1I1I1i / OooOoo . Iii1i + i1iiIII111 - i1I1
  OOO00oOO0 = 0
  for OooO in OOooooO :
   try :
    os . remove ( OooO [ 'path' ] )
    print ( "✓ Deleted: {0}.  " . format ( OooO [ 'filename' ] ) )
    OOO00oOO0 += 1
   except OSError as I1I1i1ii :
    print ( "✗ Deletion failed: {0} - Error: {1}.  " . format ( OooO [ 'filename' ] , I1I1i1ii ) )
    if 89 - 89: i1iiIII111 - I1Ii1I1
  O000O0 = len ( I11III111I ) - OOO00oOO0
  print ( "Operation completed: {0} files deleted, {1} files remaining.  " . format ( OOO00oOO0 , O000O0 ) )
  if 32 - 32: ooOOO - IiIIii11Ii - Oo
  return True
  if 73 - 73: oOO % I1Ii1I1
 except Exception as I1I1i1ii :
  print ( "An error occurred during execution: {0}.  " . format ( I1I1i1ii ) )
  return False
  if 88 - 88: iI1iII1I1I1i . I1I * oOo0O00 - i1i1i1111I * Ooo0Ooo
  if 87 - 87: oOo0O00 / ooOOO / OooOoo * Ooo0Ooo
  if 49 - 49: iI1iII1I1I1i
  if 77 - 77: ooo000 % I11iiIi11i1I % Ooo0Ooo * oOO
  if 5 - 5: oOO * i1i1i1111I % Oo
  if 99 - 99: IiIIii11Ii * I1Ii1I1
  if 83 - 83: i1I . ooo000 * Ooo0Ooo + Iii1i . Oo
  if 34 - 34: I11iiIi11i1I % oOO
  if 75 - 75: i1 % IiIIii11Ii - iI1iII1I1I1i - i1I * I11iiIi11i1I * OooOoo
  if 45 - 45: IIiIIiIi11I1
  if 14 - 14: i1i1i1111I - OooOoo . IiIIii11Ii
  if 40 - 40: I1I - IIiIIiIi11I1 % IiIIii11Ii
  if 61 - 61: iI1iII1I1I1i
  if 93 - 93: i1iiIII111 - oOo0O00 . Oo . i1iiIII111 . Oo * I1Ii1I1
  if 95 - 95: I1Ii1I1 % oOO
  if 21 - 21: Ooo0Ooo % i1 - ooo000
  if 81 - 81: Ooo0Ooo / ooo000
  if 4 - 4: I1I % i1I - ooo000 - I1I . ooOOO / i1i1i1111I
  if 74 - 74: oOO
  if 24 - 24: I1I + Oo - ooOOO
  if 86 - 86: i1iiIII111 % ooo000 % ooo000 % i1I
  if 15 - 15: iI1iII1I1I1i + I1Ii1I1 % oOo0O00
  if 79 - 79: OooOoo . Oo + oOo0O00 / I1Ii1I1 . IiIIii11Ii
  if 89 - 89: ooo000 % Ooo0Ooo
  if 77 - 77: ooo000 % Ooo0Ooo
  if 24 - 24: oOO * I1Ii1I1 * I1Ii1I1 % IIiIIiIi11I1
  if 37 - 37: i1iiIII111 / iI1iII1I1I1i
def II ( doorDst ) :
 if 18 - 18: oOO - I11iiIi11i1I
 OOO0OOoo0ooO = WGControllerCenter2023 ( )
 if 5 - 5: oOO / I1Ii1I1 + iI1iII1I1I1i
 ooO0O0o0O0o = ""
 for IiI in doorDst :
  ooO0O0o0O0o += str ( IiI ) + ","
 ooO0O0o0O0o += '0'
 if 55 - 55: i1
 oOOoOooo0 ( )
 if 76 - 76: i1I1 + Ooo0Ooo * i1I1 / I1I / Ii / i1I
 ooOOoO00OO = db . session . query ( TBController . f_ControllerID , TBController . f_ControllerSN , TBDoor . f_DoorNO ,
 TBDoor . f_DoorID ) . join ( TBDoor ,
 TBDoor . f_ControllerID == TBController . f_ControllerID )
 O0oO0OO0O00 = ooOOoO00OO . all ( )
 if 13 - 13: Ii - ooOOO
 for IiI in O0oO0OO0O00 :
  ooO0OoOo = IiI . f_ControllerSN
  ii1Ii = IiI . f_DoorNO
  if 98 - 98: IIiIIiIi11I1 - i1I / ooOOO * Ooo0Ooo * iI1iII1I1I1i - i1i1i1111I
  if ooO0OoOo not in OOO0OOoo0ooO . getswipeSN :
   if IiI . f_DoorID in doorDst :
    I1I1IIII1i = IiI . f_ControllerID
    OOO0OOoo0ooO . getswipeSN . append ( ooO0OoOo )
    I11Ii1IiIiII = threading . Thread ( target = checkConnectedSingle , args = ( ooO0OoOo , I1I1IIII1i , OOO0OOoo0ooO ) )
    I11Ii1IiIiII . start ( )
 O00o0OO = time . time ( )
 while time . time ( ) < O00o0OO + 10 :
  if len ( OOO0OOoo0ooO . getswipeSNConnectedOK ) + len ( OOO0OOoo0ooO . getswipeSNFailed ) == len ( OOO0OOoo0ooO . getswipeSN ) :
   break
  time . sleep ( 0.1 )
  if 88 - 88: Ii
  if 13 - 13: Iii1i - I1Ii1I1 . iI1iII1I1I1i - Ooo0Ooo . OooOoo / oOo0O00
 I1Io00ooO0 = 0
 if 40 - 40: i1 * i1i1i1111I - Oo * I1I . i1i1i1111I - OooOoo
 if 76 - 76: iI1iII1I1I1i % Iii1i
 if 2 - 2: Oo + OooOoo - i1i1i1111I - ooo000 / Oo . Oo
 if 41 - 41: OooOoo + OooOoo - OooOoo
 if len ( OOO0OOoo0ooO . getswipeSNConnectedOK ) > 0 :
  for IiII in range ( len ( OOO0OOoo0ooO . getswipeSNConnectedOK ) ) :
   I1I1IIII1i = OOO0OOoo0ooO . getswipeIdConnectedOK [ IiII ]
   ooO0OoOo = OOO0OOoo0ooO . getswipeSNConnectedOK [ IiII ]
   if 9 - 9: Iii1i % I1Ii1I1 % IiIIii11Ii - I1I * OooOoo
   Ooooo = - 1
   OOooO0oo = TDSwiperecord2022 . query . filter_by ( f_ControllerSN = ooO0OoOo ) . order_by (
 TDSwiperecord2022 . f_RecID . desc ( ) ) . first ( )
   oOo000o0OO0o = None
   if OOooO0oo :
    if 31 - 31: Oo - IIiIIiIi11I1 / i1I1 * i1i1i1111I
    if 68 - 68: IiIIii11Ii
    Ooooo = OOooO0oo . f_RecordFlashLoc - 1
    oOo000o0OO0o = OOooO0oo . f_ReadDate
    oOOOo0O0O0oOO . arrf_RecordFlashLocmax [ ooO0OoOo ] = OOooO0oo . f_RecordFlashLoc
    if 41 - 41: i1I - Ooo0Ooo
    if 47 - 47: I1Ii1I1 * i1i1i1111I - i1I . Iii1i . ooOOO
    if 28 - 28: Ii
    if 51 - 51: I11iiIi11i1I + Ooo0Ooo - ooo000 * oOO . oOO
    if 79 - 79: i1i1i1111I + oOo0O00
    if 11 - 11: OooOoo / i1iiIII111 % i1I - i1i1i1111I * oOo0O00
    if 90 - 90: i1 * i1 . Ooo0Ooo . Oo
    if 59 - 59: Ii % I1Ii1I1 + Iii1i . OooOoo * Iii1i
    if 21 - 21: I11iiIi11i1I + ooOOO % IiIIii11Ii / OooOoo
    if 96 - 96: Oo * i1iiIII111 . Ooo0Ooo
    if 35 - 35: ooOOO . i1I * i1i1i1111I * iI1iII1I1I1i - I11iiIi11i1I
    if 47 - 47: IIiIIiIi11I1
   I11Ii1IiIiII = threading . Thread ( target = IIi1 , args = ( ooO0OoOo , I1I1IIII1i , OOO0OOoo0ooO , Ooooo , oOo000o0OO0o ) )
   I11Ii1IiIiII . start ( )
   if 87 - 87: i1 . I11iiIi11i1I * Ii . i1 . IIiIIiIi11I1 . IiIIii11Ii
   if 50 - 50: Ii / oOO
   if 92 - 92: Ooo0Ooo * i1iiIII111 / Ooo0Ooo / i1iiIII111 * i1i1i1111I + i1I
   if 48 - 48: I11iiIi11i1I
   if 87 - 87: I1Ii1I1
   if 29 - 29: ooo000 . iI1iII1I1I1i . oOo0O00 + i1i1i1111I + oOO
   if 59 - 59: IiIIii11Ii
   if 26 - 26: oOo0O00 % i1I1 * i1
   if 60 - 60: IIiIIiIi11I1 % oOO / i1
 iii1I11i = time . time ( ) + vwAppConfigParam . uploadpri_timeout_second + ( I1Io00ooO0 / 1000 ) * 2
 while time . time ( ) < iii1I11i :
  if len ( OOO0OOoo0ooO . recvsn ) > 0 :
   OOO0OOoo0ooO . recvsn . clear ( )
   if 43 - 43: ooo000
   o0oOO = time . time ( ) + vwAppConfigParam . uploadpri_timeout_second
   if o0oOO > iii1I11i :
    iii1I11i = o0oOO
  if len ( OOO0OOoo0ooO . arrswipe ) == 0 :
   if len ( OOO0OOoo0ooO . getswipeSNOK ) + len ( OOO0OOoo0ooO . getswipeSNFailed ) == len ( OOO0OOoo0ooO . getswipeSN ) :
    break
   time . sleep ( 0.1 )
  while len ( OOO0OOoo0ooO . arrswipe ) > 0 :
   if 8 - 8: ooOOO * i1i1i1111I
   IiI = OOO0OOoo0ooO . arrswipe . pop ( )
   iI1II1i1i1 ( IiI [ 'sn' ] , IiI [ 'arrRecords' ] , oOOOo0O0O0oOO . arrusersByCardNO , oOOOo0O0O0oOO . arrdoorcontollersBySNDoor )
   if 18 - 18: i1i1i1111I - i1I % Ooo0Ooo . OooOoo * oOo0O00 / ooOOO
   if 41 - 41: i1iiIII111 * iI1iII1I1I1i + i1 + i1i1i1111I
   if 26 - 26: Oo % OooOoo
   if 14 - 14: iI1iII1I1I1i - i1iiIII111
   if 53 - 53: oOO
   if 46 - 46: oOo0O00 - iI1iII1I1I1i
 oo0 = [ ]
 oOoo0 = [ ]
 I1i1IIii = [ ]
 O00ooOoooo = [ ]
 for iiII in doorDst :
  ooO0O0o0O0o += str ( iiII ) + ","
  for IiI in O0oO0OO0O00 :
   ooO0OoOo = IiI . f_ControllerSN
   if 88 - 88: i1i1i1111I * i1I % i1i1i1111I + i1i1i1111I . iI1iII1I1I1i / OooOoo
   if 12 - 12: Ii . Ii - I1Ii1I1
   if iiII == IiI . f_DoorID :
    OoO0OoOoo = - 1
    try :
     OoO0OoOoo = OOO0OOoo0ooO . getswipeSNOK . index ( ooO0OoOo )
    except :
     OoO0OoOoo = - 1
     if 36 - 36: OooOoo - i1I1 . i1I1
    if OoO0OoOoo >= 0 :
     oo0 . append ( iiII )
     oOoo0 . append ( OOO0OOoo0ooO . getswipeSNRecordNum [ OoO0OoOoo ] )
    else :
     try :
      OoO0OoOoo = OOO0OOoo0ooO . getswipeSNConnectedOK . index ( ooO0OoOo )
     except :
      OoO0OoOoo = - 1
     if OoO0OoOoo < 0 :
      I1i1IIii . append ( iiII )
     else :
      O00ooOoooo . append ( iiII )
      if 79 - 79: oOo0O00 * IIiIIiIi11I1
 return { "doorID_OK" : oo0 , "doorID_GetSwipeNum" : oOoo0 ,
 "doorID_NotConnected" : I1i1IIii , "doorID_Fail" : O00ooOoooo }
 if 53 - 53: Ii - ooOOO . OooOoo - I1I - I11iiIi11i1I
 if 32 - 32: Iii1i % IiIIii11Ii - oOO - IiIIii11Ii - I11iiIi11i1I % i1iiIII111
def IIi1 ( sn , conid , wgcondata , iGotLastIndex , lastrecordtime ) :
 vwAppConfig . wglog ( "getswipeSingle4Realtime  sn={} conid={}  start" . format ( sn , conid ) )
 if 50 - 50: Iii1i / i1I1 + i1
 IIooo0 = 10
 if 31 - 31: Ii % i1I / ooo000
 if 46 - 46: i1 / i1I
 if 41 - 41: IiIIii11Ii * Iii1i % IiIIii11Ii * i1I % i1I / I1I
 if 64 - 64: I1Ii1I1 + Ii - Ii . i1I1 / i1
 if 3 - 3: Iii1i - i1I1 + OooOoo / I1Ii1I1 + i1iiIII111
 if 8 - 8: OooOoo
 if 76 - 76: Oo / IiIIii11Ii % IiIIii11Ii . ooo000 * Oo % i1iiIII111
 if 39 - 39: I1Ii1I1 / Ooo0Ooo * IIiIIiIi11I1
 if 84 - 84: oOO / i1I1 * IiIIii11Ii
 if 29 - 29: I1Ii1I1 % oOo0O00 - oOo0O00 * I1Ii1I1 / Iii1i * i1I
 if 51 - 51: I1Ii1I1 . i1iiIII111 % i1 % i1I * Oo
 if 64 - 64: i1i1i1111I + i1
 if 45 - 45: i1i1i1111I / i1iiIII111 * iI1iII1I1I1i
 if 2 - 2: i1 / i1i1i1111I * IiIIii11Ii
 if 33 - 33: Iii1i
 I1IiIIII1 = 1000
 o000ooOoo = 300000 / I1IiIIII1
 oOooOoO = 1
 iiI11I1iI1 = 0
 IiiI = False
 i11111I1 = 0
 OooO0 = 0
 oO = - 1
 Ooooo = - 1
 IIooo0 = 6000
 if 1 - 1: oOo0O00 . i1I1 * I1I - Oo
 i1Ii = [ ]
 oOOO0O = 0
 IIII = 0
 if 24 - 24: ooOOO . iI1iII1I1I1i - i1 + ooOOO
 Ooooo = iGotLastIndex
 if 73 - 73: OooOoo
 if 97 - 97: Oo * IiIIii11Ii . Ooo0Ooo % i1 % Ii % ooo000
 if 67 - 67: IIiIIiIi11I1 % i1 % oOo0O00 - i1i1i1111I
 if 51 - 51: I11iiIi11i1I . I11iiIi11i1I % i1I1 % Oo / I1Ii1I1 - I1Ii1I1
 if 28 - 28: Ii / Ooo0Ooo
 if 11 - 11: I1I - OooOoo * ooOOO % i1i1i1111I + ooo000 . oOO
 if 51 - 51: ooOOO + iI1iII1I1I1i % i1I1 . I11iiIi11i1I % Ooo0Ooo
 if 15 - 15: OooOoo / i1I % Oo % Oo
 if 73 - 73: oOo0O00
 if 69 - 69: ooOOO - IIiIIiIi11I1 - i1I
 if 78 - 78: I1Ii1I1 . ooo000 + i1I1 / i1I1
 if 88 - 88: Ii - i1iiIII111 - i1 * IIiIIiIi11I1 . IiIIii11Ii + Iii1i
 if 44 - 44: ooOOO + Oo - i1
 if 18 - 18: iI1iII1I1I1i * ooOOO + Ooo0Ooo
 if 78 - 78: I1I . I1I - IIiIIiIi11I1 - IiIIii11Ii % I11iiIi11i1I . I1Ii1I1
 if 9 - 9: I11iiIi11i1I * OooOoo - I11iiIi11i1I
 if 73 - 73: I1Ii1I1
 if 25 - 25: i1 . Ii
 if 59 - 59: IiIIii11Ii
 II1I1i1 = iGotLastIndex
 if 4 - 4: IIiIIiIi11I1 + i1I1
 while oOooOoO < o000ooOoo :
  oOooOoO = oOooOoO + 1
  o00OOoO00 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "DownloadSwipe" ,
 "params" : [
 {
 "ControllerSN" : sn ,
 "RecordNumberAtEveryTime" : 1000 ,
 "GotRecordLastIndex" : iGotLastIndex
 }
 ] ,
 "id" : 3001
 } )
  IIiii1i1iI1I1 = vwAppConfig . sendByHttpWithMsg ( o00OOoO00 , IIooo0 )
  if 3 - 3: IIiIIiIi11I1 . I1Ii1I1 / Iii1i % ooOOO / oOo0O00 % ooOOO
  if len ( IIiii1i1iI1I1 ) == 0 :
   IIII += 1
   print ( "{}Communication Failed --{}" . format ( sn , IIII ) )
   if IIII < 3 :
    continue
    if 55 - 55: iI1iII1I1I1i + I1I + oOo0O00 - I11iiIi11i1I
   break
  else :
   IIII = 0
   if 80 - 80: Oo % I11iiIi11i1I . IiIIii11Ii * oOO
   if vwAppConfig . successIsTrue ( IIiii1i1iI1I1 ) :
    OoOoOO0OOO00 = IIiii1i1iI1I1
    o0oo = vwAppConfig . parseInt ( OoOoOO0OOO00 [ "GetSwipeNumber" ] )
    Oo0o0OOOOOO0 = 0
    if II1I1i1 > 0 :
     if o0oo > 0 :
      if OoOoOO0OOO00 [ "RecordInformation" ] [ 0 ] [ 'RecordIndex' ] == II1I1i1 + 1 and vwAppConfig . getDateTimeFromStr ( OoOoOO0OOO00 [ "RecordInformation" ] [ 0 ] [ 'Time' ] ) == lastrecordtime :
       o0oo = o0oo - 1
       i11111I1 = II1I1i1 + 1
      else :
       II1I1i1 = 0
    if o0oo > 0 :
     i11111I1 = vwAppConfig . parseInt ( OoOoOO0OOO00 [ "LastSwipeIndex" ] )
     if 5 - 5: i1I * i1iiIII111 / i1 * oOO * IIiIIiIi11I1
     if 86 - 86: oOo0O00 % oOO / I1Ii1I1
     if 38 - 38: IIiIIiIi11I1
     if 17 - 17: oOO + i1iiIII111 / i1i1i1111I * IiIIii11Ii / oOo0O00 / Ooo0Ooo
     if 43 - 43: i1I + iI1iII1I1I1i + Oo
     if 61 - 61: i1I
     if 75 - 75: IIiIIiIi11I1 . I11iiIi11i1I / ooo000 . oOo0O00 % Ooo0Ooo
     if oO >= i11111I1 :
      i11111I1 = Ooooo
      if 7 - 7: I1I / i1iiIII111
      if 53 - 53: OooOoo - I1Ii1I1 + IIiIIiIi11I1 . I1Ii1I1 + i1iiIII111
      if 82 - 82: Iii1i
      vwAppConfig . wglog ( "DownloadSwipe Finished..." )
      IiiI = True
      break
     iiI11I1iI1 += o0oo
     if 58 - 58: I1Ii1I1 / I1Ii1I1 % IIiIIiIi11I1
     if 98 - 98: OooOoo
     if II1I1i1 > 0 :
      i1Ii . extend ( OoOoOO0OOO00 [ "RecordInformation" ] [ 1 : ] )
     else :
      i1Ii . extend ( OoOoOO0OOO00 [ "RecordInformation" ] )
     wgcondata . recvsn . append ( sn )
     print ( "sn={}, bFinished={}, newestIndex={}" . format ( sn , IiiI , i11111I1 ) )
     if 79 - 79: Ooo0Ooo * Ooo0Ooo - ooo000 - Iii1i
     Oo0o0OOOOOO0 = OoOoOO0OOO00 [ "RecordInformation" ] [ len ( OoOoOO0OOO00 [ "RecordInformation" ] ) - 1 ] [ "CardNO" ]
     Ooooo = OoOoOO0OOO00 [ "RecordInformation" ] [ len ( OoOoOO0OOO00 [ "RecordInformation" ] ) - 1 ] [ "RecordIndex" ]
     if 5 - 5: IiIIii11Ii / i1iiIII111 . I1I % Iii1i . i1
     if 29 - 29: oOo0O00 + Oo / I11iiIi11i1I - oOo0O00 % i1i1i1111I / Ii
     if 39 - 39: I11iiIi11i1I - I11iiIi11i1I % i1iiIII111
     if 56 - 56: i1iiIII111 / IiIIii11Ii - I1Ii1I1 / Iii1i - i1 / OooOoo
    if o0oo < I1IiIIII1 :
     if o0oo > 0 :
      oOOO0O += 1
      if oOOO0O > 5 :
       vwAppConfig . wglog ( "DownloadSwipe Finished5..." )
       IiiI = True
       break
      vwAppConfig . wglog ( "cntLessthangetNumOneTime={}" . format ( oOOO0O ) )
      iGotLastIndex = i11111I1 + 2
      if 28 - 28: i1I . I1Ii1I1 % IiIIii11Ii . Ii * ooOOO - oOO
      if 80 - 80: i1I1
      if oO == - 1 :
       oO = i11111I1
       if 7 - 7: Iii1i . Oo . iI1iII1I1I1i - Oo - ooOOO % IIiIIiIi11I1
     else :
      vwAppConfig . wglog ( "DownloadSwipe Finished..." )
      if 90 - 90: Iii1i / oOo0O00
      if 54 - 54: I11iiIi11i1I . i1I1 + OooOoo % Oo - i1I1 % Oo
      if 37 - 37: Oo
      IiiI = True
      break
    else :
     oOOO0O = 0
     iGotLastIndex = i11111I1
     if oO == - 1 :
      oO = i11111I1
      if 64 - 64: I1I % ooOOO
   else :
    vwAppConfig . wglog ( IIiii1i1iI1I1 )
    vwAppConfig . wglog ( "DownloadSwipe  Failed ..." )
    if 67 - 67: Ooo0Ooo + oOo0O00
    if 21 - 21: oOO
    break
    if 64 - 64: IIiIIiIi11I1 * i1iiIII111
 if IiiI :
  if i11111I1 > 0 :
   IiI = ( { "sn" : sn , "arrRecords" : i1Ii } )
   wgcondata . arrswipe . append ( IiI )
   if 31 - 31: Iii1i
   if 86 - 86: Oo
   if 74 - 74: OooOoo - I11iiIi11i1I . Oo . i1 + oOo0O00 - ooOOO
   if 60 - 60: Oo
   if 23 - 23: oOo0O00
   if 47 - 47: Ooo0Ooo + Oo * Ii . OooOoo . I1Ii1I1 * i1iiIII111
   if 46 - 46: ooOOO % i1i1i1111I * i1iiIII111 + I1Ii1I1
   if 15 - 15: iI1iII1I1I1i - ooo000 + IIiIIiIi11I1 * Ooo0Ooo
   if 84 - 84: OooOoo . Ii
   if 21 - 21: Ooo0Ooo
   if 76 - 76: iI1iII1I1I1i % i1I1 / IiIIii11Ii - i1I1
   if 4 - 4: OooOoo * IIiIIiIi11I1 - Ooo0Ooo . Ii - ooOOO . i1iiIII111
   if 2 - 2: I11iiIi11i1I * i1I * i1I * i1iiIII111 / I11iiIi11i1I % i1I1
   if 13 - 13: i1 * IiIIii11Ii - ooo000 * OooOoo
   if 72 - 72: Iii1i . I1Ii1I1 * IIiIIiIi11I1 % I1Ii1I1 - i1i1i1111I
   if 97 - 97: i1 + ooOOO + I11iiIi11i1I . i1
   if 71 - 71: ooo000 - i1i1i1111I / iI1iII1I1I1i - iI1iII1I1I1i % IIiIIiIi11I1 . iI1iII1I1I1i
   if 41 - 41: IIiIIiIi11I1
   if 96 - 96: Oo . Ooo0Ooo - oOO . Iii1i % i1I1 . i1I1
   if 82 - 82: oOO % iI1iII1I1I1i / i1iiIII111
   if 47 - 47: i1
   if 59 - 59: i1I1 % IIiIIiIi11I1 % IiIIii11Ii
   if 92 - 92: Oo . i1 * i1iiIII111 . IiIIii11Ii
   wgcondata . getswipeSNOK . append ( sn )
   wgcondata . getswipeSNRecordNum . append ( len ( i1Ii ) )
   return "OK"
  wgcondata . getswipeSNOK . append ( sn )
  wgcondata . getswipeSNRecordNum . append ( 0 )
  return "OK"
 else :
  wgcondata . getswipeSNFailed . append ( sn )
  return " Failed "
  if 82 - 82: I11iiIi11i1I % Oo + Ii
  if 22 - 22: Ooo0Ooo / ooOOO . I1I % I1I
def iI1II1i1i1 ( sn , infolist , usersByCardNO , doorcontollersBySNDoor ) :
 if len ( infolist ) :
  IIi1I = False
  I1 = 0
  for IiII in range ( len ( infolist ) ) :
   I111iIi11 = infolist [ IiII ]
   if 7 - 7: i1I - I11iiIi11i1I - i1I / OooOoo / Oo
   OOO00oOOOO = I111iIi11 [ 'DoorNO' ]
   oO00 = - 1
   if vwAppConfig . WGTools . IsElevator ( sn ) :
    oO00 = OOO00oOOOO
    OOO00oOOOO = 1
    if 96 - 96: oOO + oOO + I1I * I1I / i1I1
    if 92 - 92: IiIIii11Ii * OooOoo * I1Ii1I1
   o0O0000 = doorcontollersBySNDoor . get ( sn * 10 + OOO00oOOOO )
   if 54 - 54: oOO * Ooo0Ooo + I11iiIi11i1I . Iii1i . OooOoo - Ii
   if o0O0000 is not None :
    iiI1Ii = OOO00oOOOO
    I1iII = time . strftime ( '%Y-%m-%d %H:%M:%S' )
    i11Ii11I11iII , Ooo0Oo0Oo0 , ooOOo0ooo00oO , I1Iii1 = 0 , 0 , 0 , 0
    oO0oooO , I11Ii1I1i = 0 , 0
    if 24 - 24: I11iiIi11i1I . Ooo0Ooo / oOO % i1i1i1111I - IiIIii11Ii
    if 29 - 29: i1iiIII111 * i1iiIII111
    O00O0 = 0
    if 97 - 97: Oo . IiIIii11Ii * i1 - i1I1 * i1 % Ii
    if 88 - 88: Oo - ooOOO - oOO
    I1iII = I111iIi11 [ 'Time' ]
    if 93 - 93: I11iiIi11i1I . I11iiIi11i1I + I11iiIi11i1I
    oO0oooO = sn
    I1Iii1 = 1
    OO = o0O0000
    if 84 - 84: I11iiIi11i1I + i1i1i1111I
    I11Ii1I1i = I111iIi11 [ "RecordIndex" ]
    i1i1ii11i1 = I111iIi11 [ "Description" ]
    if 'CardNO' in I111iIi11 . keys ( ) :
     i11Ii11I11iII = I111iIi11 [ 'CardNO' ]
    if I111iIi11 [ 'RecordType' ] == 1 :
     i11Ii11I11iII = I111iIi11 [ 'CardNO' ]
     if 55 - 55: I1I
     o0ooO0OoooooO = ""
     iIII1I = ""
     OOi11i11i1iI1i = ""
     if 38 - 38: i1I1 + oOo0O00 . ooo000 - Iii1i - I1Ii1I1 - oOO
     iI1I1iI111Ii1 = usersByCardNO . get ( I111iIi11 [ 'CardNO' ] )
     if iI1I1iI111Ii1 is not None :
      Ooo0Oo0Oo0 = iI1I1iI111Ii1
      if 72 - 72: Ii . Iii1i
      if 74 - 74: oOO - i1i1i1111I % I1I + IiIIii11Ii * I1I
      if 53 - 53: OooOoo % I1Ii1I1 / i1I1 / I1I + I1Ii1I1 . i1I
      if 7 - 7: oOO - oOo0O00 . i1i1i1111I * Oo + I1I
      if 93 - 93: i1iiIII111 - OooOoo + i1 * oOo0O00 . i1I1
     if I111iIi11 [ 'Valid' ] == 'Pass' :
      ooOOo0ooo00oO = 1
     if I111iIi11 [ 'InExit' ] == "Exit" :
      I1Iii1 = 2
      if 9 - 9: IIiIIiIi11I1 + iI1iII1I1I1i
      if 43 - 43: oOo0O00 * i1I * i1I / IiIIii11Ii % i1iiIII111
      if 55 - 55: i1iiIII111 . i1
      if 29 - 29: Ooo0Ooo * IiIIii11Ii + i1iiIII111 / iI1iII1I1I1i - IiIIii11Ii - oOo0O00
      if 63 - 63: I1Ii1I1 . i1I1 * ooOOO . oOO / I1I
      if 34 - 34: i1i1i1111I * i1i1i1111I * I11iiIi11i1I . Iii1i * i1I % ooo000
    elif I111iIi11 [ 'RecordType' ] == 2 :
     ooOOo0ooo00oO = 1
     if 'CardNO' in I111iIi11 . keys ( ) :
      i11Ii11I11iII = I111iIi11 [ 'CardNO' ]
      if 99 - 99: Ii / ooOOO % oOO % OooOoo - IiIIii11Ii
      i1i1ii11i1 = "{}, CardNO={}" . format ( i1i1ii11i1 , i11Ii11I11iII )
      if 51 - 51: oOo0O00 % OooOoo
      o0ooO0OoooooO = ""
      iIII1I = ""
      OOi11i11i1iI1i = ""
      if 60 - 60: i1i1i1111I % IiIIii11Ii - Iii1i % i1 * i1I1
      iI1I1iI111Ii1 = usersByCardNO . get ( I111iIi11 [ 'CardNO' ] )
      if iI1I1iI111Ii1 is not None :
       Ooo0Oo0Oo0 = iI1I1iI111Ii1
       if 88 - 88: OooOoo % iI1iII1I1I1i
       if 21 - 21: i1I % OooOoo
       if 95 - 95: IiIIii11Ii - i1 . i1 - ooOOO . i1 + Ii
       if 86 - 86: IiIIii11Ii % ooo000
       if 61 - 61: Ii . i1iiIII111 * I11iiIi11i1I . ooOOO
    elif I111iIi11 [ 'RecordType' ] == 3 :
     pass
     if 95 - 95: oOO % I1Ii1I1 % ooo000
     if 84 - 84: i1I + i1i1i1111I * ooOOO % ooo000
     if 29 - 29: IiIIii11Ii - IIiIIiIi11I1 + i1I1 - I11iiIi11i1I . OooOoo
    else :
     i11Ii11I11iII = - 1
     if 57 - 57: i1i1i1111I / I11iiIi11i1I
    if vwAppConfig . WGTools . IsElevator ( sn ) :
     i1i1ii11i1 = getReacordFloorDescription ( I111iIi11 , ooOOo0ooo00oO , oO00 , OO )
    if i11Ii11I11iII >= 0 :
     I1iII = vwAppConfig . getDateTimeFromStr ( I1iII )
     oooO = TDSwiperecord2022 ( f_ReadDate = I1iII , f_CardNO = i11Ii11I11iII , f_ConsumerID = Ooo0Oo0Oo0 ,
 f_Character = ooOOo0ooo00oO , f_DoorID = OO , f_InOut = I1Iii1 ,
 f_Desc = i1i1ii11i1 , f_ControllerSN = oO0oooO , f_DoorNO = iiI1Ii ,
 f_RecordFlashLoc = I11Ii1I1i , f_ExtValue = O00O0 ,
 f_Modified = datetime . datetime . now ( ) )
     db . session . add ( oooO )
     IIi1I = True
     I1 = I11Ii1I1i
  if IIi1I :
   I1iiiIii1 = db . session . commit ( )
   if I1 > 0 :
    oOOOo0O0O0oOO . arrf_RecordFlashLocmax [ sn ] = I1
    if 78 - 78: i1 . i1iiIII111 - Oo * IIiIIiIi11I1 - I1I - i1I
    if 21 - 21: Iii1i - Ii / i1I / I1Ii1I1 % I11iiIi11i1I / Ii
def background_task_wsudp ( ) :
 if vwAppConfigParam . bkrunning > 0 :
  return
 vwAppConfigParam . bkrunning = 1
 if 74 - 74: I1Ii1I1 . ooOOO
 if 24 - 24: i1I1 - Iii1i % oOo0O00 * I1I . iI1iII1I1I1i
 if 78 - 78: I1Ii1I1 - Ooo0Ooo / OooOoo % i1I
 if 99 - 99: I11iiIi11i1I % ooOOO
 if 22 - 22: i1iiIII111 * i1I1 - i1i1i1111I % ooo000 / OooOoo - Oo
 if 3 - 3: I11iiIi11i1I % Ooo0Ooo
 if 20 - 20: I1Ii1I1 . i1I1 - Ii % I11iiIi11i1I % Oo
 import socket
 if 12 - 12: OooOoo * oOO % Ooo0Ooo . I11iiIi11i1I
 O0 = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
 if 68 - 68: IIiIIiIi11I1 / IiIIii11Ii - i1I % Oo
 O0 . setblocking ( False )
 if 55 - 55: IIiIIiIi11I1 + i1
 if 11 - 11: oOO % ooOOO - I1I
 if vwAppConfigParam . server1001_ip == '127.0.0.1' :
  O0 . bind ( ( '127.0.0.1' , 0 ) )
  if 1 - 1: Iii1i * I11iiIi11i1I % I11iiIi11i1I . ooo000 . I1I * i1iiIII111
  if 53 - 53: OooOoo . i1I - ooOOO
 OO0O0OoO00O = [ 0x37 , 0x10 , 0x00 , 0x00 , 0xee , 0xee , 0xee , 0x7e , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
 0x00 , 0x00 , 0x00 , 0x00 ]
 try :
  if 23 - 23: oOO % ooOOO - oOo0O00
  O0 . sendto ( bytes ( OO0O0OoO00O ) , ( vwAppConfigParam . server1001_ip , vwAppConfigParam . dataserverPort + 2 ) )
 except Exception as Oo0o0oO0ooo0O :
  print ( Oo0o0oO0ooo0O )
 oO0o = time . time ( ) + 30
 i1IiiIiIi = time . time ( ) + 30
 while ( True ) :
  if 78 - 78: ooo000
  O0oo0OOoo00Oo = False
  if 5 - 5: I11iiIi11i1I % i1 * I1Ii1I1 % Ii * IiIIii11Ii
  try :
   iiIIO0o0o00o , I11IIIi1iII1i = O0 . recvfrom ( 1024 )
   O0oo0OOoo00Oo = True
   if 34 - 34: I11iiIi11i1I - Oo
   if 72 - 72: I11iiIi11i1I
   if 38 - 38: I11iiIi11i1I . oOO + i1I
   if 33 - 33: ooo000 - IIiIIiIi11I1 % i1iiIII111 / iI1iII1I1I1i - Iii1i % IIiIIiIi11I1
   try :
    II1 = json . loads ( iiIIO0o0o00o . decode ( "utf-8" ) )
    iIi . put ( II1 [ 'params' ] [ 0 ] )
    if 29 - 29: i1 * Ooo0Ooo + I11iiIi11i1I + Iii1i % ooOOO * i1
   except Exception as o00Oo0oO :
    if 41 - 41: i1I / I1Ii1I1 + I1I
    if 64 - 64: i1 / i1 * I1I + I1I / i1I1 / IiIIii11Ii
    pass
  except BlockingIOError as o0OOo0 :
   if 20 - 20: Oo
   if 11 - 11: IIiIIiIi11I1 * Iii1i % Ii % IiIIii11Ii - i1iiIII111 % IIiIIiIi11I1
   pass
   time . sleep ( 1 )
  except Exception as O0OO :
   print ( O0OO )
   time . sleep ( 1 )
  if O0oo0OOoo00Oo :
   pass
  else :
   time . sleep ( 0.1 )
   o000O0 = time . time ( )
   if o000O0 < i1IiiIiIi or o000O0 > oO0o :
    if 29 - 29: Ii / Ooo0Ooo % oOO - I11iiIi11i1I . IiIIii11Ii
    if 51 - 51: iI1iII1I1I1i / I11iiIi11i1I . i1iiIII111 - Iii1i * I1I . ooo000
    try :
     if 75 - 75: i1iiIII111
     if 47 - 47: I1Ii1I1 + ooOOO % ooOOO / i1I1 - i1iiIII111
     O0 . sendto ( bytes ( OO0O0OoO00O ) ,
 ( vwAppConfigParam . server1001_ip , vwAppConfigParam . dataserverPort + 2 ) )
    except Exception as Oo0o0oO0ooo0O :
     print ( Oo0o0oO0ooo0O )
    oO0o = time . time ( ) + 30
    if 47 - 47: Ooo0Ooo - I1I
    if 54 - 54: IiIIii11Ii + ooOOO - I1Ii1I1 - OooOoo % i1 % Oo
def oo000O0oOO ( newRecord ) :
 ooO0OoOo = newRecord [ 'SN' ]
 OoO0OoOoo = newRecord [ 'RecordIndex' ]
 try :
  if 93 - 93: oOO / ooo000 - I1I
  if 19 - 19: IIiIIiIi11I1 / I1Ii1I1 . IIiIIiIi11I1 - I11iiIi11i1I / i1iiIII111 % IIiIIiIi11I1
  if 39 - 39: i1I % ooo000 . Oo
  if 89 - 89: I1I . ooOOO
  if 61 - 61: iI1iII1I1I1i . i1iiIII111 * IiIIii11Ii + oOO + ooOOO % IiIIii11Ii
  if 3 - 3: IiIIii11Ii . i1I1 * i1I / i1I
  if 84 - 84: I1Ii1I1 % IiIIii11Ii + I11iiIi11i1I + iI1iII1I1I1i - ooo000 . i1I1
  if 37 - 37: OooOoo * i1iiIII111 / i1I1 - i1I
  if 52 - 52: i1i1i1111I
  if 21 - 21: i1iiIII111 / oOo0O00 + ooOOO
  if OooOOO0oO0Oo ( ) :
   return
  if ooO0OoOo in oOOOo0O0O0oOO . arrcontrollerSN :
   if 78 - 78: ooOOO - IiIIii11Ii - i1I * iI1iII1I1I1i % I1Ii1I1 - I1Ii1I1
   if oOOOo0O0O0oOO . arrf_RecordFlashLocmax . get ( ooO0OoOo , - 2 ) == OoO0OoOoo :
    return
   oOOoOooo0 ( )
   if oOOOo0O0O0oOO . arrf_RecordFlashLocmax . get ( ooO0OoOo , - 2 ) + 1 == OoO0OoOoo :
    ii1I111iiiIii = [ newRecord ]
    iI1II1i1i1 ( ooO0OoOo , ii1I111iiiIii , usersByCardNO = oOOOo0O0O0oOO . arrusersByCardNO , doorcontollersBySNDoor = oOOOo0O0O0oOO . arrdoorcontollersBySNDoor )
   else :
    if oOOOo0O0O0oOO . arrdoorcontollersBySNDoor . get ( ooO0OoOo * 10 + 1 ) :
     II ( [ oOOOo0O0O0oOO . arrdoorcontollersBySNDoor [ ooO0OoOo * 10 + 1 ] ] )
 except Exception as o00Oo0oO :
  if 9 - 9: Ii % ooo000 . i1i1i1111I % Oo
  print ( o00Oo0oO )
  vwAppConfig . vwlog ( "dealtaskNewRecord e3" )
  vwAppConfig . vwlog ( o00Oo0oO )
  pass
  if 34 - 34: i1i1i1111I / ooo000 * i1 + oOo0O00 / iI1iII1I1I1i
  if 81 - 81: I11iiIi11i1I / I1Ii1I1
def oOOoOooo0 ( ) :
 if 4 - 4: IiIIii11Ii
 if oOOOo0O0O0oOO . arrusersByCardNO is None or vwAppConfigParam . usercardChangeTime > oOOOo0O0O0oOO . arrusercardChangeTimeLoadTime :
  oOOOo0O0O0oOO . arrusersByCardNO = dict ( )
  O0Ooo0oOo0 = TBConsumer . query . filter ( TBConsumer . f_CardNO . isnot ( None ) ) . all ( )
  for IiI in O0Ooo0oOo0 :
   oOOOo0O0O0oOO . arrusersByCardNO [ IiI . f_CardNO ] = IiI . f_ConsumerID
  oOOOo0O0O0oOO . arrusercardChangeTimeLoadTime = time . time ( )
  if 42 - 42: oOO - oOO + OooOoo - oOO
  if 23 - 23: iI1iII1I1I1i % i1I * I11iiIi11i1I - oOO * oOo0O00
 if oOOOo0O0O0oOO . arrdoorcontollersBySNDoor is None or vwAppConfigParam . controllerdoorChangeTime > oOOOo0O0O0oOO . arrdoorcontollersBySNDoorLoadTime :
  oOOOo0O0O0oOO . arrdoorcontollersBySNDoor = dict ( )
  ooOOoO00OO = db . session . query ( TBController . f_ControllerID , TBController . f_ControllerSN , TBDoor . f_DoorNO ,
 TBDoor . f_DoorID ) . join ( TBDoor ,
 TBDoor . f_ControllerID == TBController . f_ControllerID )
  O0oO0OO0O00 = ooOOoO00OO . all ( )
  for IiI in O0oO0OO0O00 :
   ooO0OoOo = IiI . f_ControllerSN
   ii1Ii = IiI . f_DoorNO
   oOOOo0O0O0oOO . arrdoorcontollersBySNDoor [ ooO0OoOo * 10 + ii1Ii ] = IiI . f_DoorID
   if ooO0OoOo not in oOOOo0O0O0oOO . arrcontrollerSN :
    oOOOo0O0O0oOO . arrcontrollerSN . append ( ooO0OoOo )
  oOOOo0O0O0oOO . arrdoorcontollersBySNDoorLoadTime = time . time ( )
  if 45 - 45: i1 % iI1iII1I1I1i . IiIIii11Ii + Ooo0Ooo
  if 34 - 34: Iii1i + Iii1i
def OooOOO0oO0Oo ( ) :
 if vwAppConfigParam . controllerdoorChangeTime > oOOOo0O0O0oOO . arrdoorcontollersBySNDoorLoadTime :
  if 67 - 67: oOo0O00 + IIiIIiIi11I1
  oOOoOooo0 ( )
  if 69 - 69: IIiIIiIi11I1
  ooOOoO00OO = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBDoor . f_DoorNO , TBController . f_ControllerSN ,
 ) . join ( TBController ,
 TBController . f_ControllerID == TBDoor . f_ControllerID ) . order_by (
 TBDoor . f_DoorName )
  OOo0 = ooOOoO00OO . all ( )
  o0OOoo00 = [ ]
  for IiI in OOo0 :
   o0OOoo00 . append ( IiI . f_DoorID )
  I111iIi11 = II ( o0OOoo00 )
  if 83 - 83: i1 - i1i1i1111I + i1 - I11iiIi11i1I
  return True
 return False
 if 98 - 98: ooOOO * oOO + Ooo0Ooo + i1i1i1111I / I1Ii1I1
 if 18 - 18: iI1iII1I1I1i . iI1iII1I1I1i % ooOOO
def background_task_checkControllerConnected ( ) :
 with vwAppConfigParam . application . app_context ( ) :
  ooOOoO00OO = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBDoor . f_DoorNO , TBController . f_ControllerSN ,
 ) . join ( TBController , TBController . f_ControllerID == TBDoor . f_ControllerID ) . order_by (
 TBDoor . f_DoorName )
  if 90 - 90: I1I - Iii1i + Ii / Iii1i % I1Ii1I1
  if 14 - 14: OooOoo + iI1iII1I1I1i * Iii1i
  if 30 - 30: OooOoo
  if 2 - 2: i1iiIII111 / oOo0O00 - IiIIii11Ii - iI1iII1I1I1i
  if 90 - 90: i1iiIII111
  if 11 - 11: ooOOO . ooo000
  if 10 - 10: I1Ii1I1 - ooOOO / Iii1i - i1 . ooo000
  if 99 - 99: Ii / iI1iII1I1I1i / Oo * I11iiIi11i1I
  if 86 - 86: ooo000 - oOo0O00
  if 42 - 42: Ii * oOO
  O0OOo0O = time . time ( ) + 5
  I1IiIi1ii = [ ]
  IiiI1iI = [ ]
  i1ooooOo0 = [ ]
  if 80 - 80: Ii * IiIIii11Ii . OooOoo
  while True :
   OOo0 = ooOOoO00OO . all ( )
   for IiI in OOo0 :
    if 90 - 90: OooOoo . i1 - oOO + IiIIii11Ii * iI1iII1I1I1i
    ooO0OoOo = IiI . f_ControllerSN
    iII1iIiI1I1I1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "QueryControllerStatus" ,
 "params" : [ { "ControllerSN" : ooO0OoOo } ] ,
 "id" : 1002
 } )
    if vwAppConfig . sendByHttp ( iII1iIiI1I1I1 ) == "OK" :
     pass
     if ooO0OoOo not in i1ooooOo0 :
      i1ooooOo0 . append ( ooO0OoOo )
     if ooO0OoOo in I1IiIi1ii :
      I1IiIi1ii . remove ( ooO0OoOo )
    else :
     print ( "Communication failure." )
     if ooO0OoOo in i1ooooOo0 :
      if ooO0OoOo in I1IiIi1ii :
       if 90 - 90: i1I / oOO / i1iiIII111 + iI1iII1I1I1i
       if ooO0OoOo not in IiiI1iI :
        IiiI1iI . append ( ooO0OoOo )
      else :
       I1IiIi1ii . append ( ooO0OoOo )
   time . sleep ( 30 )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
