Esempio n. 1
0
def get_timeinfo_hamster(
        date=datetime.now(), baseurl='', loginfo={}, activities=[]):
    default_activity = get_default_activity(activities)
    from hamster.client import Storage
    sto = Storage()
    facts = sto.get_facts(date)
    bookings = []
    for fact in facts:
        #delta = (fact.end_time or datetime.now()) - fact.start_time
        #hours = round(fact.delta.seconds / 3600. * 4 + .25) / 4.
        hours = fact.delta.seconds / 3600.
        existing = filter(
            lambda b: b['description'] == fact.activity and b['spent_on'] ==
            fact.date, bookings)
        if existing:
            existing[0]['hours'] += hours
            continue
        ticket = get_ticket_no(fact.tags + [fact.activity] +
                               [fact.description or ''])
        bookings.append({
            'issue_id': ticket,
            'spent_on': fact.date,
            'hours': hours,
            'description': fact.activity,
            'activity_id': default_activity['id'],
            'comments': '; '.join(loginfo.get(ticket, []))
        })
    return bookings
Esempio n. 2
0
    def __init__(self):
        graphics.Scene.__init__(self)
        self.storage = Storage()

        self._load_end_date = dt.datetime.now()
        self.facts = []

        self.label = layout.Label("Loading...", y=100, color="#666", size=50)
        self.add_child(layout.VBox(self.label))

        gobject.timeout_add(10, self.load_facts)
Esempio n. 3
0
    def __init__(self):
        self.version = hamster.__version__
        if hamster.installed:
            from hamster import defs  # only available when running installed
            self.data_dir = os.path.join(defs.DATA_DIR, "hamster")
        else:
            # running from sources
            module_dir = os.path.dirname(os.path.realpath(__file__))
            self.data_dir = os.path.join(module_dir, '..', '..', '..', 'data')

        self.data_dir = os.path.realpath(self.data_dir)
        self.storage = Storage()
        self.home_data_dir = os.path.realpath(os.path.join(xdg_data_home, "hamster"))
Esempio n. 4
0
    def __init__(self):
        try:
            from hamster import defs
            self.data_dir = os.path.join(defs.DATA_DIR, "hamster-time-tracker")
            self.version = defs.VERSION
        except:
            # if defs is not there, we are running from sources
            module_dir = os.path.dirname(os.path.realpath(__file__))
            self.data_dir = os.path.join(module_dir, '..', '..', '..', 'data')
            self.version = "uninstalled"

        self.data_dir = os.path.realpath(self.data_dir)
        self.storage = Storage()
        self.home_data_dir = os.path.realpath(
            os.path.join(xdg_data_home, "hamster-time-tracker"))