Commit be82c164124adf54b86e058a51d07774f6e2c11c

Authored by Miguel Barão
1 parent 74635609
Exists in master and in 1 other branch dev

- satisfy pylint recommendations against logging f-strings

Showing 1 changed file with 10 additions and 9 deletions   Show diff stats
perguntations/serve.py
@@ -63,7 +63,8 @@ class WebApplication(tornado.web.Application): @@ -63,7 +63,8 @@ class WebApplication(tornado.web.Application):
63 # ---------------------------------------------------------------------------- 63 # ----------------------------------------------------------------------------
64 def admin_only(func): 64 def admin_only(func):
65 ''' 65 '''
66 - Decorator used to restrict access to the administrator. For example: 66 + Decorator used to restrict access to the administrator.
  67 + Example:
67 68
68 @admin_only() 69 @admin_only()
69 def get(self): ... 70 def get(self): ...
@@ -91,7 +92,7 @@ class BaseHandler(tornado.web.RequestHandler): @@ -91,7 +92,7 @@ class BaseHandler(tornado.web.RequestHandler):
91 92
92 def get_current_user(self): 93 def get_current_user(self):
93 ''' 94 '''
94 - HTML is stateless, so a cookie is used to identify the user. 95 + Since HTTP is stateless, a cookie is used to identify the user.
95 This function returns the cookie for the current user. 96 This function returns the cookie for the current user.
96 ''' 97 '''
97 cookie = self.get_secure_cookie('user') 98 cookie = self.get_secure_cookie('user')
@@ -253,7 +254,7 @@ class AdminHandler(BaseHandler): @@ -253,7 +254,7 @@ class AdminHandler(BaseHandler):
253 name=student['name']) 254 name=student['name'])
254 255
255 else: 256 else:
256 - logging.error(f'Unknown command: "{cmd}"') 257 + logging.error('Unknown command: "%s"', cmd)
257 258
258 259
259 # ---------------------------------------------------------------------------- 260 # ----------------------------------------------------------------------------
@@ -346,11 +347,11 @@ class FileHandler(BaseHandler): @@ -346,11 +347,11 @@ class FileHandler(BaseHandler):
346 try: 347 try:
347 file = open(filepath, 'rb') 348 file = open(filepath, 'rb')
348 except FileNotFoundError: 349 except FileNotFoundError:
349 - logging.error(f'File not found: {filepath}') 350 + logging.error('File not found: %s', filepath)
350 except PermissionError: 351 except PermissionError:
351 - logging.error(f'No permission: {filepath}') 352 + logging.error('No permission: %s', filepath)
352 except OSError: 353 except OSError:
353 - logging.error(f'Error opening file: {filepath}') 354 + logging.error('Error opening file: %s', filepath)
354 else: 355 else:
355 data = file.read() 356 data = file.read()
356 file.close() 357 file.close()
@@ -475,7 +476,7 @@ class ReviewHandler(BaseHandler): @@ -475,7 +476,7 @@ class ReviewHandler(BaseHandler):
475 Opens JSON file with a given corrected test and renders it 476 Opens JSON file with a given corrected test and renders it
476 ''' 477 '''
477 test_id = self.get_query_argument('test_id', None) 478 test_id = self.get_query_argument('test_id', None)
478 - logging.info(f'Review test {test_id}.') 479 + logging.info('Review test %s.', test_id)
479 fname = self.testapp.get_json_filename_of_test(test_id) 480 fname = self.testapp.get_json_filename_of_test(test_id)
480 481
481 if fname is None: 482 if fname is None:
@@ -530,10 +531,10 @@ def run_webserver(app, ssl_opt, port, debug): @@ -530,10 +531,10 @@ def run_webserver(app, ssl_opt, port, debug):
530 try: 531 try:
531 httpserver.listen(port) 532 httpserver.listen(port)
532 except OSError: 533 except OSError:
533 - logging.critical(f'Cannot bind port {port}. Already in use?') 534 + logging.critical('Cannot bind port %d. Already in use?', port)
534 sys.exit(1) 535 sys.exit(1)
535 536
536 - logging.info(f'Webserver listening on {port}... (Ctrl-C to stop)') 537 + logging.info('Webserver listening on %d... (Ctrl-C to stop)', port)
537 signal.signal(signal.SIGINT, signal_handler) 538 signal.signal(signal.SIGINT, signal_handler)
538 539
539 # --- run webserver 540 # --- run webserver