2
# -*- coding: utf-8 -*-
4
# Copyright (C) 2013 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/>.
27
from subprocess import PIPE
32
import dbus.mainloop.glib
33
from gi.repository import GObject
35
from policykit import PolicyKitService
36
from cleanerinfo import CACHE_FLAG, CACHE_PACKAGES, CACHE_SIZE
37
from hardwareinfo import CPU, RAM
38
from systeminfo import HOSTNAME, PLATFORM, DISTRO, DESKTOP_FULLNAME
39
from updateinfo import UPDATE_TIME
40
from userinfo import CURRENT_USER, HOME_DIRECTORY, SHELL, LANGUAGE
42
log = logging.getLogger('Daemon')
44
INTERFACE = "com.ubuntukylin.Ihu"
46
#PATH = "/com/ubuntukylin_assistant/daemon"
48
class Daemon(PolicyKitService):
49
def __init__ (self, bus, mainloop):
50
bus_name = dbus.service.BusName(INTERFACE, bus=bus)
51
PolicyKitService.__init__(self, bus_name, PATH)
52
self.mainloop = mainloop
54
# provide a dbus signal template by kobe
55
@dbus.service.signal(INTERFACE, signature='s')
56
def test1(self, contents):
59
# provide a dbus method template by kobe
60
@dbus.service.method(INTERFACE,
61
in_signature='ii', out_signature='i')
62
def test_add(self, num1, num2):
63
print("receive:", num1, num2)
66
# a dbus method which get pc messages by kobe
67
@dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}')
70
CLIPS_DICT['cache_flag'] = CACHE_FLAG
71
CLIPS_DICT['cache_packages'] = CACHE_PACKAGES
72
CLIPS_DICT['cache_size'] = CACHE_SIZE
73
CLIPS_DICT['cpu'] = CPU
74
CLIPS_DICT['ram'] = RAM
75
CLIPS_DICT['hostname'] = HOSTNAME
76
CLIPS_DICT['platform'] = PLATFORM
77
CLIPS_DICT['distribution'] = DISTRO
78
CLIPS_DICT['desktopenvironment'] = DESKTOP_FULLNAME
79
CLIPS_DICT['update_time'] = UPDATE_TIME
80
CLIPS_DICT['currrent_user'] = CURRENT_USER
81
CLIPS_DICT['home_path'] = HOME_DIRECTORY
82
CLIPS_DICT['shell'] = SHELL
83
CLIPS_DICT['language'] = LANGUAGE