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: ...@@ -120,12 +120,12 @@ class Call:
met = getattr(obj, self.method) met = getattr(obj, self.method)
try: try:
return met(dbus_interface="%s.%s.%s" % (self.link.interface, self.group, self.class_), timeout=self.timeout, *args) 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: if "policy.auth" in exception._dbus_error_name or "Scom.PolicyKit" in exception._dbus_error_name:
action = exception.get_dbus_message() action = exception.get_dbus_message()
if self.queryPolicyKit(action): if self.queryPolicyKit(action):
return self.call(*args, **kwargs) return self.call(*args, **kwargs)
raise dbus.DBusException(exception) raise dbus.exceptions.DBusException(exception)
else: else:
raise AttributeError("Package name required for non-async calls.") raise AttributeError("Package name required for non-async calls.")
...@@ -162,14 +162,14 @@ class Link: ...@@ -162,14 +162,14 @@ class Link:
code = code.split("_")[0] code = code.split("_")[0]
obj = self.bus.get_object(self.address, '/', introspect=False) obj = self.bus.get_object(self.address, '/', introspect=False)
obj.setLocale(code, dbus_interface=self.interface) obj.setLocale(code, dbus_interface=self.interface)
except dbus.DBusException as exception: except dbus.exceptions.DBusException as exception:
pass pass
def cancel(self, method="*"): def cancel(self, method="*"):
try: try:
obj = self.bus.get_object(self.address, '/', introspect=False) obj = self.bus.get_object(self.address, '/', introspect=False)
return obj.cancel(method, dbus_interface=self.interface) return obj.cancel(method, dbus_interface=self.interface)
except dbus.DBusException as exception: except dbus.exceptions.DBusException as exception:
return 0 return 0
def listRunning(self, all=True): def listRunning(self, all=True):
...@@ -177,7 +177,7 @@ class Link: ...@@ -177,7 +177,7 @@ class Link:
try: try:
obj = self.bus.get_object(self.address, '/', introspect=False) obj = self.bus.get_object(self.address, '/', introspect=False)
methods = obj.listRunning(all, dbus_interface=self.interface) methods = obj.listRunning(all, dbus_interface=self.interface)
except dbus.DBusException as exception: except dbus.exceptions.DBusException as exception:
return methods return methods
for index, method in enumerate(methods): for index, method in enumerate(methods):
if method.startswith("%s." % self.interface): 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(): ...@@ -41,7 +41,7 @@ def main():
printUsage() printUsage()
try: try:
apps = obj.listModelApplications(model, dbus_interface='tr.org.pardus.comar3') apps = obj.listModelApplications(model, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e: except dbus.exceptions.DBusException ase:
handleError(e) handleError(e)
return return
for app in apps: for app in apps:
...@@ -53,7 +53,7 @@ def main(): ...@@ -53,7 +53,7 @@ def main():
printUsage() printUsage()
try: try:
models = obj.listApplicationModels(app, dbus_interface='tr.org.pardus.comar3') models = obj.listApplicationModels(app, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e: except dbus.exceptions.DBusException ase:
handleError(e) handleError(e)
for model in models: for model in models:
print model print model
...@@ -67,7 +67,7 @@ def main(): ...@@ -67,7 +67,7 @@ def main():
path = os.path.realpath(script) path = os.path.realpath(script)
try: try:
obj.register(app, model, path, dbus_interface='tr.org.pardus.comar3') obj.register(app, model, path, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e: except dbus.exceptions.DBusException ase:
handleError(e) handleError(e)
elif sys.argv[1] == "remove": elif sys.argv[1] == "remove":
try: try:
...@@ -76,7 +76,7 @@ def main(): ...@@ -76,7 +76,7 @@ def main():
printUsage() printUsage()
try: try:
obj.remove(app, dbus_interface='tr.org.pardus.comar3') obj.remove(app, dbus_interface='tr.org.pardus.comar3')
except dbus.DBusException, e: except dbus.exceptions.DBusException ase:
handleError(e) handleError(e)
else: else:
printUsage() printUsage()
......
...@@ -39,7 +39,7 @@ def connectToDBus(): ...@@ -39,7 +39,7 @@ def connectToDBus():
try: try:
bus = dbus.SystemBus() bus = dbus.SystemBus()
except dbus.DBusException: except dbus.exceptions.DBusException:
return False return False
if bus: if bus:
...@@ -52,7 +52,7 @@ def addUser(): ...@@ -52,7 +52,7 @@ def addUser():
user["home"], user["shell"], user["password"], user["home"], user["shell"], user["password"],
user["groups"], user["grants"], user["blocks"], user["groups"], user["grants"], user["blocks"],
dbus_interface="tr.org.sulin.scom.User.Manager") dbus_interface="tr.org.sulin.scom.User.Manager")
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
fail("Error: %s" % e) fail("Error: %s" % e)
......
File mode changed from 100644 to 100755
...@@ -25,7 +25,7 @@ def connectToDBus(): ...@@ -25,7 +25,7 @@ def connectToDBus():
try: try:
bus = dbus.SystemBus() bus = dbus.SystemBus()
except dbus.DBusException: except dbus.exceptions.DBusException:
return False return False
if bus: if bus:
...@@ -36,7 +36,7 @@ def delUser(): ...@@ -36,7 +36,7 @@ def delUser():
try: try:
obj.deleteUser(user["uid"], user["deletefiles"], obj.deleteUser(user["uid"], user["deletefiles"],
dbus_interface="tr.org.sulin.scom.User.Manager") dbus_interface="tr.org.sulin.scom.User.Manager")
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
fail("Error: %s." % e) fail("Error: %s." % e)
......
...@@ -676,7 +676,7 @@ def start_services(extras=None): ...@@ -676,7 +676,7 @@ def start_services(extras=None):
os.setuid(0) os.setuid(0)
try: try:
bus = dbus.SystemBus() bus = dbus.SystemBus()
except dbus.DBusException: except dbus.exceptions.DBusException:
UI.error(_("Cannot connect to DBus, services won't be started")) UI.error(_("Cannot connect to DBus, services won't be started"))
return return
...@@ -685,7 +685,7 @@ def start_services(extras=None): ...@@ -685,7 +685,7 @@ def start_services(extras=None):
for service in extras: for service in extras:
try: try:
manage_service(service, "start") manage_service(service, "start")
except dbus.DBusException: except dbus.exceptions.DBusException:
pass pass
else: else:
...@@ -740,7 +740,7 @@ def stop_services(): ...@@ -740,7 +740,7 @@ def stop_services():
UI.info(_("Stopping services")) UI.info(_("Stopping services"))
try: try:
bus = dbus.SystemBus() bus = dbus.SystemBus()
except dbus.DBusException: except dbus.exceptions.DBusException:
return return
for service in get_service_list(bus, _all=True): 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): ...@@ -143,7 +143,7 @@ def readyService(service):
link.setLocale() link.setLocale()
link.useAgent(False) link.useAgent(False)
link.System.Service[service].ready() link.System.Service[service].ready()
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
print(_("Unable to start %s:") % service) print(_("Unable to start %s:") % service)
print(" %s" % e.args[0]) print(" %s" % e.args[0])
...@@ -153,7 +153,7 @@ def startService(service, quiet=False): ...@@ -153,7 +153,7 @@ def startService(service, quiet=False):
link.setLocale() link.setLocale()
link.useAgent(False) link.useAgent(False)
link.System.Service[service].start() link.System.Service[service].start()
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
print(_("Unable to start %s:") % service) print(_("Unable to start %s:") % service)
print(" %s" % e.args[0]) print(" %s" % e.args[0])
return return
...@@ -166,7 +166,7 @@ def stopService(service, quiet=False): ...@@ -166,7 +166,7 @@ def stopService(service, quiet=False):
link.setLocale() link.setLocale()
link.useAgent(False) link.useAgent(False)
link.System.Service[service].stop() link.System.Service[service].stop()
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
print(_("Unable to stop %s:") % service) print(_("Unable to stop %s:") % service)
print(" %s" % e.args[0]) print(" %s" % e.args[0])
return return
...@@ -179,7 +179,7 @@ def setServiceState(service, state, quiet=False): ...@@ -179,7 +179,7 @@ def setServiceState(service, state, quiet=False):
link.setLocale() link.setLocale()
link.useAgent(False) link.useAgent(False)
link.System.Service[service].setState(state) 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(_("Unable to set %s state:") % service)
print(" %s" % e.args[0]) print(" %s" % e.args[0])
return return
...@@ -197,7 +197,7 @@ def reloadService(service, quiet=False): ...@@ -197,7 +197,7 @@ def reloadService(service, quiet=False):
link.setLocale() link.setLocale()
link.useAgent(False) link.useAgent(False)
link.System.Service[service].reload() link.System.Service[service].reload()
except dbus.DBusException as e: except dbus.exceptions.DBusException as e:
print(_("Unable to reload %s:") % service) print(_("Unable to reload %s:") % service)
print(" %s" % e.args[0]) print(" %s" % e.args[0])
return return
...@@ -288,7 +288,7 @@ def manage_dbus(op, use_color, quiet): ...@@ -288,7 +288,7 @@ def manage_dbus(op, use_color, quiet):
elif op in ["info", "status", "list"]: elif op in ["info", "status", "list"]:
try: try:
dbus.SystemBus() dbus.SystemBus()
except dbus.DBusException: except dbus.exceptions.DBusException:
print(_("DBus is not running.")) print(_("DBus is not running."))
return return
print(_("DBus is running.")) print(_("DBus is running."))
...@@ -350,7 +350,7 @@ def main(args): ...@@ -350,7 +350,7 @@ def main(args):
elif args[1] in operations: elif args[1] in operations:
try: try:
manage_service(args[0].replace("-", "_"), args[1], use_color, quiet) 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): if "Unable to find" in str(e):
print(_("No such service: %s") % args[0]) print(_("No such service: %s") % args[0])
else: else:
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -110,7 +110,7 @@ def saveXorgConfig(card): ...@@ -110,7 +110,7 @@ def saveXorgConfig(card):
try: try:
secDevice.options = link.Xorg.Driver[pkg].getDeviceOptions( secDevice.options = link.Xorg.Driver[pkg].getDeviceOptions(
card.bus_id, opts) card.bus_id, opts)
except dbus.DBusException: except dbus.exceptions.DBusException:
pass pass
# Backup and save xorg.conf # Backup and save xorg.conf
......
...@@ -92,7 +92,7 @@ class VideoDevice: ...@@ -92,7 +92,7 @@ class VideoDevice:
for package in packages: for package in packages:
try: try:
info = link.Xorg.Driver[package].getInfo() info = link.Xorg.Driver[package].getInfo()
except dbus.DBusException: except dbus.exceptions.DBusException:
continue continue
alias = str(info["alias"]) alias = str(info["alias"])
if alias == driver: if alias == driver:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment