Gitea response improved

This commit is contained in:
Désiré Werner Menrath 2025-04-19 14:28:34 +02:00
parent 28cc423138
commit 980ce3c7a7
2 changed files with 16 additions and 11 deletions

View File

@ -97,7 +97,8 @@ class Create:
process = subprocess.run( process = subprocess.run(
["pkexec", "/usr/local/bin/ssl_decrypt.py"], ["pkexec", "/usr/local/bin/ssl_decrypt.py"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
text=True, check=True text=True,
check=True,
) )
# print(process.stdout) # print(process.stdout)
if process.returncode == 0: if process.returncode == 0:
@ -113,7 +114,8 @@ class Create:
process = subprocess.run( process = subprocess.run(
["pkexec", "/usr/local/bin/ssl_encrypt.py"], ["pkexec", "/usr/local/bin/ssl_encrypt.py"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
text=True, check=True text=True,
check=True,
) )
print(process.stdout) print(process.stdout)
if process.returncode == 0: if process.returncode == 0:
@ -150,20 +152,22 @@ class GiteaUpdate:
Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version) Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version)
""" """
try: try:
response = requests.get(update_api_url) response = requests.get(update_api_url, timeout=10)
response_dict = response.json() response_dict = response.json()
response_dict = response_dict[0] response_dict = response_dict[0]
with open(wg_set, "r", encoding="utf-8") as set_file: with open(wg_set, "r", encoding="utf-8") as set_file:
set_file = set_file.read() set_file = set_file.read()
if "on\n" in set_file: if "on\n" in set_file:
if version[3:] != response_dict["tag_name"]: if version[3:] != response_dict["tag_name"]:
return response_dict["tag_name"] req = response_dict["tag_name"]
else: else:
return "No Updates" req = "No Updates"
else: else:
return "False" req = "False"
except requests.exceptions.ConnectionError: return req
return "No Internet Connection!" except requests.exceptions.RequestException:
req = "No Internet Connection!"
return req
@staticmethod @staticmethod
def download(urld, down_ok_image, down_not_ok_image, res): def download(urld, down_ok_image, down_not_ok_image, res):
@ -380,6 +384,7 @@ def if_tip(path):
with open(path, "r", encoding="utf-8") as set_file2: with open(path, "r", encoding="utf-8") as set_file2:
lines2 = set_file2.readlines() lines2 = set_file2.readlines()
if "False\n" in lines2: if "False\n" in lines2:
return False tip = "False"
else: else:
return True tip = "True"
return tip