summaryrefslogtreecommitdiff
path: root/bin/ipcam_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ipcam_server.py')
-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()