def from_dict(self, data):
        assert 'apps' in data
        assert 'minutes' in data
        _a = data['apps']
        _indexed = [track_common.app_info().load(d) for d in _a]
        _m = data['minutes']
        _minutes = {
            int(i) : track_common.minute().init(
                (
                    m[0],
                    {
                        _indexed[a]: c for a, c in m[1]
                    }
                )
            ) 
            for i, m in _m.items()
        }
        
        # x = {i:len({a:0 for a in i}) for i in l}
        _apps = {a.generate_identifier(): a for a in _indexed}
        with track_qt.change_emitter(self):

            self._apps = _apps
            self._minutes = _minutes

            if len(self._minutes) > 0:
                self._index_min = min(self._minutes.keys())
                self._index_max = max(self._minutes.keys())
            else:
                self._index_min = None
                self._index_max = None
                
            self._sort()
Esempio n. 2
0
    def from_dict(self, data):
        assert 'apps' in data
        assert 'minutes' in data
        _a = data['apps']
        _indexed = [track_common.app_info().load(d) for d in _a]
        _m = data['minutes']
        _minutes = {
            int(i): track_common.minute().init(
                (m[0], {_indexed[a]: c
                        for a, c in m[1]}))
            for i, m in _m.items()
        }

        # x = {i:len({a:0 for a in i}) for i in l}
        _apps = {a.generate_identifier(): a for a in _indexed}
        with track_qt.change_emitter(self):

            self._apps = _apps
            self._minutes = _minutes

            if len(self._minutes) > 0:
                self._index_min = min(self._minutes.keys())
                self._index_max = max(self._minutes.keys())
            else:
                self._index_min = None
                self._index_max = None

            self._sort()
Esempio n. 3
0
    def update(self):
        try:
            _today = track_common.today_int()
            self._current_minute = track_common.minutes_since_midnight()

            if self._active_day < _today:
                print("current minute is %d - it's midnight" % self._current_minute)
                #midnight!
                self.save('track-log-%d.json' % self._active_day)
                self.clear()

            self._active_day = _today

            self._current_minute = track_common.minutes_since_midnight()

            self._user_is_active = True

            self._idle_current = idle.getIdleSec()
            self._current_app_title = applicationinfo.get_active_window_title()
            try:
                self._current_process_exe = applicationinfo.get_active_process_name()
            except applicationinfo.UncriticalException as e: #necessary to run in i3
                self._current_process_exe = "Process not found"
                
            self._rules.highlight_string(self._current_app_title)
            self._rules.update_categories_time(self.get_time_per_categories())

            if self._idle_current > 10:
                self._user_is_active = False
                return

            _app = track_common.app_info(self._current_app_title, 
                            self._current_process_exe)
            _app._category = self._rules.get_first_matching_key(_app)

            _app = self._applications.update(
                        self._current_minute,
                        _app)

        except applicationinfo.UncriticalException as e:
            pass
Esempio n. 4
0
    def update(self):
        try:
            _today = track_common.today_int()
            self._current_minute = track_common.minutes_since_midnight()

            if self._active_day < _today:
                print("current minute is %d - it's midnight" % self._current_minute)
                #midnight!
                self.save('track-log-%d.json' % self._active_day)
                self.clear()

            self._active_day = _today

            self._current_minute = track_common.minutes_since_midnight()

            self._user_is_active = True

            self._idle_current = idle.getIdleSec()
            self._current_app_title = applicationinfo.get_active_window_title()
            self._current_process_exe = applicationinfo.get_active_process_name()

            self._rules.highlight_string(self._current_app_title)

            if self._idle_current > 10:
                self._user_is_active = False
                return

            _app = track_common.app_info(self._current_app_title, 
                            self._current_process_exe)
            _app._category = self._rules.get_first_matching_key(_app)

            _app = self._applications.update(
                        self._current_minute,
                        _app)

        except applicationinfo.UncriticalException as e:
            pass