unstable: environment variable for systemctl required
This commit is contained in:
parent
651dbdc5be
commit
4cff2d65a7
|
@ -6,4 +6,4 @@
|
|||
|
||||
> $ sh install.sh
|
||||
|
||||
После этого в браузере на localhost:8000 должны появиться данные о погоде.
|
||||
После этого в браузере на localhost:7841 должны появиться данные о погоде.
|
|
@ -2,9 +2,10 @@
|
|||
Description=Weather collection service
|
||||
|
||||
[Service]
|
||||
$DIR=/home/citrullux/ModernOSWeather
|
||||
Type=simple
|
||||
WorkingDirectory=/home/citrullux/ModernOSLabs/src
|
||||
ExecStart=/usr/bin/python3 /home/citrullux/ModernOSLabs/src/main.py
|
||||
WorkingDirectory=/home/citrullux/ModernOSWeather/src
|
||||
ExecStart=/usr/bin/python3 /home/citrullux/ModernOSWeather/src/main.py
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
|
|
|
@ -2,30 +2,26 @@ import filecmp
|
|||
import subprocess
|
||||
import os
|
||||
from time import sleep
|
||||
from server import weather_run
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def install(parsed) -> None:
|
||||
args = parsed.parse_args()
|
||||
if args.install:
|
||||
projectDir = Path(__file__).resolve().parent.parent
|
||||
homeDir = Path(os.getenv("HOME"))
|
||||
serviceDirExist = os.path.isdir(os.path.join(homeDir, ".config/systemd/user/"))
|
||||
delivered = False
|
||||
def install() -> None:
|
||||
projectDir = Path(__file__).resolve().parent.parent
|
||||
homeDir = Path(os.getenv("HOME"))
|
||||
serviceDirExist = os.path.isdir(os.path.join(homeDir, ".config/systemd/user/"))
|
||||
delivered = False
|
||||
|
||||
if serviceDirExist:
|
||||
delivered = filecmp.cmp(
|
||||
os.path.join(projectDir, "services/wthrc.service"),
|
||||
os.path.join(homeDir, ".config/systemd/user/wthrc.service"),
|
||||
shallow=True,
|
||||
)
|
||||
if serviceDirExist:
|
||||
delivered = filecmp.cmp(
|
||||
os.path.join(projectDir, "services/wthrc.service"),
|
||||
os.path.join(homeDir, ".config/systemd/user/wthrc.service"),
|
||||
shallow=True,
|
||||
)
|
||||
|
||||
if not delivered or not serviceDirExist:
|
||||
os.environ["DIR"] = str(projectDir)
|
||||
subprocess.call(["sh", os.path.join(projectDir, "scripts/install.sh")])
|
||||
subprocess.call(["sh", os.path.join(projectDir, "scripts/runner.sh")])
|
||||
if not delivered or not serviceDirExist:
|
||||
os.environ["DIR"] = str(projectDir)
|
||||
subprocess.call(["sh", os.path.join(projectDir, "scripts/install.sh")])
|
||||
subprocess.call(["sh", os.path.join(projectDir, "scripts/runner.sh")])
|
||||
|
||||
sleep(5)
|
||||
else:
|
||||
weather_run()
|
||||
sleep(5)
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
from installer import install
|
||||
from server import weather_run
|
||||
import argparse
|
||||
|
||||
flags = argparse.ArgumentParser()
|
||||
flags.add_argument("--install", "-i", action="store_true")
|
||||
args = flags.parse_args()
|
||||
|
||||
install(flags)
|
||||
if args.install:
|
||||
install()
|
||||
weather_run()
|
|
@ -5,7 +5,7 @@ from weather import weather_handler
|
|||
|
||||
|
||||
def weather_run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
|
||||
server_address = ("", int(os.getenv("PORT", "8000")))
|
||||
server_address = ("", int(os.getenv("PORT", "7841")))
|
||||
httpd = server_class(server_address, WeatherHandler)
|
||||
httpd.serve_forever()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user