def __init__(self, storage): threading.Thread.__init__(self) from hamster.lib import i18n i18n.setup_i18n() self.sem = threading.Semaphore(0) self.done = threading.Semaphore(0) self.activity = None self.running = True self.storage = storage
import atexit import gobject import sys, os from subprocess import Popen import gtk from docky.docky import DockyItem, DockySink from signal import signal, SIGTERM from sys import exit from hamster import client from hamster.lib import stuff, i18n i18n.setup_i18n() class DockyHamsterItem(DockyItem): def __init__(self, path): DockyItem.__init__(self, path) self.storage = client.Storage() self.storage.connect("facts-changed", lambda storage: self.refresh_hamster()) self.storage.connect("activities-changed", lambda storage: self.refresh_hamster()) self.id_map = {} #menu items self.update_text() self.add_actions() gobject.timeout_add_seconds(60, self.refresh_hamster)
cats.append("{}: {}".format(cat, duration.format())) total_duration += duration for line in word_wrap(", ".join(cats), 80): print(line) print("Total: ", total_duration.format()) print() def version(self): print(hamster.__version__) if __name__ == '__main__': from hamster.lib import i18n i18n.setup_i18n() usage = _(""" Actions: * add [activity [start-time [end-time]]]: Add an activity * stop: Stop tracking current activity. * list [start-date [end-date]]: List activities * search [terms] [start-date [end-date]]: List activities matching a search term * export [html|tsv|ical|xml] [start-date [end-date]]: Export activities with the specified format * current: Print current activity * activities: List all the activities names, one per line. * categories: List all the categories names, one per line. * overview / preferences / add / about: launch specific window
#!/usr/bin/env python3 # nicked off gwibber import dbus import dbus.service from gi.repository import GLib as glib from gi.repository import Gio as gio import hamster from hamster import logger as hamster_logger from hamster.lib import i18n i18n.setup_i18n() # noqa: E402 from hamster.storage import db from hamster.lib import datetime as dt from hamster.lib import default_logger from hamster.lib.dbus import (DBusMainLoop, fact_signature, from_dbus_date, from_dbus_fact, from_dbus_fact_json, from_dbus_range, to_dbus_fact, to_dbus_fact_json) from hamster.lib.fact import Fact, FactError logger = default_logger(__file__) DBusMainLoop(set_as_default=True) loop = glib.MainLoop() if "org.gnome.Hamster" in dbus.SessionBus().list_names(): print("Found hamster-service already running, exiting") quit()