2014-11-11 13:45:11 +01:00
|
|
|
#! /usr/bin/env python
|
2020-03-08 17:19:19 +01:00
|
|
|
"""This python script calls garminexport.garminbackup module with CLI parsed arguments
|
|
|
|
and performs (incremental) backups of activities for a given Garmin Connect account.
|
2014-11-11 13:45:11 +01:00
|
|
|
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
|
|
|
|
|
2020-03-08 17:19:19 +01:00
|
|
|
from garminexport.cli import parse_args
|
|
|
|
from garminexport.incremental_backup import incremental_backup
|
|
|
|
from garminexport.logging_config import LOG_LEVELS
|
2015-02-20 09:32:59 +01:00
|
|
|
|
2020-03-08 17:19:19 +01:00
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
|
|
|
|
log = logging.getLogger(__name__)
|
2014-11-11 13:45:11 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-03-08 17:19:19 +01:00
|
|
|
args = parse_args()
|
2014-11-11 13:45:11 +01:00
|
|
|
logging.root.setLevel(LOG_LEVELS[args.log_level])
|
2015-03-04 20:55:55 +01:00
|
|
|
|
2014-11-11 13:45:11 +01:00
|
|
|
try:
|
2020-03-08 17:19:19 +01:00
|
|
|
incremental_backup(username=args.username,
|
|
|
|
password=args.password,
|
|
|
|
backup_dir=args.backup_dir,
|
|
|
|
format=args.format,
|
2020-04-07 14:15:30 +02:00
|
|
|
ignore_errors=args.ignore_errors,
|
2020-03-08 17:19:19 +01:00
|
|
|
max_retries=args.max_retries)
|
2015-02-20 09:32:59 +01:00
|
|
|
|
2014-11-11 13:45:11 +01:00
|
|
|
except Exception as e:
|
2020-03-08 20:05:56 +01:00
|
|
|
log.error("failed with exception: {}".format(e))
|