mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-11-06 06:13:57 +03:00
Добавление файла NOTICE
This commit is contained in:
parent
77fbbcf077
commit
1229b6bc02
3 changed files with 113 additions and 38 deletions
|
@ -1,24 +1,23 @@
|
||||||
## Инструкция
|
## Инструкция
|
||||||
1. Скачайте все необходимые модули
|
1. Скачайте все необходимые модули
|
||||||
|
|
||||||
```
|
```sh
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Запустите main.py
|
2. Запустите main.py
|
||||||
|
|
||||||
```
|
```sh
|
||||||
python main.py
|
python main.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## Участники проекта ✨
|
## Участники проекта ✨ [(Emoji key)](https://allcontributors.org/docs/en/emoji-key)
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://github.com/redume"><img src="https://avatars.githubusercontent.com/u/49362257?v=3?s=100" width="100px;" alt=""/>
|
<a href="https://github.com/redume"><img src="https://avatars.githubusercontent.com/u/49362257?v=3?s=100" width="100px;" alt=""/>
|
||||||
<br/><sub><b>Redume</b></sub></a><br/>
|
<br/><sub><b>Redume</b></sub></a><br/>
|
||||||
<a href="#code" title="Код">💻</a>
|
<a href="#code" title="Код">💻</a>
|
||||||
<a href="#projectManagement" title="Управление проектом">📆</a></td>
|
|
||||||
|
|
||||||
<td align="center"><a href="https://github.com/Murzify"><img src="https://avatars.githubusercontent.com/u/59001661?v=3?s=100" width="100px;" alt=""/>
|
<td align="center"><a href="https://github.com/Murzify"><img src="https://avatars.githubusercontent.com/u/59001661?v=3?s=100" width="100px;" alt=""/>
|
||||||
<br/><sub><b>Murzify</b></sub></a><br/>
|
<br/><sub><b>Murzify</b></sub></a><br/>
|
||||||
|
|
112
main.py
112
main.py
|
@ -1,7 +1,27 @@
|
||||||
from win10toast import ToastNotifier
|
"""
|
||||||
|
Copyright 2022 Redume
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from win10toast import ToastNotifier
|
||||||
|
from pystray import MenuItem, Menu, Icon
|
||||||
|
from PIL import Image
|
||||||
from elevate import elevate
|
from elevate import elevate
|
||||||
|
|
||||||
|
import json
|
||||||
import requests
|
import requests
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
|
@ -9,18 +29,37 @@ import urllib
|
||||||
import schedule
|
import schedule
|
||||||
import winreg as reg
|
import winreg as reg
|
||||||
import getpass
|
import getpass
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from config import Config
|
||||||
|
|
||||||
|
|
||||||
class Nasa:
|
class Nasa(Config):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.url = "https://apod.nasa.gov/apod/"
|
self.url = "https://apod.nasa.gov/apod/"
|
||||||
self.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) '
|
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'}
|
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'}
|
||||||
self.photoName = "everydayphotonasa.jpg"
|
self.photoName = "everydayphotonasa.jpg"
|
||||||
self.toaster = ToastNotifier()
|
self.toaster = ToastNotifier()
|
||||||
|
self.state = json.loads(
|
||||||
|
Config.get_setting(self,
|
||||||
|
path="config.ini",
|
||||||
|
section="Settings",
|
||||||
|
setting="autorun")
|
||||||
|
.lower())
|
||||||
|
|
||||||
|
def resource_path(self, relative_path):
|
||||||
|
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
return os.path.join(base_path, relative_path)
|
||||||
|
|
||||||
def autorun(self):
|
def autorun(self):
|
||||||
|
self.state = not MenuItem.checked
|
||||||
|
|
||||||
|
if not ctypes.windll.shell32.IsUserAnAdmin() != 0:
|
||||||
|
elevate(show_console=False)
|
||||||
|
|
||||||
|
if self.state is False:
|
||||||
|
print("Автозапуск включен.")
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
address = os.path.join(path, "main.exe")
|
address = os.path.join(path, "main.exe")
|
||||||
key_value = "Software/Microsoft/Windows/CurrentVersion/Run"
|
key_value = "Software/Microsoft/Windows/CurrentVersion/Run"
|
||||||
|
@ -28,10 +67,49 @@ class Nasa:
|
||||||
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)
|
||||||
reg.SetValueEx(key, user, 0, reg.REG_SZ, address)
|
reg.SetValueEx(key, user, 0, reg.REG_SZ, address)
|
||||||
reg.CloseKey(key)
|
reg.CloseKey(key)
|
||||||
|
Config.update_setting(self,
|
||||||
|
path="config.ini",
|
||||||
|
section="Settings",
|
||||||
|
setting="autorun",
|
||||||
|
value="True")
|
||||||
|
|
||||||
self.toaster.show_toast("EveryDayPhotoNasa",
|
self.toaster.show_toast("EveryDayPhotoNasa",
|
||||||
"Программа добавлена в автозапуск.",
|
"Программа добавлена в автозапуск.",
|
||||||
duration=5,
|
duration=3,
|
||||||
icon_path=None)
|
icon_path=self.resource_path("nasa.ico"))
|
||||||
|
else:
|
||||||
|
print("Программа удалена из автозапуска.")
|
||||||
|
key_value = "Software/Microsoft/Windows/CurrentVersion/Run"
|
||||||
|
user = getpass.getuser()
|
||||||
|
key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, key_value, 0, reg.KEY_ALL_ACCESS)
|
||||||
|
reg.DeleteValue(key, user)
|
||||||
|
reg.CloseKey(key)
|
||||||
|
Config.update_setting(self,
|
||||||
|
path="config.ini",
|
||||||
|
section="Settings",
|
||||||
|
setting="autorun",
|
||||||
|
value="False")
|
||||||
|
|
||||||
|
self.toaster.show_toast("EveryDayPhotoNasa",
|
||||||
|
"Программа удалена из автозапуска.",
|
||||||
|
duration=3,
|
||||||
|
icon_path=self.resource_path("nasa.ico"))
|
||||||
|
|
||||||
|
def tray(self):
|
||||||
|
tray = Icon("EveryDayPhotoNasa", title="EveryDayPhotoNasa",
|
||||||
|
icon=Image.open(self.resource_path("nasa.ico")),
|
||||||
|
menu=Menu(
|
||||||
|
MenuItem("Автозапуск",
|
||||||
|
self.autorun,
|
||||||
|
checked=lambda item: self.state),
|
||||||
|
MenuItem("Выход",
|
||||||
|
self.tray_close),
|
||||||
|
))
|
||||||
|
tray.run()
|
||||||
|
|
||||||
|
def tray_close(self, tray):
|
||||||
|
tray.visible = False
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def download_photo(self):
|
def download_photo(self):
|
||||||
try:
|
try:
|
||||||
|
@ -49,27 +127,23 @@ class Nasa:
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
return self.toaster.show_toast("EveryDayPhotoNasa",
|
return self.toaster.show_toast("EveryDayPhotoNasa",
|
||||||
"Не получилось подключится к сайту, проверьте подключение к интернету.",
|
"Не получилось подключится к сайту, проверьте подключение к интернету.",
|
||||||
duration=5,
|
duration=3,
|
||||||
icon_path=None)
|
icon_path=self.resource_path("nasa.ico"))
|
||||||
|
|
||||||
def set_wallpaper(self):
|
def set_wallpaper(self):
|
||||||
|
print(self.state)
|
||||||
path = os.path.abspath(self.photoName)
|
path = os.path.abspath(self.photoName)
|
||||||
ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 0)
|
ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 0)
|
||||||
self.toaster.show_toast("EveryDayPhotoNasa",
|
self.toaster.show_toast("EveryDayPhotoNasa",
|
||||||
"Обои поставлены.",
|
"Обои установлены.",
|
||||||
duration=5,
|
duration=3,
|
||||||
icon_path=None)
|
icon_path=self.resource_path("nasa.ico"))
|
||||||
|
|
||||||
def start(self):
|
|
||||||
self.download_photo()
|
|
||||||
if ctypes.windll.shell32.IsUserAnAdmin() != 0:
|
|
||||||
elevate(show_console=False, graphical=False)
|
|
||||||
self.autorun()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
nasa = Nasa()
|
nasa = Nasa()
|
||||||
nasa.start()
|
nasa.download_photo()
|
||||||
schedule.every(1).day.do(nasa.start)
|
|
||||||
|
schedule.every().day.at("00:30").do(nasa.download_photo)
|
||||||
while True:
|
while True:
|
||||||
schedule.run_pending()
|
schedule.run_pending()
|
||||||
|
nasa.tray()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
beautifulsoup4==4.11.1
|
|
||||||
requests~=2.28.0
|
requests~=2.28.0
|
||||||
schedule~=1.1.0
|
schedule~=1.1.0
|
||||||
elevate~=0.1.3
|
|
||||||
future~=0.18.2
|
future~=0.18.2
|
||||||
|
beautifulsoup4~=4.11.1
|
||||||
win10toast~=0.9
|
win10toast~=0.9
|
||||||
|
pystray~=0.19.4
|
||||||
|
Pillow~=9.2.0
|
||||||
|
elevate~=0.1.3
|
Loading…
Reference in a new issue