move all executable scripts under garminexport.cli
This commit is contained in:
parent
54dad23e1c
commit
a0d6163c52
@ -1,30 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
"""This python script calls garminexport.garminbackup module with CLI parsed arguments
|
|
||||||
and performs (incremental) backups of activities for a given Garmin Connect account.
|
|
||||||
The activities are stored in a local directory on the user's computer.
|
|
||||||
The backups are incremental, meaning that only activities that aren't already
|
|
||||||
stored in the backup directory will be downloaded.
|
|
||||||
"""
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from garminexport.cli import parse_args
|
|
||||||
from garminexport.incremental_backup import incremental_backup
|
|
||||||
from garminexport.logging_config import LOG_LEVELS
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
args = parse_args()
|
|
||||||
logging.root.setLevel(LOG_LEVELS[args.log_level])
|
|
||||||
|
|
||||||
try:
|
|
||||||
incremental_backup(username=args.username,
|
|
||||||
password=args.password,
|
|
||||||
backup_dir=args.backup_dir,
|
|
||||||
format=args.format,
|
|
||||||
ignore_errors=args.ignore_errors,
|
|
||||||
max_retries=args.max_retries)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
log.error("failed with exception: {}".format(e))
|
|
0
garminexport/cli/__init__.py
Normal file
0
garminexport/cli/__init__.py
Normal file
@ -1,7 +1,19 @@
|
|||||||
|
"""This script performs backups of activities for a Garmin Connect account. The
|
||||||
|
activities are stored in a local directory on the user's computer. The backups
|
||||||
|
are incremental, meaning that only activities that aren't already stored in the
|
||||||
|
backup directory will be downloaded.
|
||||||
|
|
||||||
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from garminexport.backup import export_formats
|
from garminexport.backup import export_formats
|
||||||
|
from garminexport.incremental_backup import incremental_backup
|
||||||
|
from garminexport.logging_config import LOG_LEVELS
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_MAX_RETRIES = 7
|
DEFAULT_MAX_RETRIES = 7
|
||||||
"""The default maximum number of retries to make when fetching a single activity."""
|
"""The default maximum number of retries to make when fetching a single activity."""
|
||||||
@ -14,6 +26,7 @@ def parse_args() -> argparse.Namespace:
|
|||||||
This object may be directly used by garminexport/garminbackup.py.
|
This object may be directly used by garminexport/garminbackup.py.
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="garminbackup",
|
||||||
description=(
|
description=(
|
||||||
"Performs incremental backups of activities for a "
|
"Performs incremental backups of activities for a "
|
||||||
"given Garmin Connect account. Only activities that "
|
"given Garmin Connect account. Only activities that "
|
||||||
@ -48,3 +61,19 @@ def parse_args() -> argparse.Namespace:
|
|||||||
"will double with every retry, starting at one second. DEFAULT: {}").format(DEFAULT_MAX_RETRIES))
|
"will double with every retry, starting at one second. DEFAULT: {}").format(DEFAULT_MAX_RETRIES))
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
logging.root.setLevel(LOG_LEVELS[args.log_level])
|
||||||
|
|
||||||
|
try:
|
||||||
|
incremental_backup(username=args.username,
|
||||||
|
password=args.password,
|
||||||
|
backup_dir=args.backup_dir,
|
||||||
|
format=args.format,
|
||||||
|
ignore_errors=args.ignore_errors,
|
||||||
|
max_retries=args.max_retries)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log.error("failed with exception: {}".format(e))
|
@ -18,8 +18,8 @@ from garminexport.retryer import Retryer, ExponentialBackoffDelayStrategy, MaxRe
|
|||||||
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Downloads one particular activity for a given Garmin Connect account.")
|
description="Downloads one particular activity for a given Garmin Connect account.")
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
"""A program that uploads an activity file to a Garmin
|
"""A program that uploads an activity file to a Garmin Connect account.
|
||||||
Connect account.
|
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import getpass
|
import getpass
|
||||||
@ -12,8 +11,8 @@ from garminexport.logging_config import LOG_LEVELS
|
|||||||
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Uploads an activity file to a Garmin Connect account.")
|
description="Uploads an activity file to a Garmin Connect account.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user