Add api keys db path as env var (#1)

* Add API Keys DB path to command & env vars

* Create API Keys DB directory if not exists before sqlite connection & Add docker-compose example
This commit is contained in:
Minosity-VR 2022-07-15 13:22:04 +02:00 committed by GitHub
parent 393eebe235
commit 752d2aae2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 5 deletions

View file

@ -1,6 +1,8 @@
import argparse
import os
from app.api_keys import Database
from app.default_values import DEFAULT_ARGUMENTS as DEFARGS
def manage():
@ -10,6 +12,12 @@ def manage():
)
keys_parser = subparsers.add_parser("keys", help="Manage API keys database")
keys_parser.add_argument(
"--api-keys-db-path",
default=DEFARGS['API_KEYS_DB_PATH'],
type=str,
help="Use a specific path inside the container for the local database",
)
keys_subparser = keys_parser.add_subparsers(
help="", dest="sub_command", title="Command List"
)
@ -30,7 +38,10 @@ def manage():
args = parser.parse_args()
if args.command == "keys":
db = Database()
if not os.path.exists(args.api_keys_db_path):
print("No such database: %s" % args.api_keys_db_path)
exit(1)
db = Database(args.api_keys_db_path)
if args.sub_command is None:
# Print keys
keys = db.all()