mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-06 01:13:57 +03:00
Deleting files of the previous version
This commit is contained in:
parent
93b6c88f7b
commit
e8b1e52b1f
8 changed files with 0 additions and 272 deletions
|
@ -1,11 +0,0 @@
|
|||
---
|
||||
name: 'Pull request'
|
||||
about: Write down what you changed
|
||||
title: 'Pull request'
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
In order to make everything clear
|
||||
**Write down what you changed and why**
|
|
@ -1,47 +0,0 @@
|
|||
import configparser
|
||||
import os
|
||||
|
||||
|
||||
class Config:
|
||||
def create_config(self, path):
|
||||
if not os.path.exists(path):
|
||||
config = configparser.ConfigParser()
|
||||
config.add_section("Config")
|
||||
|
||||
config.set("Config", "wallpaper-link", "None")
|
||||
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
||||
else:
|
||||
return print("The file exists")
|
||||
|
||||
def get_config(self, path):
|
||||
if not os.path.exists(path):
|
||||
self.create_config(path)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path)
|
||||
return config
|
||||
|
||||
def get_setting(self, path, section, setting):
|
||||
if not os.path.exists(path):
|
||||
self.create_config(path)
|
||||
|
||||
config = self.get_config(path)
|
||||
value = config.get(section, setting)
|
||||
return value
|
||||
|
||||
def update_setting(self, path, section, setting, value):
|
||||
if not os.path.exists(path):
|
||||
self.create_config(path)
|
||||
|
||||
config = self.get_config(path)
|
||||
config.set(section, setting, value)
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
||||
|
||||
def delete_setting(self, path, section, setting):
|
||||
config = self.get_config(path)
|
||||
config.remove_option(section, setting)
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
|
@ -1,93 +0,0 @@
|
|||
from bs4 import BeautifulSoup
|
||||
|
||||
import requests
|
||||
import urllib
|
||||
import sys
|
||||
import ctypes
|
||||
import os
|
||||
|
||||
from .config import Config
|
||||
|
||||
|
||||
class Wallpaper(Config):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.url = "https://apod.nasa.gov/apod/"
|
||||
self.config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.ini")
|
||||
|
||||
self.full_page = requests.get(self.url)
|
||||
self.soup = BeautifulSoup(self.full_page.content, 'html.parser')
|
||||
self.lnk = None
|
||||
|
||||
def check(self):
|
||||
config = Config.get_setting(self, path=self.config_path, section="Config", setting="wallpaper-link")
|
||||
|
||||
for link in self.soup.select("img"):
|
||||
self.lnk = link["src"]
|
||||
|
||||
if self.lnk is None:
|
||||
return "On the NASA website, they posted not a picture but a video, " \
|
||||
"unfortunately, it will not work to install wallpaper"
|
||||
|
||||
if config == self.lnk:
|
||||
return
|
||||
else:
|
||||
Config.update_setting(
|
||||
self,
|
||||
path=self.config_path,
|
||||
section="Config",
|
||||
setting="wallpaper-link",
|
||||
value=self.lnk
|
||||
)
|
||||
|
||||
def download(self):
|
||||
try:
|
||||
img = urllib.request.urlopen(self.url + self.lnk).read()
|
||||
with open("everyNASA.jpg", "wb") as file:
|
||||
file.write(img)
|
||||
except requests.exceptions.ConnectionError:
|
||||
return "Connection error, please try again later."
|
||||
|
||||
@staticmethod
|
||||
def set():
|
||||
if sys.platform == "win32":
|
||||
ctypes.windll.user32.SystemParametersInfoW(20, 0, os.path.abspath("everyNASA.jpg"), 0)
|
||||
elif sys.platform == "linux":
|
||||
desk_env = os.environ.get("DESKTOP_SESSION")
|
||||
if desk_env == "gnome":
|
||||
os.system(
|
||||
"gsettings set org.gnome.desktop.background "
|
||||
"picture-uri 'file://{}'"
|
||||
.format(
|
||||
os.path.abspath(
|
||||
"everyNASA.jpg"
|
||||
)
|
||||
)
|
||||
)
|
||||
elif desk_env == "plasma":
|
||||
import dbus
|
||||
jscript = """
|
||||
var allDesktops = desktops();
|
||||
print (allDesktops);
|
||||
for (i=0;i<allDesktops.length;i++) {
|
||||
d = allDesktops[i];
|
||||
d.wallpaperPlugin = "%s";
|
||||
d.currentConfigGroup = Array("Wallpaper", "%s", "General");
|
||||
d.writeConfig("Image", "file://%s")
|
||||
}
|
||||
"""
|
||||
bus = dbus.SessionBus()
|
||||
plasma = dbus.Interface(
|
||||
bus.get_object(
|
||||
'org.kde.plasmashell',
|
||||
'/PlasmaShell'),
|
||||
dbus_interface='org.kde.PlasmaShell'
|
||||
)
|
||||
|
||||
plasma.evaluateScript(jscript % ("org.kde.image", "org.kde.image", os.path.abspath("everyNASA.jpg")))
|
||||
else:
|
||||
return "Your desktop environment is not supported."
|
||||
else:
|
||||
return "Your operating system is not supported."
|
||||
|
||||
return "The wallpaper is installed."
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 149 KiB |
|
@ -1,63 +0,0 @@
|
|||
from pystray import MenuItem, Menu, Icon
|
||||
from PIL import Image
|
||||
|
||||
import notify2
|
||||
import schedule
|
||||
import os
|
||||
import sys
|
||||
import psutil
|
||||
import time
|
||||
|
||||
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, path)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from functions.wallpaper import Wallpaper
|
||||
|
||||
|
||||
class Nasa(Wallpaper):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@staticmethod
|
||||
def resource_path(relative_path):
|
||||
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.join(base_path, relative_path)
|
||||
|
||||
def tray(self):
|
||||
tray = Icon("EveryNasa",
|
||||
title="EveryNasa",
|
||||
icon=Image.open(self.resource_path("./icons/icon.ico")),
|
||||
menu=Menu(
|
||||
MenuItem("Выход",
|
||||
self.kill_program),
|
||||
))
|
||||
tray.run()
|
||||
|
||||
def kill_program(self):
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == "EveryNasa":
|
||||
proc.kill()
|
||||
|
||||
@staticmethod
|
||||
def notify(title, message):
|
||||
notify2.init("EveryNasa")
|
||||
notice = notify2.Notification(title, message)
|
||||
notice.show()
|
||||
return
|
||||
|
||||
def main(self):
|
||||
wall_check = Wallpaper.check(self)
|
||||
Wallpaper.download(self)
|
||||
wall_set = Wallpaper.set()
|
||||
self.notify("EveryNasa", wall_check or wall_set)
|
||||
|
||||
|
||||
nasa = Nasa()
|
||||
nasa.main()
|
||||
|
||||
schedule.every(3).hours.do(nasa.main)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
nasa.tray()
|
||||
time.sleep(1)
|
|
@ -1,58 +0,0 @@
|
|||
from win10toast import ToastNotifier
|
||||
from infi.systray import SysTrayIcon
|
||||
|
||||
import schedule
|
||||
import os
|
||||
import sys
|
||||
import psutil
|
||||
import time
|
||||
|
||||
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, path)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from functions.wallpaper import Wallpaper
|
||||
|
||||
|
||||
class Nasa(Wallpaper):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.toaster = ToastNotifier()
|
||||
|
||||
@staticmethod
|
||||
def resource_path(relative_path):
|
||||
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.join(base_path, relative_path)
|
||||
|
||||
@staticmethod
|
||||
def kill_program(tray):
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == "EveryNasa.exe":
|
||||
proc.kill()
|
||||
|
||||
def tray(self):
|
||||
tray = SysTrayIcon(
|
||||
self.resource_path("./icons/icon.ico"),
|
||||
"EveryNasa",
|
||||
on_quit=self.kill_program,
|
||||
)
|
||||
tray.start()
|
||||
|
||||
def main(self):
|
||||
self.tray()
|
||||
wall_check = Wallpaper.check(self)
|
||||
Wallpaper.download(self)
|
||||
wall_set = Wallpaper.set()
|
||||
self.toaster.show_toast("EveryNasa",
|
||||
wall_check or wall_set,
|
||||
duration=4,
|
||||
icon_path=self.resource_path("./icons/icon.ico"))
|
||||
|
||||
|
||||
nasa = Nasa()
|
||||
nasa.main()
|
||||
|
||||
schedule.every(3).hours.do(nasa.main)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
Loading…
Reference in a new issue