import configparser
import datetime
import logging
import sys
import socket
import platform
import time
if 82 - 82: Iii1i
import exts
from vwAppConfigParam import vwAppConfigParam
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
import http
import json
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
if 31 - 31: i1I
if 9 - 9: IiI11Ii111 / oOo0O00 / IiIIii11Ii - I11iiIi11i1I - iI1iII1I1I1i
if 16 - 16: i1i1i1111I / 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 . IiI11Ii111 . 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: IiI11Ii111 + 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
__all__ = [
 'checkElevator' ,
 'cleartable' ,
 'getDateFromStr' ,
 'getDateTimeFromStr' ,
 'getIPV4' ,
 'getProductType' ,
 'getStrFromArray' ,
 'getStrNoneToSpace' ,
 'getStrOfDatetime' ,
 'getStrOfDatetimeHHMM' ,
 'getStrOfDatetimeYMD' ,
 'is_valid_ip' ,
 'isNotLocalHost' ,
 'isValidCardId' ,
 'logdebug' ,
 'logprint' ,
 'longToByte' ,
 'parseInt' ,
 'sendByHttp' ,
 'sendByHttpWithMsg' ,
 'setcontrollerdoorChangeTime' ,
 'setusercardChangeTime' ,
 'strtotime' ,
 'successIsTrue' ,
 'vwlog' ,
 'wglog' ,
 'wgMjControllerConfigure' ,
 'WGTools' ,
 'WriteLine'
 ]
if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
if 88 - 88: Oo * IiIIii11Ii
def getProductType ( SN ) :
 if SN < 100000000 :
  return 0
 if SN < 200000000 :
  return 1
 if SN < 300000000 :
  return 2
 if SN < 400000000 :
  return 0
 if SN < 500000000 :
  return 4
 return 0
 if 100 - 100: IiI11Ii111 - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
 if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
def parseInt ( strinfo ) :
 try :
  return int ( strinfo )
 except ValueError :
  return 0
  if 29 - 29: IiIIii11Ii - oOo0O00
  if 30 - 30: I1I . ooo000
def isValidCardId ( CardNO ) :
 if CardNO < 0 :
  pass
 elif ( CardNO == 0xffffff ) or ( CardNO == 0xffffffff ) :
  pass
 elif 25565535 == CardNO :
  pass
  if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
  if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
 else :
  return True
 return False
 if 77 - 77: i1iiIII111 + IiI11Ii111 - Oo % ooo000
 if 74 - 74: Ii + Ooo0Ooo
def checkElevator ( sn ) :
 return 180000000 > sn > 170000000
 if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
 if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
def WriteLine ( info ) :
 if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
 if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
 if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
 logdebug ( ( '[{}sec]:\t{}' . format ( time . time ( ) - vwAppConfigParam . dtLast , info ) ) )
 vwAppConfigParam . dtLast = time . time ( )
 if 37 - 37: IiI11Ii111 * i1i1i1111I + oOo0O00 / I1I / OooOoo
 if 4 - 4: i1
 if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
 if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
 if 32 - 32: iI1iII1I1I1i
 if 18 - 18: I11iiIi11i1I * IiI11Ii111 % iI1iII1I1I1i + IiI11Ii111
 if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
 if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
 if 57 - 57: oOo0O00
def logdebug ( info ) :
 print ( "{0} {1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , info ) )
 if 31 - 31: i1iiIII111 + i1i1i1111I % OooOoo
 if 20 - 20: OooOoo - I1I
def wglog ( info ) :
 if vwAppConfigParam . allowprint :
  if 9 - 9: i1iiIII111 - iI1iII1I1I1i % Ii - I1I
  print ( "{0} UDP.{1}\r" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , info ) )
  if 54 - 54: Iii1i % ooo000 % Iii1i - IiIIii11Ii
  if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
  if 29 - 29: IIiIIiIi11I1 - ooo000 . i1iiIII111
  if 86 - 86: I1Ii1I1 - OooOoo - oOO % ooo000 . i1I % Iii1i
def strtotime ( strtime ) :
 if 11 - 11: OooOoo - I1Ii1I1 - ooOOO . i1iiIII111 - iI1iII1I1I1i / i1iiIII111
 if 44 - 44: Ooo0Ooo + i1i1i1111I + Iii1i - oOO
 if type ( strtime ) is datetime . datetime :
  return strtime
 if len ( strtime ) - 19 >= 0 :
  return datetime . datetime . strptime ( strtime [ 0 : 19 ] , "%Y-%m-%d %H:%M:%S" )
 if len ( strtime ) - 19 == 0 :
  return datetime . datetime . strptime ( strtime , "%Y-%m-%d %H:%M:%S" )
 return datetime . datetime . strptime ( strtime , "%Y-%m-%d %H:%M:%S" [ : len ( strtime ) - 19 ] )
 if 7 - 7: i1i1i1111I / Ii * Iii1i
 if 32 - 32: IiI11Ii111 . OooOoo
def getStrOfDatetime ( timeA ) :
 return timeA . strftime ( "%Y-%m-%d %H:%M:%S" )
 if 31 - 31: Oo - i1I
 if 28 - 28: ooOOO * I1Ii1I1 + IiI11Ii111 % Oo
def getStrOfDatetimeYMD ( timeA ) :
 return timeA . strftime ( "%Y-%m-%d" )
 if 100 - 100: Oo + i1I
 if 4 - 4: ooo000 % I1I - i1i1i1111I
def getStrOfDatetimeHHMM ( timeA ) :
 return timeA . strftime ( "%H:%M" )
 if 76 - 76: i1 * oOo0O00 . IiI11Ii111 * i1I . IiIIii11Ii . oOO
 if 55 - 55: i1i1i1111I + i1iiIII111 % Ooo0Ooo . Oo - IiIIii11Ii - iI1iII1I1I1i
def cleartable ( strtablename ) :
 if vwAppConfigParam . bmysql > 0 :
  return "TRUNCATE TABLE {}" . format ( strtablename )
 else :
  return "Delete From {}" . format ( strtablename )
  if 91 - 91: I1Ii1I1 - I11iiIi11i1I
  if 84 - 84: oOO % iI1iII1I1I1i - Ooo0Ooo
def successIsTrue ( cmdjsonresult ) :
 OoOOo = False
 try :
  return cmdjsonresult [ 'success' ]
 except :
  OoOOo = False
 return OoOOo
 if 97 - 97: IiI11Ii111 % ooo000 * Iii1i + IIiIIiIi11I1
 if 42 - 42: I1I - IiIIii11Ii
 if 34 - 34: IiI11Ii111 + ooOOO * oOO
def getDateFromStr ( strDate ) :
 try :
  return datetime . datetime . strptime ( strDate , "%Y-%m-%d" )
 except :
  return None
  if 2 - 2: i1i1i1111I / Ooo0Ooo / oOO - IIiIIiIi11I1 / IIiIIiIi11I1
  if 58 - 58: i1i1i1111I
  if 38 - 38: i1 - oOo0O00
def getDateTimeFromStr ( strDate ) :
 try :
  O0OO00OO0O = len ( strDate )
  if O0OO00OO0O <= 10 :
   return datetime . datetime . strptime ( strDate , "%Y-%m-%d" )
  elif O0OO00OO0O == 16 :
   return datetime . datetime . strptime ( strDate , "%Y-%m-%d %H:%M" )
  return datetime . datetime . strptime ( strDate , "%Y-%m-%d %H:%M:%S" )
 except :
  return None
  if 35 - 35: i1 + I1I . i1iiIII111
  if 16 - 16: I1Ii1I1 % I1I / IIiIIiIi11I1 * i1I + IiI11Ii111 % oOo0O00
  if 13 - 13: i1 + IiIIii11Ii
def longToByte ( number , data , startIndex , bytlen ) :
 for I1 in range ( 0 , bytlen ) :
  data [ startIndex + I1 ] = ( number % 256 )
  number >>= 8
  if 69 - 69: Ii + Ii
  if 71 - 71: OooOoo * IIiIIiIi11I1 * Oo
  if 2 - 2: IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + ooOOO . IIiIIiIi11I1
def getStrNoneToSpace ( strinfo ) :
 if strinfo is None :
  return ''
 else :
  if type ( strinfo ) is int :
   return str ( strinfo )
  return strinfo
  if 15 - 15: ooo000
  if 63 - 63: i1I
  if 81 - 81: OooOoo . i1I / i1i1i1111I + Oo / Ooo0Ooo % IiI11Ii111
def logprint ( * args ) :
 try :
  if 77 - 77: I11iiIi11i1I / iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % oOo0O00
  if vwAppConfigParam . allowprint :
   print ( args )
   if 73 - 73: IiI11Ii111 . Oo * I1I / i1i1i1111I + I1Ii1I1
   if 31 - 31: i1i1i1111I % I1Ii1I1
   if 1 - 1: IiI11Ii111 - 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
 except Exception as OOO00OOo0oO0O :
  pass
  if 78 - 78: i1i1i1111I . i1I / i1I
  if 3 - 3: i1I + I1Ii1I1 . I11iiIi11i1I - iI1iII1I1I1i * I1Ii1I1 + i1I
  if 56 - 56: i1i1i1111I - IiIIii11Ii - i1iiIII111 - Oo + i1iiIII111 / Ooo0Ooo
  if 89 - 89: ooo000 + Ii % i1i1i1111I - i1iiIII111
  if 33 - 33: ooo000 . Iii1i % oOO
  if 60 - 60: I1I . IiIIii11Ii % IIiIIiIi11I1 % iI1iII1I1I1i
def vwlog ( msg ) :
 try :
  if exts . vwroot_logger is None :
   if 98 - 98: I1I
   if 35 - 35: oOo0O00 / IIiIIiIi11I1 - Iii1i . IiI11Ii111 * i1
   if 91 - 91: oOO + Iii1i
   if 71 - 71: i1 . iI1iII1I1I1i . OooOoo . IIiIIiIi11I1
   if 92 - 92: ooOOO % IIiIIiIi11I1 - IIiIIiIi11I1
   if 32 - 32: OooOoo % I1I - I11iiIi11i1I % OooOoo
   if 9 - 9: i1iiIII111 - ooOOO % Iii1i
   if 37 - 37: i1I + IIiIIiIi11I1 % iI1iII1I1I1i / IIiIIiIi11I1 % i1iiIII111 + oOO
   if 98 - 98: iI1iII1I1I1i - I1I + i1 * ooo000 % i1
   if 100 - 100: i1iiIII111 . IIiIIiIi11I1 * ooo000 * ooo000
   if 85 - 85: IIiIIiIi11I1 / OooOoo . i1I % Oo + Oo - I11iiIi11i1I
   ooO0ooOOO00O0 = logging . getLogger ( "vw_log" )
   ooO0ooOOO00O0 . setLevel ( logging . INFO )
   from logging . handlers import RotatingFileHandler
   if 11 - 11: oOO * i1iiIII111 - IIiIIiIi11I1
   i11Ii = RotatingFileHandler ( vwAppConfigParam . wgcloudpath1001vw_logName ,
 maxBytes = vwAppConfigParam . wglogmaxBytes ,
 backupCount = 3 , mode = 'a' , encoding = 'utf-8' )
   if 96 - 96: Ooo0Ooo
   ii1IiiIiI = logging . Formatter ( '%(asctime)s:%(message)s' )
   i11Ii . setFormatter ( ii1IiiIiI )
   ooO0ooOOO00O0 . addHandler ( i11Ii )
   exts . vwroot_logger = ooO0ooOOO00O0
  if msg is not None :
   exts . vwroot_logger . info ( msg )
 except Exception as OOO00OOo0oO0O :
  pass
  if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
 finally :
  pass
  if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
  if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
def getStrFromArray ( arr ) :
 oOOOOOOoOOooO0O0 = ''
 if arr :
  for O0 in arr :
   if oOOOOOOoOOooO0O0 == '' :
    oOOOOOOoOOooO0O0 = "{}" . format ( O0 )
   else :
    if 51 - 51: i1I . Ii * IiI11Ii111
    oOOOOOOoOOooO0O0 = "{}, {}" . format ( oOOOOOOoOOooO0O0 , O0 )
 return oOOOOOOoOOooO0O0
 if 96 - 96: i1 + IiIIii11Ii % I1I / IiI11Ii111
 if 33 - 33: OooOoo * Oo * Ii * iI1iII1I1I1i + i1I . IiIIii11Ii
 if 94 - 94: 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 - IiI11Ii111
 if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
 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
def sendByHttpWithMsg ( arrinfo , timeoutSec = 3 ) :
 if 77 - 77: ooOOO
 try :
  iIii1iiiIi = vwAppConfigParam . server1001_ip
  oOoo = vwAppConfigParam . server1001_webport
  ooOOO00oO0o0o = http . client . HTTPConnection ( host = iIii1iiiIi , port = oOoo , timeout = 3 )
  OooOOO0oO0Oo = bytes ( json . dumps ( arrinfo , sort_keys = False , indent = 4 ) , encoding = 'utf8' )
  IiiiI11111I = { "Content-type" : "application/json" , "Accept" : "application/json" }
  ooOOO00oO0o0o . timeout = timeoutSec
  ooOOO00oO0o0o . request ( "POST" , iIii1iiiIi , OooOOO0oO0Oo , IiiiI11111I )
  O00Oo0o00 = ooOOO00oO0o0o . getresponse ( )
  IiIIIII1i = O00Oo0o00 . read ( )
  ooOOO00oO0o0o . close ( )
  try :
   O0OOo0O = json . loads ( IiIIIII1i . decode ( "utf-8" ) )
   OoOOo = O0OOo0O [ 'result' ]
  except :
   OoOOo = None
   return OoOOo
  return OoOOo
 except Exception as OOO00OOo0oO0O :
  pass
  print ( OOO00OOo0oO0O )
 return None
 if 9 - 9: i1i1i1111I
 if 12 - 12: IiIIii11Ii . oOO / i1I . oOO
def sendByHttp ( arrinfo , timeoutSec = 3 ) :
 OoOOo = None
 try :
  iIii1iiiIi = vwAppConfigParam . server1001_ip
  oOoo = vwAppConfigParam . server1001_webport
  ooOOO00oO0o0o = http . client . HTTPConnection ( host = iIii1iiiIi , port = oOoo , timeout = 3 )
  OooOOO0oO0Oo = bytes ( json . dumps ( arrinfo , sort_keys = False , indent = 4 ) , encoding = 'utf8' )
  if 72 - 72: Oo * IiIIii11Ii - Ooo0Ooo
  if 93 - 93: oOo0O00
  IiiiI11111I = { "Content-type" : "application/json" , "Accept" : "application/json" }
  ooOOO00oO0o0o . timeout = timeoutSec
  if 77 - 77: Oo + I11iiIi11i1I % I1I
  ooOOO00oO0o0o . request ( "POST" , iIii1iiiIi , OooOOO0oO0Oo , IiiiI11111I )
  O00Oo0o00 = ooOOO00oO0o0o . getresponse ( )
  if 20 - 20: i1 - IiIIii11Ii . IiIIii11Ii % ooOOO . i1 % Ooo0Ooo
  IiIIIII1i = O00Oo0o00 . read ( )
  if 72 - 72: oOO % IiI11Ii111 . ooOOO * I1Ii1I1 . ooOOO
  if 90 - 90: IiIIii11Ii + I1Ii1I1 . OooOoo
  if 73 - 73: i1i1i1111I - Iii1i / I11iiIi11i1I . ooo000 / iI1iII1I1I1i - i1iiIII111
  ooOOO00oO0o0o . close ( )
  try :
   if 21 - 21: i1iiIII111 + IiI11Ii111 % i1i1i1111I
   if 7 - 7: IiI11Ii111 / Ii
   O0OOo0O = json . loads ( IiIIIII1i . decode ( "utf-8" ) )
   if 87 - 87: ooOOO
   if O0OOo0O [ 'result' ] [ 'success' ] :
    OoOOo = "OK"
   else :
    OoOOo = O0OOo0O [ 'result' ] [ 'msg' ]
    if 57 - 57: IIiIIiIi11I1 - iI1iII1I1I1i % ooOOO - I11iiIi11i1I / IiIIii11Ii . Ooo0Ooo
  except :
   if 15 - 15: i1I * I11iiIi11i1I - oOo0O00
   if 6 - 6: IiI11Ii111 - Ii
   if 1 - 1: I1I + OooOoo
   OoOOo = None
   return OoOOo
   if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
   if 96 - 96: OooOoo / oOO - i1 * I11iiIi11i1I
  return OoOOo
 except Exception as OOO00OOo0oO0O :
  pass
  print ( OOO00OOo0oO0O )
  if 72 - 72: i1i1i1111I + Ii - Iii1i - i1i1i1111I - i1I + Ooo0Ooo
  if 74 - 74: Ooo0Ooo * Oo + Iii1i - i1iiIII111
 return None
 if 22 - 22: IiIIii11Ii - Ooo0Ooo . i1 . i1I - ooo000
 if 68 - 68: ooo000
 if 40 - 40: i1 + I1Ii1I1 + I11iiIi11i1I . Oo * I11iiIi11i1I % I1I
 if 100 - 100: OooOoo + Oo / OooOoo
def isNotLocalHost ( str ) :
 OoOOo = 1
 try :
  if "127.0.0.1" in str :
   OoOOo = 0
 finally :
  pass
 return OoOOo == 1
 if 33 - 33: IiI11Ii111 / OooOoo
 if 98 - 98: I1Ii1I1 . IIiIIiIi11I1 * i1I - iI1iII1I1I1i % i1I * IiI11Ii111
 if 42 - 42: OooOoo + i1i1i1111I - iI1iII1I1I1i - oOo0O00 * i1I + Ii
def is_valid_ip ( ip ) :
 try :
  socket . inet_aton ( ip )
  return True
 except socket . error :
  return False
  if 46 - 46: oOo0O00 . iI1iII1I1I1i - Ii . oOo0O00 + i1i1i1111I
  if 83 - 83: IiI11Ii111
def getIPV4 ( nouse = None ) :
 if 77 - 77: iI1iII1I1I1i - oOO % Ii * i1I - I1I
 OooOoO0o00 = [ ]
 if 23 - 23: i1
 if 91 - 91: I11iiIi11i1I - IiI11Ii111 % IiIIii11Ii / IiIIii11Ii
 if 37 - 37: i1iiIII111 - IiI11Ii111 * i1iiIII111 . i1i1i1111I
 if 43 - 43: oOO
 try :
  if 87 - 87: ooOOO + IiI11Ii111 * i1iiIII111 / i1i1i1111I
  if str ( platform . system ( ) . lower ( ) ) == 'windows' :
   import subprocess
   I111Ii = ""
   try :
    try :
     I111Ii = subprocess . check_output ( [ 'c:\\windows\\system32\\ipconfig' ] )
    except Exception as II1Ii11111 :
     I111Ii = subprocess . check_output ( [ 'ipconfig' ] )
    IIiIIiiIIi = ""
    try :
     IIiIIiiIIi = I111Ii . decode ( "GBK" )
    except Exception as iiIi :
     try :
      IIiIIiiIIi = I111Ii . decode ( "GB2312" )
     except Exception as Ii1Iiii11i1 :
      IIiIIiiIIi = I111Ii . decode ( "utf-8" )
    I111Ii = IIiIIiiIIi
   except Exception as oO00oO0O :
    pass
    if 97 - 97: i1 - i1 % IIiIIiIi11I1 + IiIIii11Ii / i1I * iI1iII1I1I1i
   if len ( I111Ii ) > 0 :
    if 60 - 60: I11iiIi11i1I - Ooo0Ooo % I1Ii1I1
    if 26 - 26: ooOOO / IIiIIiIi11I1 . oOO + I11iiIi11i1I . Oo
    for oOO0 in I111Ii . splitlines ( ) :
     if 19 - 19: i1 . IiIIii11Ii - Ooo0Ooo . Ii
     if "IPv4" in oOO0 :
      OOoOo = oOO0 . split ( ":" ) [ 1 ] . strip ( )
      if is_valid_ip ( OOoOo ) and isNotLocalHost ( OOoOo ) :
       OooOoO0o00 . append ( OOoOo )
       if 4 - 4: i1iiIII111 . OooOoo / Ii
       if 37 - 37: OooOoo * IIiIIiIi11I1 * IiI11Ii111 - Iii1i
   if len ( OooOoO0o00 ) > 0 :
    return OooOoO0o00
    if 11 - 11: ooOOO
   i111IiIiIi = socket . getaddrinfo ( socket . gethostname ( ) , None )
   if 7 - 7: IiI11Ii111 - iI1iII1I1I1i
   for i11i111i1 in i111IiIiIi :
    if 19 - 19: Iii1i - IiIIii11Ii % i1
    if ':' not in i11i111i1 [ 4 ] [ 0 ] :
     if 74 - 74: i1i1i1111I / IiIIii11Ii % I11iiIi11i1I . oOO
     if isNotLocalHost ( i11i111i1 [ 4 ] [ 0 ] ) :
      OooOoO0o00 . append ( i11i111i1 [ 4 ] [ 0 ] )
   if len ( OooOoO0o00 ) > 0 :
    return OooOoO0o00
    if 65 - 65: Iii1i % IIiIIiIi11I1 - ooo000 . ooOOO + Iii1i
    if 46 - 46: IiIIii11Ii
   if len ( OooOoO0o00 ) == 0 :
    try :
     if 31 - 31: Oo * i1iiIII111 % Ii / oOO + I1Ii1I1 + iI1iII1I1I1i
     oo0O = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
     try :
      oo0O . connect ( ( '8.8.8.8' , 80 ) )
     except :
      oo0O . connect ( ( '127.0.0.1' , 1 ) )
     IiiiI = oo0O . getsockname ( ) [ 0 ]
     oo0O . close ( )
     OooOoO0o00 . append ( IiiiI . strip ( ) )
    except Exception as oO00oO0O :
     pass
    if len ( OooOoO0o00 ) > 0 :
     if 40 - 40: oOO - ooOOO - I1I . IiIIii11Ii + Ii
     return OooOoO0o00
  else :
   if 84 - 84: Oo + Ooo0Ooo + ooo000
   if 96 - 96: i1iiIII111 - IIiIIiIi11I1 / IIiIIiIi11I1 * IiIIii11Ii
   if 67 - 67: Ooo0Ooo . Ooo0Ooo . IiI11Ii111
   if 24 - 24: i1iiIII111 + i1i1i1111I . oOo0O00 + iI1iII1I1I1i + IiI11Ii111
   import subprocess
   I111Ii = ''
   if 92 - 92: iI1iII1I1I1i / iI1iII1I1I1i + IiIIii11Ii . IiI11Ii111
   if 56 - 56: Ii * ooo000 . IiIIii11Ii
   try :
    if 66 - 66: I1Ii1I1 * OooOoo . iI1iII1I1I1i % OooOoo . i1 . IiIIii11Ii
    if 47 - 47: Ii % OooOoo % iI1iII1I1I1i * IiIIii11Ii
    I111Ii = subprocess . check_output ( [ 'ip' , 'addr' , 'show' ] ) . decode ( )
    if 48 - 48: i1I . I11iiIi11i1I / ooo000 + i1iiIII111
    if 84 - 84: Oo / I1Ii1I1 . IIiIIiIi11I1
    if 67 - 67: Oo % ooOOO + iI1iII1I1I1i * I1I
   except Exception as oO00oO0O :
    pass
    if "darwin" not in str ( platform . system ( ) . lower ( ) ) :
     print ( oO00oO0O )
   if len ( I111Ii ) > 0 :
    if 79 - 79: IIiIIiIi11I1 * Oo / OooOoo
    for i11i111i1 in I111Ii . split ( '\n' ) :
     I1Ii = 0
     if "inet " not in i11i111i1 :
      continue
     for Oo00OOo0000oO in i11i111i1 . split ( ' ' ) :
      if 66 - 66: I1I . OooOoo
      if len ( Oo00OOo0000oO ) > 0 :
       if I1Ii > 0 :
        if 31 - 31: IiIIii11Ii . i1I % iI1iII1I1I1i + oOO
        if 17 - 17: i1i1i1111I . ooo000 + IIiIIiIi11I1 * Ooo0Ooo % Ooo0Ooo
        i1iII11 = Oo00OOo0000oO . split ( ":" )
        if len ( i1iII11 ) == 1 :
         if isNotLocalHost (
 Oo00OOo0000oO ) :
          o00ooO0oo0 = Oo00OOo0000oO . split ( "/" )
          if isNotLocalHost (
 o00ooO0oo0 [ 0 ] ) :
           OooOoO0o00 . append ( o00ooO0oo0 [ 0 ] )
        else :
         if isNotLocalHost (
 i1iII11 [ 1 ] ) :
          o00ooO0oo0 = i1iII11 [ 1 ] . split ( "/" )
          if isNotLocalHost (
 o00ooO0oo0 [ 0 ] ) :
           OooOoO0o00 . append ( o00ooO0oo0 [ 0 ] )
        break
       if Oo00OOo0000oO . index ( 'inet' ) >= 0 :
        I1Ii = 1
    if len ( OooOoO0o00 ) > 0 :
     if 20 - 20: I1Ii1I1 / i1 + IiIIii11Ii
     return OooOoO0o00
     if 67 - 67: ooOOO . oOO / ooOOO
   if len ( I111Ii ) == 0 :
    if 17 - 17: IiI11Ii111 + i1i1i1111I % I1Ii1I1 % i1I % I1Ii1I1 / IiI11Ii111
    if 93 - 93: i1I + Iii1i . Ii . i1I * ooOOO
    try :
     if 84 - 84: Ooo0Ooo % IiI11Ii111
     I111Ii = subprocess . check_output ( [ 'ifconfig' ] ) . decode ( )
     if 82 - 82: IIiIIiIi11I1
     if 81 - 81: oOo0O00 + i1 - ooo000 * iI1iII1I1I1i + i1i1i1111I
    except Exception as oO00oO0O :
     pass
     if 89 - 89: I1Ii1I1
   if len ( I111Ii ) > 0 :
    if 57 - 57: iI1iII1I1I1i - i1iiIII111 / OooOoo % i1iiIII111
    for i11i111i1 in I111Ii . split ( '\n' ) :
     I1Ii = 0
     if "inet " not in i11i111i1 :
      continue
     for Oo00OOo0000oO in i11i111i1 . split ( ' ' ) :
      if 92 - 92: IiIIii11Ii * OooOoo - IiIIii11Ii
      if len ( Oo00OOo0000oO ) > 0 :
       if I1Ii > 0 :
        if 66 - 66: i1iiIII111 . iI1iII1I1I1i / ooOOO . i1 - OooOoo
        if 13 - 13: oOo0O00
        i1iII11 = Oo00OOo0000oO . split ( ":" )
        if len ( i1iII11 ) == 1 :
         if isNotLocalHost (
 Oo00OOo0000oO ) :
          OooOoO0o00 . append ( Oo00OOo0000oO )
        else :
         if isNotLocalHost (
 i1iII11 [ 1 ] ) :
          OooOoO0o00 . append ( i1iII11 [ 1 ] )
        break
       if Oo00OOo0000oO . index ( 'inet' ) >= 0 :
        I1Ii = 1
    if len ( OooOoO0o00 ) > 0 :
     if 50 - 50: i1 - i1iiIII111 / i1iiIII111 % I1Ii1I1 / IIiIIiIi11I1
     return OooOoO0o00
     if 66 - 66: oOo0O00 - Iii1i - ooo000 . I11iiIi11i1I
     if 59 - 59: i1I / IiIIii11Ii
   if len ( I111Ii ) == 0 :
    try :
     I111Ii = subprocess . check_output ( [ 'hostname' , '-I' ] ) . decode ( )
     if len ( I111Ii ) > 0 :
      for i11i111i1 in I111Ii . split ( '\n' ) :
       if 7 - 7: oOo0O00
       if len ( i11i111i1 . strip ( ) ) > 3 and isNotLocalHost ( i11i111i1 ) :
        OooOoO0o00 . append ( i11i111i1 . strip ( ) )
        if 64 - 64: IIiIIiIi11I1 * oOO + Oo . OooOoo - ooOOO
        if 94 - 94: IiIIii11Ii - ooo000 . Ii
        if 73 - 73: IiIIii11Ii / oOo0O00 % ooo000 . iI1iII1I1I1i % oOO
    except Exception as oO00oO0O :
     pass
     if 36 - 36: IiI11Ii111 * OooOoo . ooo000 . i1iiIII111 + oOO
    if len ( OooOoO0o00 ) > 0 :
     if 47 - 47: IiI11Ii111 / I11iiIi11i1I
     return OooOoO0o00
     if 52 - 52: Ii . OooOoo . i1iiIII111 * I11iiIi11i1I - iI1iII1I1I1i
   if len ( I111Ii ) == 0 :
    try :
     if 20 - 20: OooOoo % IiI11Ii111 + I1Ii1I1 + IiI11Ii111 - oOo0O00
     oo0O = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
     try :
      oo0O . connect ( ( '8.8.8.8' , 80 ) )
     except :
      oo0O . connect ( ( '127.0.0.1' , 1 ) )
     IiiiI = oo0O . getsockname ( ) [ 0 ]
     oo0O . close ( )
     OooOoO0o00 . append ( IiiiI . strip ( ) )
    except Exception as oO00oO0O :
     pass
    if len ( OooOoO0o00 ) > 0 :
     if 76 - 76: I11iiIi11i1I % IIiIIiIi11I1 % i1I
     return OooOoO0o00
     if 39 - 39: IiIIii11Ii . Oo + i1I - oOo0O00
 except Exception as OOO00OOo0oO0O :
  pass
  print ( OOO00OOo0oO0O )
  if 93 - 93: Iii1i * IIiIIiIi11I1 % i1I + i1 % Ii * i1I
  if 62 - 62: IiI11Ii111 % ooo000
  if 19 - 19: Ii / Oo % Iii1i / i1iiIII111 - OooOoo - Ooo0Ooo
  if 89 - 89: I11iiIi11i1I - IiI11Ii111
  if 61 - 61: Ii * OooOoo * I1I % i1iiIII111 % IIiIIiIi11I1 * I11iiIi11i1I
 return OooOoO0o00
 if 49 - 49: iI1iII1I1I1i / i1iiIII111 % oOO
 if 46 - 46: ooOOO * IIiIIiIi11I1 % i1 / oOO + i1 + oOo0O00
class wgMjControllerConfigure ( object ) :
 def __init__ ( self ) :
  self . needUpdate = [ 0 ] * 64
  self . paramData = [ 0 ] * 512
  self . paramMaxLen = 512
  if 99 - 99: I1I * IIiIIiIi11I1 * i1iiIII111
  if 62 - 62: ooOOO % Oo + i1I
  if 87 - 87: ooo000 - OooOoo + Ii + i1i1i1111I + IiIIii11Ii
 def IsValidNO_ReaderDoor ( self , value ) :
  return ( value >= 1 ) and ( value <= 4 )
  if 57 - 57: IIiIIiIi11I1 + I1I / ooOOO % ooOOO % Oo / IiI11Ii111
 def SetUpdateBits ( self , paramloc , paramByteLen ) :
  if ( paramloc < self . paramMaxLen ) and ( paramloc + paramByteLen < self . paramMaxLen ) :
   for I1 in range ( paramloc , paramloc + paramByteLen ) :
    self . needUpdate [ I1 >> 3 ] |= ( 1 << ( I1 & 0x7 ) )
    if 95 - 95: i1 / I11iiIi11i1I . i1 / Oo . Ooo0Ooo
 def SetIntValue ( self , paramLoc , value ) :
  if paramLoc < len ( self . paramData ) :
   self . paramData [ paramLoc ] = value & 0xff
   self . paramData [ paramLoc + 1 ] = ( value >> 8 ) & 0xff
   self . SetUpdateBits ( paramLoc , 2 )
   if 43 - 43: Oo - OooOoo * oOO . Ooo0Ooo / IIiIIiIi11I1 * IIiIIiIi11I1
   if 84 - 84: i1iiIII111 + oOo0O00
 def SetByteValue ( self , paramLoc , value ) :
  if paramLoc < len ( self . paramData ) :
   self . paramData [ paramLoc ] = value & 0xff
   self . SetUpdateBits ( paramLoc , 1 )
   if 83 - 83: i1i1i1111I
   if 84 - 84: oOO / Ii * Ooo0Ooo / Ii / ooo000
   if 64 - 64: oOo0O00 * Ii
 def DoorControlSet ( self , DoorNO , value ) :
  if self . IsValidNO_ReaderDoor ( DoorNO ) :
   self . paramData [ 2 + 8 + ( DoorNO - 1 ) ] = ( value & 0xff )
   self . SetUpdateBits ( 2 + 8 + ( DoorNO - 1 ) , 1 )
   if 2 - 2: IiI11Ii111 % i1iiIII111 . oOo0O00
   if 59 - 59: I11iiIi11i1I % OooOoo - iI1iII1I1I1i % I1I + i1iiIII111 . I1Ii1I1
 def DoorDelaySet ( self , DoorNO , value ) :
  if DoorNO <= 4 :
   self . SetIntValue ( 2 + ( DoorNO - 1 ) * 2 , ( value * 10 ) )
   if 94 - 94: ooOOO * I1Ii1I1 * i1iiIII111 . oOo0O00
   if 73 - 73: I1Ii1I1 / ooo000 % I11iiIi11i1I - i1i1i1111I + Oo - I1Ii1I1
def setusercardChangeTime ( ) :
 vwAppConfigParam . usercardChangeTime = time . time ( )
 if 18 - 18: i1 + ooOOO . i1 - iI1iII1I1I1i
 if 97 - 97: oOo0O00 + i1I % Iii1i
def setcontrollerdoorChangeTime ( ) :
 vwAppConfigParam . controllerdoorChangeTime = time . time ( )
 if 34 - 34: i1 + Oo . oOo0O00 - ooo000 / I11iiIi11i1I * oOo0O00
 if 89 - 89: oOo0O00
class WGTools ( object ) :
 if 48 - 48: i1 / IIiIIiIi11I1 / iI1iII1I1I1i / IiI11Ii111 * IiIIii11Ii
 if 54 - 54: IIiIIiIi11I1 % I1I % IiI11Ii111 / 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
 @ classmethod
 def log ( self , info ) :
  print ( "{0} {1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , info ) )
  if 55 - 55: i1i1i1111I * Ii % i1i1i1111I
 @ staticmethod
 def getLongByByte ( data , startIndex , bytlen ) :
  OoOOo = - 1
  if ( bytlen >= 1 ) and ( bytlen <= 8 ) :
   OoOOo = data [ startIndex + bytlen - 1 ]
   for I1 in range ( 1 , bytlen ) :
    OoOOo <<= 8
    OoOOo += ( data [ startIndex + bytlen - 1 - I1 ] )
  return OoOOo
  if 61 - 61: oOo0O00
  if 53 - 53: Ooo0Ooo / IiIIii11Ii
 @ staticmethod
 def longToByte ( number , data , startIndex , bytlen ) :
  for I1 in range ( 0 , bytlen ) :
   data [ startIndex + I1 ] = ( number % 256 )
   number >>= 8
   if 49 - 49: ooo000 - oOO . IiIIii11Ii / Oo
 @ staticmethod
 def getBCD ( val ) :
  return int ( ( ( val % 10 ) + ( ( ( val - ( val % 10 ) ) / 10 ) % 10 ) * 16 ) )
  if 23 - 23: I11iiIi11i1I - i1 / Iii1i . iI1iII1I1I1i + oOO
 @ staticmethod
 def getHexString1Byte ( val ) :
  OoOOoooo0O0ooooo0o = ""
  o0oOO = val
  OoOOoooo0O0ooooo0o = OoOOoooo0O0ooooo0o + "{0:02X}" . format ( o0oOO & 0xff )
  return OoOOoooo0O0ooooo0o
  if 30 - 30: Ii / I11iiIi11i1I / i1 + i1I * i1iiIII111
 @ staticmethod
 def getHexString2Byte ( val ) :
  OoOOoooo0O0ooooo0o = ""
  o0oOO = val
  for oo00oO in range ( 0 , 2 ) :
   OoOOoooo0O0ooooo0o = OoOOoooo0O0ooooo0o + "{0:02X}" . format ( o0oOO & 0xff )
   o0oOO = o0oOO >> 8
  return OoOOoooo0O0ooooo0o
  if 39 - 39: oOO . I1Ii1I1 % Ooo0Ooo
 @ staticmethod
 def getHexString4Byte ( val ) :
  OoOOoooo0O0ooooo0o = ""
  o0oOO = val
  for oo00oO in range ( 0 , 4 ) :
   OoOOoooo0O0ooooo0o = OoOOoooo0O0ooooo0o + "{0:02X}" . format ( o0oOO & 0xff )
   o0oOO = o0oOO >> 8
  return OoOOoooo0O0ooooo0o
  if 72 - 72: IiIIii11Ii . ooo000 * i1iiIII111 % Ooo0Ooo
 @ staticmethod
 def getHexString8Byte ( val ) :
  OoOOoooo0O0ooooo0o = ""
  o0oOO = val
  for oo00oO in range ( 0 , 8 ) :
   OoOOoooo0O0ooooo0o = OoOOoooo0O0ooooo0o + "{0:02X}" . format ( o0oOO & 0xff )
   o0oOO = o0oOO >> 8
  return OoOOoooo0O0ooooo0o
  if 53 - 53: ooo000 + I1Ii1I1
  if 97 - 97: i1 - oOo0O00 / OooOoo * Ii - oOO
 @ staticmethod
 def crc8 ( buf , buflen ) :
  O0oOoOoO0o = 0 ;
  for O00 in range ( 0 , buflen ) :
   O0oOoOoO0o = ( O0oOoOoO0o ^ ( buf [ O00 ] ) ) & 0xff
   for I1 in range ( 0 , 8 ) :
    if ( O0oOoOoO0o & 0x80 ) > 0 :
     O0oOoOoO0o = ( ( O0oOoOoO0o << 1 ) ^ 0x31 ) & 0xff
    else :
     O0oOoOoO0o = ( O0oOoOoO0o << 1 ) & 0xff
  return O0oOoOoO0o ;
  if 25 - 25: ooOOO
  if 49 - 49: IiI11Ii111 % i1i1i1111I . i1I / oOO * IIiIIiIi11I1 / I1I
 @ staticmethod
 def getYMD ( Year , Month , Day ) :
  OoiIi111iIi1III = ( Year % 100 ) << 9
  OoiIi111iIi1III += ( Month << 5 )
  OoiIi111iIi1III += Day
  return OoiIi111iIi1III
  if 60 - 60: IiIIii11Ii * ooOOO + I11iiIi11i1I + iI1iII1I1I1i - Oo
  if 93 - 93: I1I + i1iiIII111 + Ii - i1I
 @ staticmethod
 def getHMS ( Hour , Minute , Second ) :
  iI = 0
  iI += ( Second >> 1 )
  iI += Minute << 5
  iI += Hour << 11
  return iI
  if 71 - 71: Ooo0Ooo % OooOoo + i1iiIII111 / ooo000 / i1I
 @ staticmethod
 def getHexString ( arrbyte ) :
  OoOOoooo0O0ooooo0o = ""
  I11III111I = len ( arrbyte )
  for oo00oO in range ( 0 , I11III111I ) :
   OoOOoooo0O0ooooo0o = OoOOoooo0O0ooooo0o + "{0:02X}" . format ( arrbyte [ oo00oO ] & 0xff )
  return OoOOoooo0O0ooooo0o
  if 59 - 59: IiIIii11Ii * I1Ii1I1
 @ staticmethod
 def getarrStringWithsplitDou ( cmdarr ) :
  I11i = ''
  for O0 in cmdarr :
   if I11i == '' :
    I11i += O0
   else :
    I11i += ',' + O0
  return I11i
  if 68 - 68: i1i1i1111I
 @ staticmethod
 def IsElevator ( sn ) :
  return 176 * 10 ** 6 > sn > 170 * 10 ** 6
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
