Reduce verbosity of commands

This commit is contained in:
Kevin Alberts 2020-11-11 17:38:28 +01:00
parent ee2856c5fc
commit fccf5ff600
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
2 changed files with 2 additions and 7 deletions

View file

@ -56,6 +56,6 @@ def handle_lock(handle):
lock.release()
logging.debug("released.")
logging.info("done in %.2f seconds" % (time.time() - start_time))
logging.debug("done in %.2f seconds" % (time.time() - start_time))
return wrapper

View file

@ -14,22 +14,17 @@ class Command(BaseCommand):
def handle(self, *args, **options):
logger = logging.getLogger("davinci.icalendar.ical_sync")
logger.debug(f"Command `ical_sync` invoked")
self.stdout.write(f"Command `ical_sync` invoked")
for sync in ICalSync.objects.filter(active=True):
sync: ICalSync
if sync.last_sync is None or timezone.now() > (sync.last_sync + sync.sync_interval):
logger.debug(f"Synchronizing {sync.name}...")
self.stdout.write(f"Synchronizing {sync.name}...")
events = sync.get_events()
added, existing, deleted = sync.target.upload_events(events, purge=sync.purge)
sync.last_sync = timezone.now()
sync.save()
msg = f"Sync for {sync.name} done! {added} events added, {existing} updated, and {deleted} purged."
logger.info(msg)
self.stdout.write(msg)
logger.debug(f"Sync for {sync.name} done! {added} events added, {existing} updated, and {deleted} purged.")
self.stdout.write("iCal sync complete!")
logger.debug("iCal sync complete!")