Beispiel #1
0
 def save(self, filename=None):
     _file_name = filename if filename else "track-%s.json" % track_common.today_str() 
     # print(_file_name)
     _app_data = self._applications.__data__()
     with open(_file_name, 'w') as _file:
         json.dump(_app_data, _file,
                   sort_keys=True) #, indent=4, separators=(',', ': '))
         
     _test_model = track_qt.active_applications(None)
     _test_model.from_dict(_app_data)
     assert self._applications == _test_model
Beispiel #2
0
    def __init__(self, parent):
        self._idle_current = 0
        self._current_minute = 0  # does not need to be highest minute index
        self._current_app_title = ""
        self._current_process_exe = ""
        self._user_is_active = True
        self._active_day = track_common.today_int()
        

        # -- persist
        self._applications = track_qt.active_applications(parent)
        self._rules = track_qt.rules_model(parent)
Beispiel #3
0
def test_import():
    a = track_qt.active_applications(None)
    _total_dur = 0
    _count = 0
    _lunch_time = 12 * 60 + 50
    for root, dirs, files in os.walk('.'):
        for _f in [f for f in sorted(files) if f.endswith('.json')]:
            _file = os.path.join(root, _f)
            c = json.load(open(_file))
            try:
                a.from_dict(c)
            except:
                print('ERROR: could not load "%s"' % _file)
                continue
            _end = a.end_index()
            _begin = a.begin_index()
            _dur = _end - _begin

            (_b, _e), _a = a.info(_lunch_time)
            _lunch_dur = _e - _b
            if not (_e - _b >= 30 and _a == 'idle'):
                _lunch_dur = 0
                print("WARNING: no lunch time found for %s" % _file)
            _dur -= _lunch_dur
            if _dur > 300:
                _total_dur += _dur
                _count += 1
            else:
                print('WARNING: ignore "%s" - less than 5h tracked' % _file)

            print("f: %23s, count: %3d, begin: %s (%4d), end: %s (%4d), lunch: %7s, dur: %7s" % (
                _file, a.rowCount(), 
                track_common.mins_to_date(_begin), _begin, 
                track_common.mins_to_date(_end), _end, 
                track_common.mins_to_dur(_lunch_dur),
                track_common.mins_to_dur(_dur)))
            # print(re.search('track-.*.json', _file) is not None)
    print(track_common.mins_to_dur(_total_dur / _count))
def test_active_applications():
    aa = track_qt.active_applications(None)
def test_active_applications():
    aa = track_qt.active_applications(None)