2
# -*- coding: utf-8 -*-
4
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
24
def __init__(self, homedir):
27
path = '%s/.local/share/zeitgeist/' % homedir
29
path = os.path.expanduser('~/.local/share/zeitgeist/')
30
self.full_path = path + 'activity.sqlite'
31
if not os.path.exists(self.full_path):
32
raise Exception("Dashhistory: path did not exist")
34
def scan_the_records(self):
35
self.browser_conn = sqlite3.connect(self.full_path)
36
self.browser_cur = self.browser_conn.cursor()
38
sql_select = "SELECT COUNT(*) FROM event_view"
39
self.browser_cur.execute(sql_select)
40
number = self.browser_cur.fetchone()[0]
42
self.browser_cur.close()
43
self.browser_conn.close()
46
def clean_the_records(self):
47
tmp_path = self.full_path
48
user = tmp_path.split('/')[2]
50
cmd = "su - %s -c 'zeitgeist-daemon --replace & >& /dev/null'" % user
51
(status, output) = commands.getstatusoutput(cmd)