diff --git a/main.py b/main.py index e00081f..2b7e7f2 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,6 @@ from bs4 import BeautifulSoup -from pyqadmin import admin +from elevate import elevate import requests - import ctypes import os import urllib @@ -10,8 +9,6 @@ import winreg as reg import getpass - - class Nasa: def __init__(self): @@ -21,7 +18,6 @@ class Nasa: self.photoName = "everydayphotonasa.jpg" @staticmethod - @admin def autorun(): path = os.path.dirname(os.path.realpath(__file__)) address = os.path.join(path, "main.py") @@ -37,7 +33,6 @@ class Nasa: lnk = str for link in soup.select("img"): lnk = link["src"] - print(f"Скачиваю картинку — {self.url + lnk}") img = urllib.request.urlopen(self.url + lnk).read() out = open(self.photoName, "wb") @@ -49,12 +44,15 @@ class Nasa: ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 0) def start(self): - self.autorun() + if not ctypes.windll.shell32.IsUserAnAdmin() != 0: + elevate(show_console=False, graphical=False) self.download_photo() self.set_wallpaper() if __name__ == "__main__": - schedule.every(1).days.do(Nasa().start) + nasa = Nasa() + nasa.start() + schedule.every(3).seconds.do(nasa.start) while True: schedule.run_pending() diff --git a/requirements.txt b/requirements.txt index 9699a2f..72b4522 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ beautifulsoup4==4.11.1 requests~=2.28.0 schedule~=1.1.0 -pyqadmin~=1.0.0 \ No newline at end of file +elevate~=0.1.3 \ No newline at end of file