mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
working on process checking
This commit is contained in:
2
config.json
vendored
2
config.json
vendored
@@ -1 +1 @@
|
||||
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.3.0", "BOOKPATH": "~/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*"}
|
||||
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.3.0", "BOOKPATH": "/home/raelon/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*"}
|
||||
|
||||
28
install
vendored
28
install
vendored
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/python3.8
|
||||
import json
|
||||
import pathlib
|
||||
import os
|
||||
import platform
|
||||
|
||||
import psutil
|
||||
from src.backend.lib.display import TerminalDisplay
|
||||
|
||||
|
||||
@@ -9,7 +11,7 @@ class Configuration:
|
||||
def __init__(self):
|
||||
self._cp = pathlib.Path("config.json")
|
||||
self._data = self.open_file()
|
||||
self.system = os.sys.environ
|
||||
self.system = platform.system()
|
||||
|
||||
def open_file(self):
|
||||
"""
|
||||
@@ -20,7 +22,7 @@ class Configuration:
|
||||
try:
|
||||
with open(str(self._cp), "r") as read_file:
|
||||
data = json.load(read_file)
|
||||
with open('config.backup.json', 'w') as backup_file:
|
||||
with open("config.backup.json", "w") as backup_file:
|
||||
json.dump(data, backup_file)
|
||||
return data
|
||||
except Exception as e:
|
||||
@@ -36,9 +38,29 @@ class Configuration:
|
||||
return True
|
||||
|
||||
|
||||
class RequiredServices:
|
||||
@staticmethod
|
||||
def check_ps(service_list):
|
||||
breakpoint()
|
||||
ps = psutil
|
||||
passed = []
|
||||
for p in ps.process_iter(attrs=["name", "exe", "cmdline"]):
|
||||
for s in service_list:
|
||||
if s == p.name:
|
||||
passed.append(s)
|
||||
return
|
||||
if len(passed) == len(service_list):
|
||||
return True
|
||||
else:
|
||||
return failed
|
||||
|
||||
|
||||
config = Configuration().open_file()
|
||||
install_answers = TerminalDisplay().installer()
|
||||
for key in install_answers:
|
||||
config[key["name"]] = key["answer"]
|
||||
Configuration().write_file(config)
|
||||
|
||||
# Start checking for our list of required services
|
||||
service_list = ["postgresql", "nginx", "httpd"]
|
||||
req = RequiredServices.check_ps(service_list)
|
||||
|
||||
1
requirements.txt
vendored
1
requirements.txt
vendored
@@ -16,3 +16,4 @@ uwsgi
|
||||
django-debug-toolbar
|
||||
psycopg2-binary
|
||||
prompt_toolkit
|
||||
psutil
|
||||
|
||||
Reference in New Issue
Block a user