mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-22 08:36:22 +03:00
Добавления ошибки о том если не получается подключится к сайту наса с картинками
This commit is contained in:
parent
f6399423fa
commit
b81fcac344
1 changed files with 15 additions and 12 deletions
27
main.py
27
main.py
|
@ -20,7 +20,7 @@ class Nasa:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def autorun():
|
def autorun():
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
address = os.path.join(path, "main.py")
|
address = os.path.join(path, "main.exe")
|
||||||
key_value = "Software/Microsoft/Windows/CurrentVersion/Run"
|
key_value = "Software/Microsoft/Windows/CurrentVersion/Run"
|
||||||
user = getpass.getuser()
|
user = getpass.getuser()
|
||||||
key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, key_value, 0, reg.KEY_ALL_ACCESS)
|
key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, key_value, 0, reg.KEY_ALL_ACCESS)
|
||||||
|
@ -29,17 +29,21 @@ class Nasa:
|
||||||
print("Программа добавлена в автозапуск")
|
print("Программа добавлена в автозапуск")
|
||||||
|
|
||||||
def download_photo(self):
|
def download_photo(self):
|
||||||
full_page = requests.get(self.url, headers=self.headers)
|
try:
|
||||||
soup = BeautifulSoup(full_page.content, 'html.parser')
|
full_page = requests.get(self.url, headers=self.headers)
|
||||||
lnk = str
|
soup = BeautifulSoup(full_page.content, 'html.parser')
|
||||||
for link in soup.select("img"):
|
lnk = str
|
||||||
lnk = link["src"]
|
for link in soup.select("img"):
|
||||||
print(f"Сохарняю картинку — {self.url + lnk}")
|
lnk = link["src"]
|
||||||
|
print(f"Сохарняю картинку — {self.url + lnk}")
|
||||||
|
|
||||||
img = urllib.request.urlopen(self.url + lnk).read()
|
img = urllib.request.urlopen(self.url + lnk).read()
|
||||||
out = open(self.photoName, "wb")
|
out = open(self.photoName, "wb")
|
||||||
out.write(img)
|
out.write(img)
|
||||||
out.close()
|
out.close()
|
||||||
|
self.set_wallpaper()
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
return print("Нет подключения к интернету")
|
||||||
|
|
||||||
def set_wallpaper(self):
|
def set_wallpaper(self):
|
||||||
path = os.path.abspath(self.photoName)
|
path = os.path.abspath(self.photoName)
|
||||||
|
@ -48,7 +52,6 @@ class Nasa:
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.download_photo()
|
self.download_photo()
|
||||||
self.set_wallpaper()
|
|
||||||
print("Можно закрывать программу")
|
print("Можно закрывать программу")
|
||||||
if ctypes.windll.shell32.IsUserAnAdmin() != 0:
|
if ctypes.windll.shell32.IsUserAnAdmin() != 0:
|
||||||
elevate(show_console=False, graphical=False)
|
elevate(show_console=False, graphical=False)
|
||||||
|
|
Loading…
Add table
Reference in a new issue