diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ee2bb7a..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Redume - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index a39ac4e..0000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -## Инструкция -1. Скачайте все необходимые модули - -``` -pip install -r requirements.txt -``` - -2. Запустите main.py - -``` -python main.py -``` - -## Участники проекта ✨ - - - - - -
-
Redume

- 💻 - 🤔 - 📆

Murzify

- 💻 -
diff --git a/main.py b/main.py index 44e4214..b9cca6e 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +from win10toast import ToastNotifier + from bs4 import BeautifulSoup from elevate import elevate import requests @@ -16,9 +18,9 @@ class Nasa: self.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) ' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'} self.photoName = "everydayphotonasa.jpg" + self.toaster = ToastNotifier() - @staticmethod - def autorun(): + def autorun(self): path = os.path.dirname(os.path.realpath(__file__)) address = os.path.join(path, "main.exe") key_value = "Software/Microsoft/Windows/CurrentVersion/Run" @@ -26,7 +28,10 @@ class Nasa: key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, key_value, 0, reg.KEY_ALL_ACCESS) reg.SetValueEx(key, user, 0, reg.REG_SZ, address) reg.CloseKey(key) - print("Программа добавлена в автозапуск") + self.toaster.show_toast("EveryDayPhotoNasa", + "Программа добавлена в автозапуск.", + duration=5, + icon_path=None) def download_photo(self): try: @@ -35,7 +40,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") @@ -43,20 +47,24 @@ class Nasa: out.close() self.set_wallpaper() except requests.exceptions.ConnectionError: - return print("Нет подключения к интернету") + return self.toaster.show_toast("EveryDayPhotoNasa", + "Не получилось подключится к сайту, проверьте подключение к интернету.", + duration=5, + icon_path=None) def set_wallpaper(self): path = os.path.abspath(self.photoName) - print("Установлено фоновое изображение") ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 0) + self.toaster.show_toast("EveryDayPhotoNasa", + "Обои поставлены.", + duration=5, + icon_path=None) def start(self): self.download_photo() - print("Можно закрывать программу") if ctypes.windll.shell32.IsUserAnAdmin() != 0: elevate(show_console=False, graphical=False) self.autorun() - print("Программа добавлена в автозапуск, можете закрывать программу") if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index 72b4522..3a92561 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ beautifulsoup4==4.11.1 requests~=2.28.0 schedule~=1.1.0 -elevate~=0.1.3 \ No newline at end of file +elevate~=0.1.3 +future~=0.18.2 +win10toast~=0.9 \ No newline at end of file