How to use the lino.utils.dblogger.info function in lino

To help you get started, we’ve selected a few lino examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
if qs.count() > 1:
                                dblogger.warning(
                                    "Found more than 1 Place for location %r", location_name)
                        set_kw.update(place=pl)
                    else:
                        set_kw.update(place=None)
                    if event.transp.value == 'TRANSPARENT':
                        set_kw.update(transparent=True)
                    else:
                        set_kw.update(transparent=False)
                    set_kw.update(description=event.description.value)
                    set_kw.update(calendar=dbcal)
                    #~ set_kw.update(location=event.location.value)
                    #~ kw.update(dtend=event.dtend.value)

                    dblogger.info("It's a RecurringComponent")
                    if event.rruleset:
                        try:
                            obj = RecurrenceSet.objects.get(uid=uid)
                            assert obj.calendar == dbcal
                            rs_updated += 1
                        except RecurrenceSet.DoesNotExist, e:
                        #~ except Exception, e:
                            obj = RecurrenceSet(uid=uid)
                            obj.calendar = dbcal
                            obj.user = dbcal.user
                            rs_created += 1
                        #~ raise Exception("20110823 must save rrule, rdate etc... %s" % type(event.rrule_list))
                        obj.rrules = '\n'.join(
                            [r.value for r in event.rrule_list])
                        #~ obj.exrules = '\n'.join([r.value for r in event.exrule_list])
                        #~ obj.rdates = '\n'.join([r.value for r in event.rdate_list])
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
if not from_date:
        from_date = datetime.datetime.now() - datetime.timedelta(days=365)
    until_date = datetime.datetime.now() + datetime.timedelta(days=365)

    #~ from_date = aware(from_date)
    #~ until_date = aware(until_date)

    #~ print from_date.tzinfo, until_date.tzinfo
    #~ raise Exception("20110823")

    results = calendar.date_search(from_date, until_date)
    if results:
        for comp in results:
            #~ if len(list(comp.instance.getChildren())) != 1:
                #~ raise Exception("comp.instance.getChildren() is %s" % list(comp.instance.getChildren()))
            dblogger.info(
                "Got calendar component <<<\n%s\n>>>",
                prettyPrint(comp.instance))

            if comp.instance.vevent:
                event = comp.instance.vevent
                if isinstance(event, RecurringComponent):
                    """
                    in a google calendar, all events are parsed to a 
                    RecurringComponent. if event.rruleset is None 
                    we consider them non recurrent.
                    """

                    uid = event.uid.value
                    dtstart = event.dtstart.value

                    get_kw = {}
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
else:
            vevent.add('dtstart').value = obj.start_date
        if obj.end_time:
            vevent.add('dtend').value = datetime.datetime.combine(
                obj.end_date, obj.end_time)
        else:
            vevent.add('dtend').value = obj.end_date
        vevent.add('transp').value = iif(
            obj.transparent, 'TRANSPARENT', 'OPAQUE')
        vevent.add('summary').value = obj.summary
        if obj.place:
            vevent.add('location').value = obj.place.name
        vevent.add('description').value = obj.description
        event = caldav.Event(
            client, data=mycal.serialize(), parent=calendar).save()
    dblogger.info("--> Sent %d events to calendar server.", n)
github lino-framework / lino / lino / utils / dumpy_old.py View on Github external
#~ if ok:
                    #~ sorted.append(model)
                    #~ unsorted.remove(model)
                    #~ hope = True
                    #~ break
                #~ else:
                    #~ guilty[model] = deps
                #~ print model.__name__, "depends on", [m.__name__ for m in deps]
        if unsorted:
            assert len(unsorted) == len(guilty)
            msg = "There are %d models with circular dependencies :\n" % len(unsorted)
            msg += "- " + '\n- '.join([
                full_model_name(m)+' (depends on %s)' % ", ".join([full_model_name(d) for d in deps]) for m,deps in guilty.items()])
            for ln in msg.splitlines():
                self.stream.write('\n    # %s' % ln)
            dblogger.info(msg)
            sorted.extend(unsorted)              
        return sorted
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
for dtstart in dtlist:
                        dtend = dtstart + duration
                        get_kw = dt2kw(dtstart, 'start', **get_kw)
                        set_kw = dt2kw(dtend, 'end', **set_kw)
                        try:
                            obj = Event.objects.get(**get_kw)
                            count_update += 1
                        except Event.DoesNotExist, e:
                        #~ except Exception, e:
                            obj = Event(**get_kw)
                            obj.user = dbcal.user
                            count_new += 1
                        setkw(obj, **set_kw)
                        obj.full_clean()
                        obj.save()
                        dblogger.info("Saved %s", obj)
                        ev_touched.add(obj.pk)

                else:
                    raise Exception(
                        "comp.instance.vevent is a %s (expected VEvent)" % type(event))
            else:
                raise Exception(
                    "Got unhandled component %s"
                    % comp.instance.prettyPrint())
                #~ print "children:", [c for c in comp.instance.getChildren()]

            #~ raise StopIteration
    qs = dbcal.event_set.exclude(id__in=ev_touched)
    count_deleted = qs.count()
    qs.delete()  # note: doesn't call delete methods of individual objects
    qs = dbcal.recurrenceset_set.exclude(id__in=rs_touched)
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
obj.summary = event.summary.value
                        obj.description = event.description.value
                        setkw(obj, **dt2kw(dtstart, 'start'))
                        obj.full_clean()
                        obj.save()
                        dblogger.info("Saved %s", obj)
                        rs_touched.add(obj.pk)

                        set_kw.update(rset=obj)
                        if getattr(dtstart, 'tzinfo', False):
                            dtlist = event.rruleset.between(
                                aware(from_date), aware(until_date))
                        else:
                            dtlist = event.rruleset.between(
                                from_date, until_date)
                        dblogger.info("rrulset.between() --> %s", dtlist)
                    else:
                        dtlist = [dtstart]
                        dblogger.info("No rruleset")
                    duration = event.dtend.value - dtstart
                    for dtstart in dtlist:
                        dtend = dtstart + duration
                        get_kw = dt2kw(dtstart, 'start', **get_kw)
                        set_kw = dt2kw(dtend, 'end', **set_kw)
                        try:
                            obj = Event.objects.get(**get_kw)
                            count_update += 1
                        except Event.DoesNotExist, e:
                        #~ except Exception, e:
                            obj = Event(**get_kw)
                            obj.user = dbcal.user
                            count_new += 1
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
raise Exception(
                        "comp.instance.vevent is a %s (expected VEvent)" % type(event))
            else:
                raise Exception(
                    "Got unhandled component %s"
                    % comp.instance.prettyPrint())
                #~ print "children:", [c for c in comp.instance.getChildren()]

            #~ raise StopIteration
    qs = dbcal.event_set.exclude(id__in=ev_touched)
    count_deleted = qs.count()
    qs.delete()  # note: doesn't call delete methods of individual objects
    qs = dbcal.recurrenceset_set.exclude(id__in=rs_touched)
    rs_deleted = qs.count()
    qs.delete()  # note: doesn't call delete methods of individual objects
    dblogger.info(
        "--> Created %d, updated %d, deleted %s Events",
        count_new, count_update, count_deleted)
    dblogger.info(
        "--> Created %d, updated %d, deleted %s RecurrenceSets",
        rs_created, rs_updated, rs_deleted)
github lino-framework / lino / lino / utils / dumpy_old.py View on Github external
while self.saved and self.save_later:
            try_again = []
            for msg_objlist in self.save_later.values():
                for objlist in msg_objlist.values():
                    try_again += objlist
            logger.info("Trying again with %d unsaved instances.",
                len(try_again))
            self.save_later = {}
            self.saved = 0
            for obj in try_again:
                obj.try_save() # ,*args,**kw):
                #~ if obj.try_save(): # ,*args,**kw):
                    #~ self.saved += 1
                #~ else:
                    #~ self.save_later.append(obj)
            dblogger.info("Saved %d instances.",self.saved)
github lino-framework / lino / lino / modlib / cal / management / commands / watch_calendars.py View on Github external
raise Exception(
                    "Got unhandled component %s"
                    % comp.instance.prettyPrint())
                #~ print "children:", [c for c in comp.instance.getChildren()]

            #~ raise StopIteration
    qs = dbcal.event_set.exclude(id__in=ev_touched)
    count_deleted = qs.count()
    qs.delete()  # note: doesn't call delete methods of individual objects
    qs = dbcal.recurrenceset_set.exclude(id__in=rs_touched)
    rs_deleted = qs.count()
    qs.delete()  # note: doesn't call delete methods of individual objects
    dblogger.info(
        "--> Created %d, updated %d, deleted %s Events",
        count_new, count_update, count_deleted)
    dblogger.info(
        "--> Created %d, updated %d, deleted %s RecurrenceSets",
        rs_created, rs_updated, rs_deleted)