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