Skip to content

Commit 4dbe0c2

Browse files
committed
feat(app): use httpx instead of requests and apply black format.
1 parent 628c54d commit 4dbe0c2

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

main.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import platform
33
import os
44
import sys
5-
import requests
5+
import httpx
66
from src import App
77
from src import Logger
88
from src import __version__, __title__, __clientid___
@@ -16,7 +16,7 @@ def prepare_environment():
1616
raw_settings = {"firstRun": True}
1717
except json.decoder.JSONDecodeError:
1818
Logger.write(message="Invalid settings.json file.", level="ERROR")
19-
os.remove('settings.json')
19+
os.remove("settings.json")
2020
exit()
2121
if raw_settings["firstRun"] is True:
2222
with open("settings.json", "w") as settings_file:
@@ -34,16 +34,16 @@ def prepare_environment():
3434
"App | Display time remaining instead of elapsed time? (yes/no): "
3535
)
3636
raw_settings = {
37-
"firstRun": False,
38-
"client_id": client_id,
39-
"profile_name": profile or "Default",
40-
"RefreshRate": int(refreshRate) or 1,
41-
"DisplayTimeLeft": useTimeLeft.lower() or "yes",
42-
}
37+
"firstRun": False,
38+
"client_id": client_id,
39+
"profile_name": profile or "Default",
40+
"RefreshRate": int(refreshRate) or 1,
41+
"DisplayTimeLeft": useTimeLeft.lower() or "yes",
42+
}
4343
if not os.path.exists("./icon.ico"):
4444
print("WARNING | Icon not found! downloading now.")
45-
icon = requests.get('https://killxr.skycode.us/icon.ico')
46-
open('icon.ico', 'wb').write(icon.content)
45+
icon = httpx.get("https://killxr.skycode.us/icon.ico")
46+
open("icon.ico", "wb").write(icon.content)
4747
print("App | Icon downloaded successfully.")
4848
new_settings = json.dumps(raw_settings)
4949
json.dump(json.loads(new_settings), settings_file)
@@ -59,17 +59,21 @@ def prepare_environment():
5959
Logger.write(message="Sorry! only supports Windows.", level="ERROR")
6060
exit()
6161
settings = prepare_environment()
62-
#using conhost to allow the functionality of hidding and showing the console.
63-
if len(sys.argv) == 1 and sys.argv[0] != 'main.py':
62+
# using conhost to allow the functionality of hidding and showing the console.
63+
if len(sys.argv) == 1 and sys.argv[0] != "main.py":
6464
found = []
6565
for file in os.listdir(os.getcwd()):
66-
if file.endswith('.exe'):
66+
if file.endswith(".exe"):
6767
found.append(file)
6868
file = found[0]
69-
#print(f'cmd /k {os.environ["SYSTEMDRIVE"]}\\Windows\\System32\\conhost.exe ' + cmd)
70-
os.system(f'cmd /c {os.environ["SYSTEMDRIVE"]}\\Windows\\System32\\conhost.exe {os.path.join(os.getcwd(),file)} True')
69+
# print(f'cmd /k {os.environ["SYSTEMDRIVE"]}\\Windows\\System32\\conhost.exe ' + cmd)
70+
os.system(
71+
f'cmd /c {os.environ["SYSTEMDRIVE"]}\\Windows\\System32\\conhost.exe {os.path.join(os.getcwd(),file)} True'
72+
)
7173
exit()
72-
os.system(f'cmd /c taskkill /IM WindowsTerminal.exe /F') #removed /IM cmd.exe in case that causes problems for windows 10. Windows 11 requires starting a new task and killing windows terminal.
74+
os.system(
75+
f"cmd /c taskkill /IM WindowsTerminal.exe /F"
76+
) # removed /IM cmd.exe in case that causes problems for windows 10. Windows 11 requires starting a new task and killing windows terminal.
7377
app = App(
7478
client_id=settings["client_id"],
7579
version=__version__,

settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"firstRun": true, "client_id": "1", "profile_name": "1", "RefreshRate": 1, "DisplayTimeLeft": "yes"}
1+
{"firstRun": false, "client_id": "828083725790609459", "profile_name": "Default", "RefreshRate": 1, "DisplayTimeLeft": "yes"}

0 commit comments

Comments
 (0)