Skip to content

Commit 7fba57d

Browse files
committed
re-organized the code
1 parent 97ac7a7 commit 7fba57d

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed
File renamed without changes.

configurator.py renamed to app/settings/helpers/configurator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import json
22
import logging
33

4-
logging.basicConfig(filename='log.log', encoding='utf-8', level=logging.INFO,
4+
logging.basicConfig(filename='./app/settings/log.log', encoding='utf-8', level=logging.INFO,
55
format='%(asctime)s | %(message)s', datefmt='%Y/%m/%d %I:%M:%S %p')
66

77

88
class Configurator:
9+
10+
conf_file_location = "./app/settings/config.json"
11+
912
def __init__(self):
1013
# Hard coded values if config file doesn't exist
1114
self.hot_key_state: bool = False
@@ -15,7 +18,7 @@ def __init__(self):
1518
def __str__(self):
1619
return f'Custom Hotkey: {self.hot_key_state} \nDefault Value: {self.def_hot_key} \nCustom Value: {self.cust_hot_key}'
1720

18-
def read_config_file(self, config_file_name: str = "config.json"):
21+
def read_config_file(self, config_file_name: str = conf_file_location):
1922
try:
2023
with open(config_file_name) as conf_file:
2124
data = json.load(conf_file)
@@ -24,7 +27,7 @@ def read_config_file(self, config_file_name: str = "config.json"):
2427
except Exception as e:
2528
logging.info(f"{str(e)} \n- File will be created and hard coded values will be applied. ")
2629

27-
def save_config_file(self, config_file_name: str = "config.json"):
30+
def save_config_file(self, config_file_name: str = conf_file_location):
2831
try:
2932
conf_items = {k: v for k, v in vars(self).items() if isinstance(v, (int, float, str, bool, list, dict))}
3033
with open(config_file_name, "w") as conf_file:

functions.py renamed to app/settings/helpers/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
from multiprocess import Process
77

88

9-
logging.basicConfig(filename='log.log', encoding='utf-8', level=logging.INFO,
9+
logging.basicConfig(filename='./app/settings/log.log', encoding='utf-8', level=logging.INFO,
1010
format='%(asctime)s | %(message)s', datefmt='%Y/%m/%d %I:%M:%S %p')
1111

12+
1213
keys_list = ['ALT', 'CTRL', 'SHIFT', 'WINDOWS',
1314
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
1415
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
File renamed without changes.

version.yml renamed to build/version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version: 2.0.1
1+
Version: 2.0.2
22
CompanyName: Kaloian Kozlev
33
FileDescription: X-Sleep GUI / Mouse jiggler
44
InternalName: X-Sleep GUI

main.pyw

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import PySimpleGUI as sg
66
import pyautogui as pag
77
import keyboard
88
import logging
9-
from functions import (get_latest_version, create_process, countdown, graceful_exit, get_hotkey, correct_key,
10-
is_capslock_on, terminate)
9+
from app.settings.helpers.functions import (get_latest_version, create_process, countdown, graceful_exit, get_hotkey, correct_key,
10+
is_capslock_on, terminate)
1111
from threading import Thread, Event
12-
from mouse_jiggler import jiggler
13-
from configurator import Configurator
12+
from app.settings.helpers.mouse_jiggler import jiggler
13+
from app.settings.helpers.configurator import Configurator
1414

15-
logging.basicConfig(filename='log.log', encoding='utf-8', level=logging.INFO,
15+
logging.basicConfig(filename='app/settings/helpers/log.log', encoding='utf-8', level=logging.INFO,
1616
format='%(asctime)s | %(message)s', datefmt='%Y/%m/%d %I:%M:%S %p')
1717

1818

@@ -247,7 +247,7 @@ if __name__ == '__main__':
247247
HOURS = [f" {i:02}" for i in range(24)]
248248
MINUTES = [f" {i:02}" for i in range(60)]
249249
SECONDS = [f" {i:02}" for i in range(60)]
250-
ICON = 'media/x-sleep.ico'
250+
ICON = 'app/media/x-sleep.ico'
251251

252252
github_url = {'name': 'Official GitHub Page',
253253
'url': 'https://github.com/kbkozlev/x-sleepGUI'}

0 commit comments

Comments
 (0)