This commit is contained in:
2022-03-23 18:06:16 +07:00
committed by GitHub
parent 008148229f
commit 65afbacb58
6 changed files with 188 additions and 191 deletions

View File

@@ -22,8 +22,8 @@ class FilesIO:
try: try:
with open(self.file_name, encoding="utf-8", mode="r") as f: with open(self.file_name, encoding="utf-8", mode="r") as f:
ret_data = load(f) ret_data = load(f)
return ret_data
except FileNotFoundError: except FileNotFoundError:
self.create_default_file() self.create_default_file()
# ret_data = self.default_values # ret_data = self.default_values
return False return False
return ret_data

View File

@@ -4,7 +4,6 @@
from sys import exit, argv from sys import exit, argv
from os import system from os import system
from subprocess import Popen from subprocess import Popen
from time import sleep
from filesio import FilesIO from filesio import FilesIO
from match_name import MatchIO from match_name import MatchIO
@@ -29,15 +28,14 @@ default_values = {
loaded_file = None loaded_file = None
def main(comp_key, is_prod): def main(comp_key, is_debug):
global loaded_file global loaded_file
list_pc_names = loaded_file.get("pc").get(comp_key) list_pc_names = loaded_file.get("pc").get(comp_key)
if list_pc_names is not None: if list_pc_names is not None:
for pc_name in list_pc_names: for pc_name in list_pc_names:
formatted_pc_name = matchio.check_arm_name(pc_name) formatted_pc_name = matchio.check_arm_name(pc_name)
if formatted_pc_name is not False: if formatted_pc_name is not False:
# print("pc_name:", formatted_pc_name) if is_debug is False:
if is_prod is True:
# system("shutdown /m \\\{} /r /f /t 60 /c \"Плановая перезагрузка компьютера через 1 минуту!\"".format(formatted_pc_name)) # system("shutdown /m \\\{} /r /f /t 60 /c \"Плановая перезагрузка компьютера через 1 минуту!\"".format(formatted_pc_name))
Popen("shutdown /m \\\{} /r /f /t 60 /c \"Плановая перезагрузка компьютера через 1 минуту!\"".format(formatted_pc_name)).wait() Popen("shutdown /m \\\{} /r /f /t 60 /c \"Плановая перезагрузка компьютера через 1 минуту!\"".format(formatted_pc_name)).wait()
else: else:
@@ -56,10 +54,9 @@ if __name__ == "__main__":
if loaded_file is False: if loaded_file is False:
raise OSError raise OSError
matchio = MatchIO(loaded_file.get("expr_list")) matchio = MatchIO(loaded_file.get("expr_list"))
main(argv[1], argv[2].strip() == "prod") main(argv[1], argv[2].strip() == "debug")
except OSError: except OSError:
print("Файл с настройками не найден. Создан файл со стандартными настройками.") print("Файл с настройками не найден. Создан файл со стандартными настройками.")
sleep(20)
exit() exit()
except KeyboardInterrupt: except KeyboardInterrupt:
exit() exit()