3131
3232# Sentry setup 
3333sentry_sdk .init (
34-     dsn = app .config [" SENTRY_DSN"  ],
34+     dsn = app .config [' SENTRY_DSN'  ],
3535    integrations = [FlaskIntegration (), SqlalchemyIntegration ()],
36-     environment = app .config [" SENTRY_ENV"  ],
36+     environment = app .config [' SENTRY_ENV'  ],
3737)
3838
39- ldap  =  CSHLDAP (
40-     app . config [ "LDAP_BIND_DN" ],  app .config [" LDAP_BIND_PW" ],  ro = app . config [ "LDAP_RO" ] 
41- )
39+ ldap  =  CSHLDAP (app . config [ 'LDAP_BIND_DN' ], 
40+                 app .config [' LDAP_BIND_PW' ], 
41+                 ro = app . config [ 'LDAP_RO' ] )
4242
4343client_metadata  =  ClientMetadata (app .config ["OIDC_CLIENT_CONFIG" ])
44- provider_config  =  ProviderConfiguration (
45-     issuer = app .config ["OIDC_ISSUER" ], client_registration_info = client_metadata 
46- )
47- frosh_provider_config  =  ProviderConfiguration (
48-     issuer = app .config ["FROSH_OIDC_ISSUER" ], client_registration_info = client_metadata 
49- )
44+ provider_config  =  ProviderConfiguration (issuer = app .config ["OIDC_ISSUER" ], client_registration_info = client_metadata )
5045
51- auth  =  OIDCAuthentication (
52-     {"default" : provider_config , "frosh" : frosh_provider_config }, app 
53- )
46+ auth  =  OIDCAuthentication ({'default' : provider_config }, app )
5447
5548app .secret_key  =  app .config ["SECRET_KEY" ]
5649
@@ -67,48 +60,42 @@ def start_of_year():
6760
6861
6962# Configure Logging 
70- def  request_processor (
71-     logger , log_method , event_dict 
72- ):  # pylint: disable=unused-argument, redefined-outer-name 
73-     if  "request"  in  event_dict :
74-         flask_request  =  event_dict ["request" ]
75-         event_dict ["ip" ] =  flask_request .remote_addr 
76-         event_dict ["method" ] =  flask_request .method 
77-         event_dict ["blueprint" ] =  flask_request .blueprint 
78-         event_dict ["path" ] =  flask_request .full_path 
79-     if  "auth_dict"  in  event_dict :
80-         auth_dict  =  event_dict ["auth_dict" ]
81-         event_dict ["user" ] =  auth_dict ["username" ]
63+ def  request_processor (logger , log_method , event_dict ):  # pylint: disable=unused-argument, redefined-outer-name 
64+     if  'request'  in  event_dict :
65+         flask_request  =  event_dict ['request' ]
66+         event_dict ['ip' ] =  flask_request .remote_addr 
67+         event_dict ['method' ] =  flask_request .method 
68+         event_dict ['blueprint' ] =  flask_request .blueprint 
69+         event_dict ['path' ] =  flask_request .full_path 
70+     if  'auth_dict'  in  event_dict :
71+         auth_dict  =  event_dict ['auth_dict' ]
72+         event_dict ['user' ] =  auth_dict ['username' ]
8273    return  event_dict 
8374
8475
85- def  database_processor (
86-     logger , log_method , event_dict 
87- ):  # pylint: disable=unused-argument, redefined-outer-name 
88-     if  "request"  in  event_dict :
89-         if  event_dict ["method" ] !=  "GET" :
76+ def  database_processor (logger , log_method , event_dict ):  # pylint: disable=unused-argument, redefined-outer-name 
77+     if  'request'  in  event_dict :
78+         if  event_dict ['method' ] !=  'GET' :
9079            log  =  UserLog (
91-                 ipaddr = event_dict ["ip" ],
92-                 user = event_dict [" user"  ],
93-                 method = event_dict [" method"  ],
94-                 blueprint = event_dict [" blueprint"  ],
95-                 path = event_dict [" path"  ],
96-                 description = event_dict [" event" ], 
80+                 ipaddr = event_dict ['ip' ],
81+                 user = event_dict [' user'  ],
82+                 method = event_dict [' method'  ],
83+                 blueprint = event_dict [' blueprint'  ],
84+                 path = event_dict [' path'  ],
85+                 description = event_dict [' event' ] 
9786            )
9887            db .session .add (log )
9988            db .session .flush ()
10089            db .session .commit ()
101-         del  event_dict [" request"  ]
90+         del  event_dict [' request'  ]
10291    return  event_dict 
10392
10493
105- structlog .configure (
106-     processors = [
107-         request_processor ,
108-         database_processor ,
109-         structlog .processors .KeyValueRenderer (),
110-     ]
111- )
94+ structlog .configure (processors = [
95+     request_processor ,
96+     database_processor ,
97+     structlog .processors .KeyValueRenderer ()
98+ ])
11299
113100logger  =  structlog .get_logger ()
114101
@@ -128,7 +115,6 @@ def database_processor(
128115from  .blueprints .cache_management  import  cache_bp 
129116from  .blueprints .co_op  import  co_op_bp 
130117from  .blueprints .logs  import  log_bp 
131- from  .blueprints .packet  import  packet_bp 
132118
133119app .register_blueprint (dashboard_bp )
134120app .register_blueprint (attendance_bp )
@@ -143,21 +129,20 @@ def database_processor(
143129app .register_blueprint (cache_bp )
144130app .register_blueprint (co_op_bp )
145131app .register_blueprint (log_bp )
146- app .register_blueprint (packet_bp )
147132
148133from  .util .ldap  import  ldap_get_member 
149134
150135
151- @app .route (" /<path:path>"  ) 
136+ @app .route (' /<path:path>'  ) 
152137def  static_proxy (path ):
153138    # send_static_file will guess the correct MIME type 
154139    return  app .send_static_file (path )
155140
156141
157- @app .route ("/" ) 
142+ @app .route ('/' ) 
158143@auth .oidc_auth ("default" ) 
159144def  default_route ():
160-     return  redirect (" /dashboard"  )
145+     return  redirect (' /dashboard'  )
161146
162147
163148@app .route ("/logout" ) 
@@ -171,7 +156,7 @@ def health():
171156    """ 
172157    Shows an ok status if the application is up and running 
173158    """ 
174-     return  {" status" :  "ok" }
159+     return  {' status' :  'ok' }
175160
176161
177162@app .errorhandler (404 ) 
@@ -182,17 +167,17 @@ def route_errors(error, user_dict=None):
182167    data  =  {}
183168
184169    # Handle the case where the header isn't present 
185-     if  user_dict [" username"  ] is  not   None :
186-         data [" username"  ] =  user_dict [" account"  ].uid 
187-         data [" name"  ] =  user_dict [" account"  ].cn 
170+     if  user_dict [' username'  ] is  not   None :
171+         data [' username'  ] =  user_dict [' account'  ].uid 
172+         data [' name'  ] =  user_dict [' account'  ].cn 
188173    else :
189-         data [" username"  ] =  "unknown" 
190-         data [" name"  ] =  "Unknown" 
174+         data [' username'  ] =  "unknown" 
175+         data [' name'  ] =  "Unknown" 
191176
192177    # Figure out what kind of error was passed 
193178    if  isinstance (error , int ):
194179        code  =  error 
195-     elif  hasattr (error , " code"  ):
180+     elif  hasattr (error , ' code'  ):
196181        code  =  error .code 
197182    else :
198183        # Unhandled exception 
@@ -204,13 +189,11 @@ def route_errors(error, user_dict=None):
204189    else :
205190        error_desc  =  type (error ).__name__ 
206191
207-     return  render_template (
208-         "errors.html" ,
209-         error = error_desc ,
210-         error_code = code ,
211-         event_id = sentry_sdk .last_event_id (),
212-         ** data 
213-     ), int (code )
192+     return  render_template ('errors.html' ,
193+                            error = error_desc ,
194+                            error_code = code ,
195+                            event_id = sentry_sdk .last_event_id (),
196+                            ** data ), int (code )
214197
215198
216- logger .info (" conditional started"  )
199+ logger .info (' conditional started'  )
0 commit comments