summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-06-11 05:03:43 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-06-11 05:03:43 +0300
commit62ee71fdb0eb07adbf0071103617aa96c993fe22 (patch)
tree07a5d7ec63c66efcf3162a388f22f371367000f7 /bin
parentba321657e0e724082df206857f80ca08c4d999dc (diff)
ipcam: start porting to new config and multiserver scheme
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ipcam_server.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/bin/ipcam_server.py b/bin/ipcam_server.py
index 211bc86..a9d6a0b 100755
--- a/bin/ipcam_server.py
+++ b/bin/ipcam_server.py
@@ -9,6 +9,7 @@ import __py_include
import homekit.telegram.aio as telegram
+from argparse import ArgumentParser
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from asyncio import Lock
@@ -53,8 +54,8 @@ def get_all_cams() -> list:
class IPCamServerDatabase(SQLiteBase):
SCHEMA = 4
- def __init__(self):
- super().__init__()
+ def __init__(self, path=None):
+ super().__init__(path=path)
def schema_init(self, version: int) -> None:
cursor = self.cursor()
@@ -319,9 +320,9 @@ class IPCamWebServer(http.HTTPServer):
# other global stuff
# ------------------
-def open_database():
+def open_database(database_path: str):
global db
- db = IPCamServerDatabase()
+ db = IPCamServerDatabase(database_path)
# update cams list in database, if needed
cams = db.get_all_timestamps().keys()
@@ -558,9 +559,12 @@ logger = logging.getLogger(__name__)
# --------------------
if __name__ == '__main__':
- config.load_app('ipcam_server')
+ parser = ArgumentParser()
+ parser.add_argument('--listen', type=str, required=True)
+ parser.add_argument('--database-path', type=str, required=True)
+ arg = config.load_app(no_config=True, parser=parser)
- open_database()
+ open_database(arg.database_path)
loop = asyncio.get_event_loop()