Break out sync to separate file

This commit is contained in:
3wc
2023-11-01 21:11:21 +00:00
parent 77f87e5299
commit 21fc28a14e
3 changed files with 72 additions and 44 deletions

View File

@ -22,6 +22,7 @@ from .db import (
HamsterActivityKimaiMapping,
HamsterFactKimaiImport,
)
from .sync import sync
HAMSTER_DIR = Path.home() / ".local/share/hamster"
# HAMSTER_FILE = HAMSTER_DIR / 'hamster.db'
@ -34,9 +35,13 @@ db.init(HAMSTER_FILE)
@click.option("-d", "--debug", is_flag=True)
def cli(debug):
if debug:
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
peewee_logger = logging.getLogger("peewee")
peewee_logger.addHandler(TextualHandler())
peewee_logger.setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
@ -342,7 +347,7 @@ def _get_kimai_mapping_file(path, category_search=None):
return open(path)
@kimai.command()
@kimai.command("sync")
@click.option(
"--mapping-path",
help="Mapping file (default ~/.local/share/hamster/mapping.kimai.csv)",
@ -352,9 +357,9 @@ def _get_kimai_mapping_file(path, category_search=None):
@click.argument("api_key")
@click.option("--just-errors", "just_errors", is_flag=True, help="Only display errors")
@click.option("--ignore-activities", is_flag=True, help="Ignore missing activities")
def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
def check(username, api_key, just_errors, ignore_activities, mapping_path=None):
"""
Download customer / project / activity data from Kimai
Check customer / project / activity data from Kimai
"""
kimai_api_url = "https://kimai.autonomic.zone/api"
@ -656,6 +661,11 @@ def reset():
HamsterActivityKimaiMapping.delete().execute()
@db_.command("sync")
def kimai_db_sync():
sync()
@db_.command()
@click.option(
"-g",