Exemplo n.º 1
0
    def update_last_synced(self):
        if not self.tracker.syncdata:
            return
        messages = {}
        now = datetime.datetime.now()

        for remote in self.tracker.syncdata.diverged_remotes:
            messages.setdefault(remote, []).append("diverged")

        for connection in self.tracker.syncdata.connections.values():
            messages.setdefault(connection.remote_name, []).append(
                "connected"
            )

        for remote, dt in self.tracker.syncdata.last_synced.items():
            td = now - dt
            delta = timefmt.small_approx_delta(td)
            messages.setdefault(remote, []).append(
                "last synced {delta} ago".format(delta=delta)
            )

        final_message = "; ".join(sorted(
            "{}: {}".format(remote, ", ".join(remote_messages))
            for remote, remote_messages in messages.items()
        ))

        self.sendmessage({
            "sync_status": final_message
        })
Exemplo n.º 2
0
 def sd(*a, **kw):
     return timefmt.small_approx_delta(datetime.timedelta(*a, **kw))