Skip to content

Commit

Permalink
Removed PySide code, Added sort services support
Browse files Browse the repository at this point in the history
git-svn-id: https://camelo.conectiva/repos/projetos/qtlab/mcc2@9008 aeaf0dc8-91d7-0310-8701-e1fc1a66ab8d
  • Loading branch information
wiliam committed Apr 19, 2011
1 parent 26e086f commit 68a3df7
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions mcc2/frontends/services/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()
bus = dbus.SystemBus()#private=True)
proxy = bus.get_object('org.mandrivalinux.mcc2.Services',
'/org/mandrivalinux/mcc2/Services')
interface = dbus.Interface(proxy, 'org.mandrivalinux.mcc2.Services')
Expand All @@ -21,9 +21,9 @@ def __init__(self, servicePath, serviceDetails, parent):
self.__servicePath = servicePath
self.__serviceDetails = serviceDetails

properties_proxy = bus.get_object('org.freedesktop.systemd1', self.__servicePath)
properties_interface = dbus.Interface(properties_proxy, 'org.freedesktop.DBus.Properties')
properties_interface.connect_to_signal('PropertiesChanged', self.on_properties_changed)
self.properties_proxy = bus.get_object('org.freedesktop.systemd1', self.__servicePath)
self.properties_interface = dbus.Interface(self.properties_proxy, 'org.freedesktop.DBus.Properties')
self.properties_interface.connect_to_signal('PropertiesChanged', self.on_properties_changed)

def __getName(self):
return self.__serviceDetails['Id']
Expand All @@ -48,7 +48,6 @@ def start(self):
print "timed out"
if error.get_dbus_name() == "org.mandrivalinux.mcc2.Services.Error.NotAuthorized":
print 'Not Authorized'
self.update()

def stop(self):
try:
Expand All @@ -58,17 +57,15 @@ def stop(self):
print "Timed out"
if error.get_dbus_name() == "org.mandrivalinux.mcc2.Services.Error.NotAuthorized":
print 'Not Authorized'
self.update()

def restart(self):
try:
interface.Restart(self.name, 'fail')
except dbus.exceptions.DBusException, error:
if error.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
print "timed out"
print "timed out"
if error.get_dbus_name() == "org.mandrivalinux.mcc2.Services.Error.NotAuthorized":
print 'Not Authorized'
self.update()

def on_properties_changed(self, *args, **kargs):
self.update()
Expand All @@ -80,14 +77,6 @@ def update(self):
#changed = QtCore.Signal()
changed = QtCore.pyqtSignal()

"""
name = QtCore.Property(unicode, __getName, notify=changed)
description = QtCore.Property(unicode, __getDescription, notify=changed)
loadState = QtCore.Property(unicode, __getLoadState, notify=changed)
activeState = QtCore.Property(unicode, __getActiveState, notify=changed)
subState = QtCore.Property(unicode, __getSubState, notify=changed)
"""

name = QtCore.pyqtProperty(unicode, __getName, notify=changed)
description = QtCore.pyqtProperty(unicode, __getDescription, notify=changed)
loadState = QtCore.pyqtProperty(unicode, __getLoadState, notify=changed)
Expand Down Expand Up @@ -124,13 +113,11 @@ def restart(self, row):
service.restart()

def populate(self):
count = 0
services = []
for servicePath in interface.List():
serviceDetails = interface.ServiceDetails(servicePath[6])
# This filtering is done to avoid show up more than one .device unit
# under different names
if serviceDetails['Following'] == "":
self.__services.append(Service(servicePath[6], serviceDetails, parent=self.parent))
else:
count = count + 1
#print '%d .device unit removed by duplicity' % count
services.append(Service(servicePath[6], serviceDetails, parent=self.parent))
self.__services = sorted(services, key=lambda service: service.name)

0 comments on commit 68a3df7

Please sign in to comment.