Skip to content

Commit

Permalink
cli fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Mar 2, 2023
1 parent ba6a7d8 commit f4fa8d6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions xthulu/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""xthulu main entry point"""

# stdlib
from asyncio import get_event_loop
from asyncio import new_event_loop
from signal import SIGTERM
import sys

Expand All @@ -10,15 +10,20 @@
from click import echo, group

# local
from .configuration import get_config
from .logger import log
from .resources import Resources
from .ssh import start_server as start_ssh
from .web import start_server as start_web

loop = get_event_loop()
loop = new_event_loop()
db = Resources().db


async def bind_db():
await db.set_bind(get_config("db.bind"))


@group()
def main():
"""xthulu community server command line utility"""
Expand Down Expand Up @@ -65,8 +70,9 @@ def db_create():
from . import models # noqa: F401

async def f():
echo("Creating database")
await Resources().db.gino.create_all() # type: ignore
echo("Creating database and tables")
await bind_db()
await db.gino.create_all() # type: ignore

loop.run_until_complete(f())

Expand All @@ -75,10 +81,11 @@ async def f():
def db_init():
"""Initialize database with starter data"""

from .models.user import User
from .models import User

async def f():
echo("Creating guest user")
await bind_db()
pwd, salt = User.hash_password("guest")
await User.create(
name="guest",
Expand Down

0 comments on commit f4fa8d6

Please sign in to comment.