Appease the linter

This commit is contained in:
Andrew 2023-02-15 18:40:20 -05:00
parent 491415c7fa
commit e52294dbb3
4 changed files with 9 additions and 9 deletions

View File

@ -163,7 +163,7 @@ class ServersController(metaclass=Singleton):
return server["server_obj"] return server["server_obj"]
logger.warning(f"Unable to find server object for server id {server_id}") logger.warning(f"Unable to find server object for server id {server_id}")
raise Exception(f"Unable to find server object for server id {server_id}") raise ValueError(f"Unable to find server object for server id {server_id}")
def init_all_servers(self): def init_all_servers(self):
servers = self.get_all_defined_servers() servers = self.get_all_defined_servers()

View File

@ -123,7 +123,7 @@ def ping(ip, port):
try: try:
k = sock.recv(1) k = sock.recv(1)
if not k: if not k:
raise Exception() raise ValueError()
except: except:
return 0 return 0
k = k[0] k = k[0]

View File

@ -94,7 +94,7 @@ class Helpers:
try: try:
# Get tags from Gitlab, select the latest and parse the semver # Get tags from Gitlab, select the latest and parse the semver
response = get( response = get(
"https://gitlab.com/api/v4/projects/20430749/repository/tags" "https://gitlab.com/api/v4/projects/20430749/repository/tags", timeout=1
) )
if response.status_code == 200: if response.status_code == 200:
remote_version = pkg_version.parse(json.loads(response.text)[0]["name"]) remote_version = pkg_version.parse(json.loads(response.text)[0]["name"])
@ -131,7 +131,7 @@ class Helpers:
try: try:
# Get minecraft server download page # Get minecraft server download page
# (hopefully the don't change the structure) # (hopefully the don't change the structure)
download_page = get(url, headers=headers) download_page = get(url, headers=headers, timeout=1)
# Search for our string targets # Search for our string targets
win_download_url = re.search(target_win, download_page.text).group(0) win_download_url = re.search(target_win, download_page.text).group(0)
@ -281,7 +281,7 @@ class Helpers:
@staticmethod @staticmethod
def check_port(server_port): def check_port(server_port):
try: try:
ip = get("https://api.ipify.org").content.decode("utf8") ip = get("https://api.ipify.org", timeout=1).content.decode("utf8")
except: except:
ip = "google.com" ip = "google.com"
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@ -751,7 +751,7 @@ class Helpers:
use_ssl=True, use_ssl=True,
) # + "?d=404" ) # + "?d=404"
try: try:
if requests.head(url).status_code != 404: if requests.head(url, timeout=1).status_code != 404:
profile_url = url profile_url = url
except Exception as e: except Exception as e:
logger.debug(f"Could not pull resource from Gravatar with error {e}") logger.debug(f"Could not pull resource from Gravatar with error {e}")

View File

@ -347,7 +347,7 @@ class Controller:
elif root_create_data["create_type"] == "import_zip": elif root_create_data["create_type"] == "import_zip":
# TODO: Copy files from the zip file to the new server directory # TODO: Copy files from the zip file to the new server directory
server_file = create_data["jarfile"] server_file = create_data["jarfile"]
raise Exception("Not yet implemented") raise NotImplementedError("Not yet implemented")
_create_server_properties_if_needed( _create_server_properties_if_needed(
create_data["server_properties_port"], create_data["server_properties_port"],
) )
@ -379,7 +379,7 @@ class Controller:
logger.error(f"Server import failed with error: {ex}") logger.error(f"Server import failed with error: {ex}")
elif root_create_data["create_type"] == "import_zip": elif root_create_data["create_type"] == "import_zip":
# TODO: Copy files from the zip file to the new server directory # TODO: Copy files from the zip file to the new server directory
raise Exception("Not yet implemented") raise NotImplementedError("Not yet implemented")
_create_server_properties_if_needed(0, True) _create_server_properties_if_needed(0, True)
@ -401,7 +401,7 @@ class Controller:
logger.error(f"Server import failed with error: {ex}") logger.error(f"Server import failed with error: {ex}")
elif root_create_data["create_type"] == "import_zip": elif root_create_data["create_type"] == "import_zip":
# TODO: Copy files from the zip file to the new server directory # TODO: Copy files from the zip file to the new server directory
raise Exception("Not yet implemented") raise NotImplementedError("Not yet implemented")
_create_server_properties_if_needed(0, True) _create_server_properties_if_needed(0, True)