Exemple #1
0
 def clientshow_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "DBUS error:" + str(reply.error().message()))
     else:
         ts = (reply.argumentAt(0).toPyObject()[0].toULongLong()[0],
               reply.argumentAt(0).toPyObject()[1].toULongLong()[0])
         interval_nsecs = ts[0] * 1000000000L + ts[1]
         clients = []
         for client in reply.argumentAt(1).toPyObject():
             cl = client.toPyObject()
             lasttime = cl[8].toPyObject()
             clt = Client(ClientIP=str(cl[0].toString()),
                          HasNFSv3=cl[1].toBool(),
                          HasMNT=cl[2].toBool(),
                          HasNLM4=cl[3].toBool(),
                          HasRQUOTA=cl[4].toBool(),
                          HasNFSv40=cl[5].toBool(),
                          HasNFSv41=cl[6].toBool(),
                          Has9P=cl[7].toBool(),
                          LastTime=(lasttime[0].toPyObject(),
                                    lasttime[1].toPyObject()))
             clients.append(clt)
         self.show_clients.emit(ts, clients)
 def exportrm_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "Error:" + str(reply.error().message()))
     else:
         self.show_status.emit(True, "Done")
Exemple #3
0
 def exportshow_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "DBUS error:" + str(reply.error().message()))
     else:
         ts = (reply.argumentAt(0).toPyObject()[0].toULongLong()[0],
               reply.argumentAt(0).toPyObject()[1].toULongLong()[0])
         exports = []
         for export in reply.argumentAt(1).toPyObject():
             ex = export.toPyObject()
             lasttime = ex[9].toPyObject()
             exp = Export(ExportID=ex[0].toInt()[0],
                          ExportPath=str(ex[1].toString()),
                          HasNFSv3=ex[2].toBool(),
                          HasMNT=ex[3].toBool(),
                          HasNLM4=ex[4].toBool(),
                          HasRQUOTA=ex[5].toBool(),
                          HasNFSv40=ex[6].toBool(),
                          HasNFSv41=ex[7].toBool(),
                          Has9P=ex[8].toBool(),
                          LastTime=(lasttime[0].toPyObject(),
                                    lasttime[1].toPyObject()))
             exports.append(exp)
         self.show_exports.emit(ts, exports)
 def exportadd_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "Error:" + str(reply.error().message()))
     else:
         message = reply.argumentAt(0).toPyObject()
         self.show_status.emit(True, "Done: " + message)
Exemple #5
0
 def Set(self, property, setval):
     qval = QtDBus.QDBusVariant()
     qval.setVariant(str(str(setval)))
     async = self.asyncCall("Set", LOGGER_PROPS,
                            property,
                            qval)
     status = QtDBus.QDBusPendingCallWatcher(async, self)
     status.finished.connect(self.Set_done)
Exemple #6
0
 def Get_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "DBUS error:" + str(reply.error().message()))
     else:
         level = str(reply.value().toPyObject().toString())
         self.show_level.emit(level)
Exemple #7
0
 def admin_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "DBUS error:" + str(reply.error().message()))
     else:
         status = reply.argumentAt(0).toPyObject()
         msg = reply.argumentAt(1).toPyObject()
         self.show_status.emit(status, msg)
 def exportdisplay_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "Error:" + str(reply.error().message()))
     else:
         id = reply.argumentAt(0).toPyObject()
         fullpath = reply.argumentAt(1).toPyObject()
         pseudopath = reply.argumentAt(2).toPyObject()
         tag = reply.argumentAt(3).toPyObject()
         self.display_export.emit(id, fullpath, pseudopath, tag)
Exemple #9
0
def method2():
    sys.stdout.write("Method 2:\n")

    bus = QtDBus.QDBusConnection.sessionBus()
    dbus_iface = QtDBus.QDBusInterface('org.freedesktop.DBus',
                                       '/org/freedesktop/DBus',
                                       'org.freedesktop.DBus', bus)
    names = dbus_iface.call('ListNames').arguments()[0]

    # Mimic the output from the C++ version.
    sys.stdout.write('QVariant(QStringList, ("%s") )\n' % '", "'.join(names))
Exemple #10
0
 def GetAll_done(self, call):
     reply = QtDBus.QDBusPendingReply(call)
     if reply.isError():
         self.show_status.emit(False,
                               "DBus error:" + str(reply.error().message()))
     else:
         # what follows is DBus+Qt magic.  We get a Variant object back
         # which contains a "map", aka "dict" in python.  Each item in
         # the map has a variant as a key and a variant as the value
         # first unwrap the top variant into d...
         # then walk d, unwrap the variant key to store the unwrapped
         # variant value into a string value.
         prop_dict = {}
         d = reply.value().toPyObject()
         for key in d.keys():
             prop_dict[str(key.toString())] = str(d[key].toPyObject().toString())
         self.show_components.emit(prop_dict)
Exemple #11
0
 def Get(self, property):
     _async = self.asyncCall("Get", LOGGER_PROPS, property)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.Get_done)
Exemple #12
0
 def GetAll(self):
     _async = self.asyncCall("GetAll", LOGGER_PROPS)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.GetAll_done)
 def GetNFSv41Layouts(self, ipaddr):
     _async = self.asyncCall("GetNFSv41Layouts", ipaddr)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.layout_done)
 def RemoveClient(self, ipaddr):
     _async = self.asyncCall("RemoveClient", ipaddr)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.clientmgr_done)
sip.setapi('QVariant', 2)

import sys
from PyQt4 import QtCore, QtDBus


if __name__ == '__main__':
    app = QtCore.QCoreApplication(sys.argv)

    if not QtDBus.QDBusConnection.sessionBus().isConnected():
        sys.stderr.write("Cannot connect to the D-Bus session bus.\n"
                "To start it, run:\n"
                "\teval `dbus-launch --auto-syntax`\n");
        sys.exit(1)

    iface = QtDBus.QDBusInterface('com.trolltech.QtDBus.PingExample', '/', '',
            QtDBus.QDBusConnection.sessionBus())

    if iface.isValid():
        msg = iface.call('ping', sys.argv[1] if len(sys.argv) > 1 else "")
        reply = QtDBus.QDBusReply(msg)

        if reply.isValid():
            sys.stdout.write("Reply was: %s\n" % reply.value())
            sys.exit()

        sys.stderr.write("Call failed: %s\n" % reply.error().message())
        sys.exit(1)

    sys.stderr.write("%s\n" % QtDBus.QDBusConnection.sessionBus().lastError().message())
    sys.exit(1)
Exemple #16
0
 def shutdown(self):
     _async = self.asyncCall("shutdown")
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.admin_done)
Exemple #17
0
 def reload(self):
     _async = self.asyncCall("reload")
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.admin_done)
Exemple #18
0
 def grace(self, ipaddr):
     _async = self.asyncCall("grace", ipaddr)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.admin_done)
 def GetNFSv40IO(self, ipaddr):
     _async = self.asyncCall("GetNFSv40IO", ipaddr)
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.io_done)
 def ShowClients(self):
     _async = self.asyncCall("ShowClients")
     status = QtDBus.QDBusPendingCallWatcher(_async, self)
     status.finished.connect(self.clientshow_done)