mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-05-04 20:30:39 +00:00
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:
parent
393eebe235
commit
752d2aae2c
7 changed files with 48 additions and 5 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue