From be82c164124adf54b86e058a51d07774f6e2c11c Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Wed, 6 May 2020 20:17:33 +0100 Subject: [PATCH] - satisfy pylint recommendations against logging f-strings --- perguntations/serve.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/perguntations/serve.py b/perguntations/serve.py index 73ea8f5..c9a03a8 100644 --- a/perguntations/serve.py +++ b/perguntations/serve.py @@ -63,7 +63,8 @@ class WebApplication(tornado.web.Application): # ---------------------------------------------------------------------------- def admin_only(func): ''' - Decorator used to restrict access to the administrator. For example: + Decorator used to restrict access to the administrator. + Example: @admin_only() def get(self): ... @@ -91,7 +92,7 @@ class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): ''' - HTML is stateless, so a cookie is used to identify the user. + Since HTTP is stateless, a cookie is used to identify the user. This function returns the cookie for the current user. ''' cookie = self.get_secure_cookie('user') @@ -253,7 +254,7 @@ class AdminHandler(BaseHandler): name=student['name']) else: - logging.error(f'Unknown command: "{cmd}"') + logging.error('Unknown command: "%s"', cmd) # ---------------------------------------------------------------------------- @@ -346,11 +347,11 @@ class FileHandler(BaseHandler): try: file = open(filepath, 'rb') except FileNotFoundError: - logging.error(f'File not found: {filepath}') + logging.error('File not found: %s', filepath) except PermissionError: - logging.error(f'No permission: {filepath}') + logging.error('No permission: %s', filepath) except OSError: - logging.error(f'Error opening file: {filepath}') + logging.error('Error opening file: %s', filepath) else: data = file.read() file.close() @@ -475,7 +476,7 @@ class ReviewHandler(BaseHandler): Opens JSON file with a given corrected test and renders it ''' test_id = self.get_query_argument('test_id', None) - logging.info(f'Review test {test_id}.') + logging.info('Review test %s.', test_id) fname = self.testapp.get_json_filename_of_test(test_id) if fname is None: @@ -530,10 +531,10 @@ def run_webserver(app, ssl_opt, port, debug): try: httpserver.listen(port) except OSError: - logging.critical(f'Cannot bind port {port}. Already in use?') + logging.critical('Cannot bind port %d. Already in use?', port) sys.exit(1) - logging.info(f'Webserver listening on {port}... (Ctrl-C to stop)') + logging.info('Webserver listening on %d... (Ctrl-C to stop)', port) signal.signal(signal.SIGINT, signal_handler) # --- run webserver -- libgit2 0.21.2