diff --git a/app/classes/shared/command.py b/app/classes/shared/command.py index 5306b8e5..112effbb 100644 --- a/app/classes/shared/command.py +++ b/app/classes/shared/command.py @@ -79,7 +79,7 @@ class MainPrompt(cmd.Cmd): @staticmethod def help_migrations(): console.help("Only for advanced users. Use with caution") - + @staticmethod def help_import3(): console.help("Import users and servers from Crafty 3") diff --git a/app/classes/shared/import3.py b/app/classes/shared/import3.py index db9670b7..0d244460 100644 --- a/app/classes/shared/import3.py +++ b/app/classes/shared/import3.py @@ -19,9 +19,9 @@ class import3: console.info("Crafty cannot find the path you entered. Does Crafty's user have permission to access it?") console.info("Please run the import3 command again and enter a valid path.") else: - with open (os.path.join(folder, "users.json")) as f: + with open (os.path.join(folder, "users.json"), encoding="utf-8") as f: user_json = json.loads(f.read()) - with open (os.path.join(folder, "mc_settings.json")) as f: + with open (os.path.join(folder, "mc_settings.json", encoding="utf-8")) as f: servers_json = json.loads(f.read()) self.import_users(user_json) self.import_servers(servers_json, self.controller) @@ -43,15 +43,16 @@ class import3: # If there is only one server to import json needs to call the data differently if isinstance(json_data, list): for server in json_data: - new_server_id = controller.import_jar_server(server_name=server['server_name'], server_path=server['server_path'], server_jar=server['server_jar'], - min_mem=(int(server['memory_min'])/1000), max_mem=(int(server['memory_max'])/1000), port=server['server_port']) + new_server_id = controller.import_jar_server(server_name=server['server_name'], server_path=server['server_path'], + server_jar=server['server_jar'], min_mem=(int(server['memory_min'])/1000), + max_mem=(int(server['memory_max'])/1000), port=server['server_port']) console.info(f"Imported server {server['server_name']}[{server['id']}] from Crafty 3 to new server id {new_server_id}") logger.info(f"Imported server {server['server_name']}[{server['id']}] from Crafty 3 to new server id {new_server_id}") else: - new_server_id = controller.import_jar_server(server_name=json_data['server_name'], server_path=json_data['server_path'], server_jar=json_data['server_jar'], - min_mem=(int(json_data['memory_min'])/1000), max_mem=(int(json_data['memory_max'])/1000), port=json_data['server_port']) + new_server_id = controller.import_jar_server(server_name=json_data['server_name'], server_path=json_data['server_path'], + server_jar=json_data['server_jar'], min_mem=(int(json_data['memory_min'])/1000), + max_mem=(int(json_data['memory_max'])/1000), port=json_data['server_port']) console.info(f"Imported server {json_data['server_name']}[{json_data['id']}] from Crafty 3 to new server id {new_server_id}") logger.info(f"Imported server {json_data['server_name']}[{json_data['id']}] from Crafty 3 to new server id {new_server_id}") - -import3 = import3() \ No newline at end of file +import3 = import3() diff --git a/app/classes/web/public_handler.py b/app/classes/web/public_handler.py index 72d2d4aa..80363afb 100644 --- a/app/classes/web/public_handler.py +++ b/app/classes/web/public_handler.py @@ -96,7 +96,7 @@ class PublicHandler(BaseHandler): if page == 'login': next_page = "/public/login" - if (self.request.query): + if self.request.query: next_page = '/public/login?'+self.request.query entered_username = bleach.clean(self.get_argument('username')) @@ -112,7 +112,7 @@ class PublicHandler(BaseHandler): #self.clear_cookie("user") #self.clear_cookie("user_data") self.clear_cookie("token") - if (self.request.query): + if self.request.query: self.redirect(f'/public/login?error_msg={error_msg}&{self.request.query}') else: self.redirect(f'/public/login?error_msg={error_msg}') @@ -124,7 +124,7 @@ class PublicHandler(BaseHandler): #self.clear_cookie("user") #self.clear_cookie("user_data") self.clear_cookie("token") - if (self.request.query): + if self.request.query: self.redirect(f'/public/login?error_msg={error_msg}&{self.request.query}') else: self.redirect(f'/public/login?error_msg={error_msg}') @@ -160,7 +160,7 @@ class PublicHandler(BaseHandler): error_msg = "Inncorrect username or password. Please try again." # log this failed login attempt self.controller.management.add_to_audit_log(user_data.user_id, "Tried to log in", 0, self.get_remote_ip()) - if (self.request.query): + if self.request.query: self.redirect(f'/public/login?error_msg={error_msg}&{self.request.query}') else: self.redirect(f'/public/login?error_msg={error_msg}')