import configparser
if 82 - 82: Iii1i
from flask import Blueprint , render_template , request , g , redirect , url_for , flash
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from hooks import wgcomm_before_request
from vwAppConfigParam import vwAppConfigParam , loadvw3000param
from forms . wgcommform import *
from decorators import login_required
import vwAppConfig
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
__all__ = [
 "bp" ,
 "web_extern_setup_list" ,
"web_extern_setup_edit" ,
]
bp = Blueprint ( 'wgcomm_extern_setup' , __name__ , url_prefix = '/' )
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
def i1ii1 ( paramval , paramName ) :
 ooo0O0oO00 = configparser . ConfigParser ( allow_no_value = True )
 ooo0O0oO00 . read ( vwAppConfigParam . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if ( ooo0O0oO00 . has_option ( 'wgconf' , paramName ) ) :
  paramval = ooo0O0oO00 [ 'wgconf' ] [ paramName ]
 return paramval
 if 55 - 55: I11II1Ii % iIi
 if 76 - 76: I11II1Ii / Iii1i / Ii . i1i1i1111I / Ii
def ooO0Oo0o00 ( paramval , paramName ) :
 ooo0O0oO00 = configparser . ConfigParser ( allow_no_value = True )
 ooo0O0oO00 . read ( vwAppConfigParam . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if ( ooo0O0oO00 . has_option ( 'wgconf' , paramName ) ) :
  paramval = int ( ooo0O0oO00 [ 'wgconf' ] [ paramName ] )
 return paramval
 if 74 - 74: IIiIIiIi11I1 / I1I - Oo . Ooo0Ooo
@ bp . route ( '/extern_setup_list' , methods = [ 'GET' , 'POST' ] )
@ bp . route ( '/5678' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_setup_list ( ) :
 OO0o000o = extern_setup_form ( )
 OO0o000o . f_extfunc5678_record_doorstatus_pb . data = ooO0Oo0o00 ( 0 , "extfunc5678_record_doorstatus_pb" ) > 0
 OO0o000o . f_extfunc5678_multi_card . data = ooO0Oo0o00 ( 0 , "extfunc5678_multi_card" ) > 0
 OO0o000o . f_extfunc5678_fire_warn . data = ooO0Oo0o00 ( 0 , "extfunc5678_fire_warn" ) > 0
 if 8 - 8: i1iiIII111 * i1 . I1I / oOO
 OO0o000o . f_extfunc5678_inter_lock . data = ooO0Oo0o00 ( 0 , "extfunc5678_inter_lock" ) > 0
 OO0o000o . f_extfunc5678_valid_swipe_gap . data = ooO0Oo0o00 ( 0 , "extfunc5678_valid_swipe_gap" ) > 0
 OO0o000o . f_extfunc5678_timeprofile . data = ooO0Oo0o00 ( 0 , "extfunc5678_timeprofile" ) > 0
 OO0o000o . f_extfunc5678_Meal . data = ooO0Oo0o00 ( 0 , "extfunc5678_Meal" ) > 0
 OO0o000o . f_extfunc5678_anti_back . data = ooO0Oo0o00 ( 0 , "extfunc5678_anti_back" ) > 0
 OO0o000o . f_extfunc5678_one_key . data = ooO0Oo0o00 ( 0 , "extfunc5678_one_key" ) > 0
 OO0o000o . f_extfunc5678_tasklist . data = ooO0Oo0o00 ( 0 , "extfunc5678_tasklist" ) > 0
 OO0o000o . f_extfunc5678_elevator . data = ooO0Oo0o00 ( 0 , "extfunc5678_elevator" ) > 0
 OO0o000o . f_extfunc5678_console_displayMoreLog . data = ooO0Oo0o00 ( 0 , "extfunc5678_console_displayMoreLog" ) > 0
 OO0o000o . f_extfunc5678_console_location_query . data = ooO0Oo0o00 ( 0 , "extfunc5678_console_location_query" ) > 0
 if 58 - 58: I1Ii1I1 - ooOOO
 if 60 - 60: iI1iII1I1I1i . oOO
 i1iiiiIIIiIi = i1ii1 ( "" , "allowpcip" )
 II = i1ii1 ( "" , "whitelist" )
 OO0o000o . f_extfunc5678_firewall . data = len ( i1iiiiIIIiIi ) + len ( II ) > 0
 OO0o000o . f_extfunc5678_develop_mode . data = vwAppConfigParam . extfunc5678_develop_mode > 0
 OO0000 = {
 "wgform" : OO0o000o ,
 }
 if 92 - 92: I1I / I1I + I11II1Ii . oOO
 return render_template ( "wgcomm/extern-setup-list.html" , ** OO0000 )
 if 8 - 8: Ii + I11II1Ii . I11iiIi11i1I - I1Ii1I1 % I11iiIi11i1I . i1i1i1111I
@ bp . route ( '/extern_setup_edit' , methods = [ 'POST' ] )
@ login_required
def web_extern_setup_edit ( ) :
 if request . form . get ( "submitcancel" ) is not None :
  if 24 - 24: iIi
  return redirect ( url_for ( "wgcomm.web_index" ) )
  if 9 - 9: ooo000 / I11II1Ii . I11II1Ii / Ii % i1i1i1111I % Ooo0Ooo
 if request . form . get ( 'submitsaveandadd' ) :
  OO0o000o = extern_setup_form ( )
  OO0000 = {
 "wgform" : OO0o000o ,
 }
  return render_template ( "wgcomm/extern-setup-list.html" , ** OO0000 )
 if request . form . get ( 'submitsave' ) :
  OO0o000o = extern_setup_form ( request . form )
  if OO0o000o . validate ( ) :
   ooo0O0oO00 = configparser . ConfigParser ( allow_no_value = True )
   ooo0O0oO00 . read ( vwAppConfigParam . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
   if not ooo0O0oO00 . has_section ( 'wgconf' ) :
    ooo0O0oO00 . add_section ( 'wgconf' )
   O00Oo = [ [ 'extfunc5678_record_doorstatus_pb' , OO0o000o . f_extfunc5678_record_doorstatus_pb . data ] ,
 [ 'extfunc5678_multi_card' , OO0o000o . f_extfunc5678_multi_card . data ] ,
 [ 'extfunc5678_fire_warn' , OO0o000o . f_extfunc5678_fire_warn . data ] ,

   [ 'extfunc5678_inter_lock' , OO0o000o . f_extfunc5678_inter_lock . data ] ,
 [ 'extfunc5678_valid_swipe_gap' , OO0o000o . f_extfunc5678_valid_swipe_gap . data ] ,
 [ 'extfunc5678_timeprofile' , OO0o000o . f_extfunc5678_timeprofile . data ] ,
 [ 'extfunc5678_Meal' , OO0o000o . f_extfunc5678_Meal . data ] ,
 [ 'extfunc5678_anti_back' , OO0o000o . f_extfunc5678_anti_back . data ] ,
 [ 'extfunc5678_one_key' , OO0o000o . f_extfunc5678_one_key . data ] ,
 [ 'extfunc5678_tasklist' , OO0o000o . f_extfunc5678_tasklist . data ] ,
 [ 'extfunc5678_elevator' , OO0o000o . f_extfunc5678_elevator . data ] ,
 [ 'extfunc5678_console_displayMoreLog' , OO0o000o . f_extfunc5678_console_displayMoreLog . data ] ,
 [ 'extfunc5678_console_location_query' , OO0o000o . f_extfunc5678_console_location_query . data ] ,
 [ 'extfunc5678_develop_mode' , OO0o000o . f_extfunc5678_develop_mode . data ] ,
 ]
   for O00O in O00Oo :
    if O00O [ 1 ] :
     ooo0O0oO00 . set ( 'wgconf' , O00O [ 0 ] , '1' if O00O [ 1 ] else '0' )
    else :
     ooo0O0oO00 . remove_option ( 'wgconf' , O00O [ 0 ] )
     if 59 - 59: Iii1i . iIi - I11II1Ii
   i1iiiiIIIiIi = i1ii1 ( "" , "allowpcip" )
   II = i1ii1 ( "" , "whitelist" )
   ii1IiIiiII = ""
   I1I111i11I = ""
   if OO0o000o . f_extfunc5678_firewall . data :
    ii1IiIiiII = "127.0.0.1"
    I1I111i11I = "127.0.0.1"
   if i1iiiiIIIiIi != ii1IiIiiII or II != I1I111i11I :
    if len ( ii1IiIiiII ) :
     ooo0O0oO00 . set ( 'wgconf' , "allowpcip" , ii1IiIiiII )
    else :
     ooo0O0oO00 . remove_option ( 'wgconf' , "allowpcip" )
    if len ( I1I111i11I ) :
     ooo0O0oO00 . set ( 'wgconf' , "whitelist" , I1I111i11I )
    else :
     ooo0O0oO00 . remove_option ( 'wgconf' , "whitelist" )
     if 85 - 85: OooOoo
    o00 = {
 "jsonrpc" : "2.0" ,
 "method" : "ExternFunctions" ,
 "params" : [
 {
 "FunctionName" : "SoftwareRestart"
 }
 ] ,
 "id" : 4001
 }
    vwAppConfig . sendByHttp ( o00 , 1 )
    if 20 - 20: iIi + i1iiIII111 / I1I
   ooo0O0oO00 . write ( open ( vwAppConfigParam . wgcloudpath1001configfileName , 'w' ) )
   flash ( "Parameter modification successful! Takes effect only after uploading settings in the main console!!!" )
   loadvw3000param ( )
   wgcomm_before_request ( )
   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
 return web_extern_setup_list ( )
 if 88 - 88: Oo * IiIIii11Ii
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
