Kaydet (Commit) b6d74eae authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Fixed dbus exception class, filemode checking enabled

üst 0e1d4995
2018-05-04 Suleyman Poyraz <nipalensisaquila@gmail.com>:
* Fixed dbus exception class.
......@@ -120,12 +120,12 @@ class Call:
met = getattr(obj, self.method)
try:
return met(dbus_interface="%s.%s.%s" % (self.link.interface, self.group, self.class_), timeout=self.timeout, *args)
except dbus.DBusException as exception:
except dbus.exceptions.DBusException as exception:
if "policy.auth" in exception._dbus_error_name or "Scom.PolicyKit" in exception._dbus_error_name:
action = exception.get_dbus_message()
if self.queryPolicyKit(action):
return self.call(*args, **kwargs)
raise dbus.DBusException(exception)
raise dbus.exceptions.DBusException(exception)
else:
raise AttributeError("Package name required for non-async calls.")
......@@ -162,14 +162,14 @@ class Link:
code = code.split("_")[0]
obj = self.bus.get_object(self.address, '/', introspect=False)
obj.setLocale(code, dbus_interface=self.interface)
except dbus.DBusException as exception:
except dbus.exceptions.DBusException as exception:
pass
def cancel(self, method="*"):
try:
obj = self.bus.get_object(self.address, '/', introspect=False)
return obj.cancel(method, dbus_interface=self.interface)
except dbus.DBusException as exception:
except dbus.exceptions.DBusException as exception:
return 0
def listRunning(self, all=True):
......@@ -177,7 +177,7 @@ class Link:
try:
obj = self.bus.get_object(self.address, '/', introspect=False)
methods = obj.listRunning(all, dbus_interface=self.interface)
except dbus.DBusException as exception:
except dbus.exceptions.DBusException as exception:
return methods
for index, method in enumerate(methods):
if method.startswith("%s." % self.interface):
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -41,7 +41,7 @@ def main():
printUsage()
try:
apps = obj.listModelApplications(model, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e:
except dbus.exceptions.DBusException ase:
handleError(e)
return
for app in apps:
......@@ -53,7 +53,7 @@ def main():
printUsage()
try:
models = obj.listApplicationModels(app, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e:
except dbus.exceptions.DBusException ase:
handleError(e)
for model in models:
print model
......@@ -67,7 +67,7 @@ def main():
path = os.path.realpath(script)
try:
obj.register(app, model, path, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e:
except dbus.exceptions.DBusException ase:
handleError(e)
elif sys.argv[1] == "remove":
try:
......@@ -76,7 +76,7 @@ def main():
printUsage()
try:
obj.remove(app, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e:
except dbus.exceptions.DBusException ase:
handleError(e)
else:
printUsage()
......
......@@ -39,7 +39,7 @@ def connectToDBus():
try:
bus = dbus.SystemBus()
except dbus.DBusException:
except dbus.exceptions.DBusException:
return False
if bus:
......@@ -52,7 +52,7 @@ def addUser():
user["home"], user["shell"], user["password"],
user["groups"], user["grants"], user["blocks"],
dbus_interface="tr.org.sulin.scom.User.Manager")
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
fail("Error: %s" % e)
......
File mode changed from 100644 to 100755
......@@ -25,7 +25,7 @@ def connectToDBus():
try:
bus = dbus.SystemBus()
except dbus.DBusException:
except dbus.exceptions.DBusException:
return False
if bus:
......@@ -36,7 +36,7 @@ def delUser():
try:
obj.deleteUser(user["uid"], user["deletefiles"],
dbus_interface="tr.org.sulin.scom.User.Manager")
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
fail("Error: %s." % e)
......
......@@ -676,7 +676,7 @@ def start_services(extras=None):
os.setuid(0)
try:
bus = dbus.SystemBus()
except dbus.DBusException:
except dbus.exceptions.DBusException:
UI.error(_("Cannot connect to DBus, services won't be started"))
return
......@@ -685,7 +685,7 @@ def start_services(extras=None):
for service in extras:
try:
manage_service(service, "start")
except dbus.DBusException:
except dbus.exceptions.DBusException:
pass
else:
......@@ -740,7 +740,7 @@ def stop_services():
UI.info(_("Stopping services"))
try:
bus = dbus.SystemBus()
except dbus.DBusException:
except dbus.exceptions.DBusException:
return
for service in get_service_list(bus, _all=True):
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -143,7 +143,7 @@ def readyService(service):
link.setLocale()
link.useAgent(False)
link.System.Service[service].ready()
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
print(_("Unable to start %s:") % service)
print(" %s" % e.args[0])
......@@ -153,7 +153,7 @@ def startService(service, quiet=False):
link.setLocale()
link.useAgent(False)
link.System.Service[service].start()
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
print(_("Unable to start %s:") % service)
print(" %s" % e.args[0])
return
......@@ -166,7 +166,7 @@ def stopService(service, quiet=False):
link.setLocale()
link.useAgent(False)
link.System.Service[service].stop()
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
print(_("Unable to stop %s:") % service)
print(" %s" % e.args[0])
return
......@@ -179,7 +179,7 @@ def setServiceState(service, state, quiet=False):
link.setLocale()
link.useAgent(False)
link.System.Service[service].setState(state)
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
print(_("Unable to set %s state:") % service)
print(" %s" % e.args[0])
return
......@@ -197,7 +197,7 @@ def reloadService(service, quiet=False):
link.setLocale()
link.useAgent(False)
link.System.Service[service].reload()
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
print(_("Unable to reload %s:") % service)
print(" %s" % e.args[0])
return
......@@ -288,7 +288,7 @@ def manage_dbus(op, use_color, quiet):
elif op in ["info", "status", "list"]:
try:
dbus.SystemBus()
except dbus.DBusException:
except dbus.exceptions.DBusException:
print(_("DBus is not running."))
return
print(_("DBus is running."))
......@@ -350,7 +350,7 @@ def main(args):
elif args[1] in operations:
try:
manage_service(args[0].replace("-", "_"), args[1], use_color, quiet)
except dbus.DBusException as e:
except dbus.exceptions.DBusException as e:
if "Unable to find" in str(e):
print(_("No such service: %s") % args[0])
else:
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755