def __init__(self): super(Wrapper, self).__init__() return # DDR 2018-06-22: The following function never returns, so everything is broken. QDBusConnection.systemBus().connect( 'com.krontech.chronos.control.mock', '/', '', key, self.updateKey)
def __init__(self, *, taskModel, frontendSettings, parent): super().__init__(parent) self.__taskModel = taskModel self.__frontendSettings = frontendSettings self._conn = QDBusConnection("Xware Desktop").sessionBus() self._interface = QDBusInterface(_DBUS_NOTIFY_SERVICE, _DBUS_NOTIFY_PATH, _DBUS_NOTIFY_INTERFACE, self._conn) self._notified = {} # a dict of notifyId: taskDict self.__taskModel.taskCompleted.connect(self.notifyTaskCompleted, Qt.DirectConnection) self._capabilities = self._getCapabilities() if "actions" in self._capabilities: successful = self._conn.connect(_DBUS_NOTIFY_SERVICE, _DBUS_NOTIFY_PATH, _DBUS_NOTIFY_INTERFACE, "ActionInvoked", self.slotActionInvoked) if not successful: logging.error("ActionInvoked connect failed.") self._qSound_complete = QSound(":/sound/download-complete.wav", self)
def __init__(self): super(ChatMainWindow, self).__init__() self.m_nickname = "nickname" self.m_messages = [] self.symptomRaw = [] self.symptomClean = [] self.inputTest = [] self.setupUi(self) self.sendButton.setEnabled(False) self.messageLineEdit.textChanged.connect(self.textChangedSlot) self.messageLineEdit = autocomplete.auto(self.messageLineEdit) self.sendButton.clicked.connect(self.sendClickedSlot) self.unSendButton.clicked.connect(self.unsendMessage) self.clearButton.clicked.connect(self.clearMessage) QApplication.instance().lastWindowClosed.connect(self.exiting) self.predictButton.clicked.connect(self.retrieveChat) # Add our D-Bus interface and connect to D-Bus. ChatAdaptor(self) QDBusConnection.sessionBus().registerObject('/', self) iface = ChatInterface('', '', QDBusConnection.sessionBus(), self) QDBusConnection.sessionBus().connect('', '', 'org.example.chat', 'message', self.messageSlot) iface.action.connect(self.actionSlot) dialog = NicknameDialog() dialog.cancelButton.setVisible(False) dialog.exec_() self.m_nickname = dialog.nickname.text().strip() self.action.emit(self.m_nickname, "joins the chat")
def main(): import sys app = QCoreApplication(sys.argv) # noqa: F841 if not 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 = QDBusInterface(SERVICE_NAME, "/", "", QDBusConnection.sessionBus()) if iface.isValid(): msg = iface.call("ping", sys.argv[1] if len(sys.argv) > 1 else "") reply = 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" % QDBusConnection.sessionBus().lastError().message()) sys.exit(1)
def test3(): self._state["recordingExposureNs"] = int(8.5e8) signal = QDBusMessage.createSignal( '/', 'com.krontech.chronos.control.mock', 'recordingExposureNs') signal << self._state["recordingExposureNs"] QDBusConnection.systemBus().send(signal)
def __init__(self): super(ChatMainWindow, self).__init__() self.m_nickname = "nickname" self.m_messages = [] self.setupUi(self) self.sendButton.setEnabled(False) self.messageLineEdit.textChanged.connect(self.textChangedSlot) self.sendButton.clicked.connect(self.sendClickedSlot) self.actionChangeNickname.triggered.connect(self.changeNickname) self.actionAboutQt.triggered.connect(self.aboutQt) QApplication.instance().lastWindowClosed.connect(self.exiting) # Add our D-Bus interface and connect to D-Bus. ChatAdaptor(self) QDBusConnection.sessionBus().registerObject('/', self) iface = ChatInterface('', '', QDBusConnection.sessionBus(), self) QDBusConnection.sessionBus().connect('', '', 'org.example.chat', 'message', self.messageSlot) iface.action.connect(self.actionSlot) dialog = NicknameDialog() dialog.cancelButton.setVisible(False) dialog.exec_() self.m_nickname = dialog.nickname.text().strip() self.action.emit(self.m_nickname, "joins the chat")
def observe(name: str, callback: Callable[[Any], None]) -> None: """Observe changes in a state value. Args: name: ID of the state variable. "exposure", "focusPeakingColor", etc. callback: Function called when the state updates and upon subscription. Called with one parameter, the new value. Called when registered and when the value updates. Note: Some frequently updated values (> 10/sec) are only available via polling due to flooding concerns. They can not be observed, as they're assumed to *always* be changed. See the API docs for more details. Rationale: It is convenient and less error-prone if we only have one callback that handles the initialization and update of values. The API provides separate initialization and update methods, so we'll store the initialization and use it to perform the initial call to the observe() callback. In addition, this means we only have to query the initial state once, retrieving a blob of all the data available, rather than retrieving each key one syscall at a time as we instantiate each Qt control. """ callback(_camState[name]) QDBusConnection.systemBus().connect('com.krontech.chronos.control.mock', '/', '', name, callback)
def __init__(self, parent=None): QObject.__init__(self) self.interface = Interface('com.deepin.daemon.SystemInfo', '/com/deepin/daemon/SystemInfo', QDBusConnection.sessionBus(), self) QDBusConnection.sessionBus().connect('com.deepin.daemon.SystemInfo', '/com/deepin/daemon/SystemInfo', 'org.freedesktop.DBus.Properties', 'PropertiesChanged', self.messageSlot)
def __init__(self): """ NetworkInterfaces is a list of the plugged-in network connections. ```python [{ "path": b"/org/freedesktop/NetworkManager/Devices/1" "name": "Ethernet", "address": "192.168.100.166" or "2001:0db8:85a3::8a2e:0370:7334" }, { ... }] ``` You can `networkInterfaces.observe(callback)` to get updates. """ super().__init__() self._connections = [] #observers collection self._callbacks = [] self.networkManager = QDBusInterface( f"org.freedesktop.NetworkManager", #Service f"/org/freedesktop/NetworkManager", #Path f"org.freedesktop.NetworkManager", #Interface QDBusConnection.systemBus(), ) self.networkManager.setTimeout(10) #Set to 1000 after startup period. #Retry. This doesn't connect the first time, no matter what the time limit is. I don't know why, probably something in the start-on-demand logic. if not self.networkManager.isValid(): self.networkManager = QDBusInterface( f"org.freedesktop.NetworkManager", #Service f"/org/freedesktop/NetworkManager", #Path f"org.freedesktop.NetworkManager", #Interface QDBusConnection.systemBus(), ) self.networkManager.setTimeout(10) if not self.networkManager.isValid(): log.critical(f"Error: Can not connect to NetworkManager at {self.networkManager.service()}. ({self.networkManager.lastError().name()}: {self.networkManager.lastError().message()}) Try running `apt install network-manager`?") raise Exception("D-Bus Setup Error") self.networkManager.setTimeout(1000) #The .connect call freezes if we don't do this, or if we do this twice. #This bug was fixed by Qt 5.11. QDBusConnection.systemBus().registerObject( f"/org/freedesktop/NetworkManager", self, ) self._acquireInterfacesCall = QDBusPendingCallWatcher( self.networkManager.asyncCall('GetDevices') ) self._acquireInterfacesCall.finished.connect(self._acquireInterfaceData)
def call_cura(method, *args): dbus_service = "nl.ultimaker.cura" dbus_object = "/Application" dbus_interface = "nl.ultimaker.cura.Application" message = QDBusMessage.createMethodCall(dbus_service, dbus_object, dbus_interface, method) message.setArguments(args) QDBusConnection.sessionBus().call(message)
def __init__(self, dbus_name, object_name): QObject.__init__(self) iface = QDBusInterface(dbus_name, object_name, '', QDBusConnection.sessionBus()) if iface.isValid(): iface.call("unique") sys.exit(1) QDBusConnection.sessionBus().registerService(dbus_name) QDBusConnection.sessionBus().registerObject(object_name, self, QDBusConnection.ExportAllSlots)
def __init__(self): super(ControlCenterInterface, self).__init__("com.deepin.dde.ControlCenter", "/com/deepin/dde/ControlCenter", "com.deepin.dde.ControlCenter", QDBusConnection.sessionBus(), None) sessionBus = QDBusConnection.sessionBus() self._control_center_exists = not sessionBus.registerService( self.service()) sessionBus.unregisterService(self.service())
def __init__(self): super(ControlCenterInterface, self).__init__( "com.deepin.dde.ControlCenter", "/com/deepin/dde/ControlCenter", "com.deepin.dde.ControlCenter", QDBusConnection.sessionBus(), None) sessionBus = QDBusConnection.sessionBus() self._control_center_exists = not sessionBus.registerService( self.service()) sessionBus.unregisterService(self.service())
def PropertiesChanged(self, interface, prop, values): """Sends PropertiesChanged signal through sessionBus. Args: interface: interface name prop: property name values: current property value(s) """ emptyStringListArg = QDBusArgument() emptyStringListArg.add([""], QMetaType.QStringList) self.signal.setArguments([interface, {prop: values}, emptyStringListArg]) QDBusConnection.sessionBus().send(self.signal)
def uninhibitScreenlock(self): if not 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") return iface = QDBusInterface('org.kde.screensaver', '/ScreenSaver', '', QDBusConnection.sessionBus()) if iface.isValid(): iface.call('UnInhibit', self.screenLockCookie)
def inhibitScreenlock(self): if not 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"); return iface = QDBusInterface('org.kde.screensaver', '/ScreenSaver', '', QDBusConnection.sessionBus()) if iface.isValid(): msg = iface.call('Inhibit', 'DisUpgradeViewKDE', 'Upgrading base OS') reply = QDBusReply(msg) self.screenLockCookie = reply.value()
def __init__(self): super(ScreenSaverInterface, self).__init__("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", QDBusConnection.sessionBus(), None) self._inhibit_cookie = None
def __init__(self): super(DisplayPropertyInterface, self).__init__( "com.deepin.daemon.Display", "/com/deepin/daemon/Display", "org.freedesktop.DBus.Properties", QDBusConnection.sessionBus(), None)
def __init__(self): super(NotificationsInterface, self).__init__( NOTIFICATIONS_SERVICE, NOTIFICATIONS_PATH, NOTIFICATIONS_INTERFACE, QDBusConnection.sessionBus(), None)
def method3(): sys.stdout.write("Method 3:\n") names = QDBusConnection.sessionBus().interface().registeredServiceNames().value() # Mimic the output from the C++ version. sys.stdout.write('("%s")\n' % '", "'.join(names))
def __init__(self): super(ScreenSaverInterface, self).__init__(SCREEN_SAVER_SERVICE, SCREEN_SAVER_PATH, SCREEN_SAVER_INTERFACE, QDBusConnection.sessionBus(), None) self._inhibit_cookie = None
def install_packages(pkg_names): iface = QDBusInterface("com.linuxdeepin.softwarecenter_frontend", "/com/linuxdeepin/softwarecenter_frontend", '', QDBusConnection.sessionBus()) iface.asyncCall("install_pkgs", pkg_names) iface.asyncCall("show_page", "install") iface.asyncCall("raise_to_top")
def packagekit_install(pack='ffmpeg'): """ Equivalent of: qdbus org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit.Modify.InstallPackageNames 0 ffmpeg "show-confirm-search,hide-finished" Or: qdbus org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit.Query.IsInstalled 0 ffmpeg See also (dbus) http://www.freedesktop.org/software/PackageKit/pk-faq.html#session-methods Doc: http://blog.fpmurphy.com/2013/11/packagekit-d-bus-abstraction-layer.html """ from PyQt5.QtDBus import QDBusConnection from PyQt5.QtDBus import QDBusInterface bus = QDBusConnection.sessionBus() service_name = 'org.freedesktop.PackageKit' service_path = '/org/freedesktop/PackageKit' interface = 'org.freedesktop.PackageKit.Query.IsInstalled' install = QDBusInterface(service_name, service_path, interface, bus) reply = install.call(0, pack, 'show-confirm-search,hide-finished') print(reply.arguments()) interface = 'org.freedesktop.PackageKit.Modify.InstallPackageNames' install = QDBusInterface(service_name, service_path, interface, bus) reply = install.call(0, pack, 'show-confirm-search,hide-finished') print(reply.arguments())
def __init__(self, dbus_name, object_name): QObject.__init__(self) search_option = len(sys.argv) >= 2 and sys.argv[1] == "--search" iface = QDBusInterface(dbus_name, object_name, '', QDBusConnection.sessionBus()) if iface.isValid(): iface.call("unique") if search_option: iface.call("search") sys.exit(1) QDBusConnection.sessionBus().registerService(dbus_name) QDBusConnection.sessionBus().registerObject(object_name, self, QDBusConnection.ExportAllSlots)
def _dbus_notify(title, message, duration=5000): from PyQt5.QtDBus import ( QDBus, QDBusArgument, QDBusConnection, QDBusInterface) bus = QDBusConnection.sessionBus() if not bus.isConnected(): raise OSError("Could not connect to DBus") interface = QDBusInterface( 'org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications', bus) error = interface.lastError() if error.type(): raise RuntimeError("{}; {}".format(error.name(), error.message())) # See https://developer.gnome.org/notification-spec/ # "This allows clients to effectively modify the notification while # it's active. A value of value of 0 means that this notification # won't replace any existing notifications." replaces_id = QVariant(0) replaces_id.convert(QVariant.UInt) interface.call( QDBus.NoBlock, 'Notify', APP_NAME, replaces_id, resource(settings['application']['tray_icon']), title, message, QDBusArgument([], QMetaType.QStringList), {}, duration)
def __init__(self, parent=None): super().__init__(parent=parent) # Use environment variable to optionally assign a unique session ID to a Cura instance so they won't interfere # with each other on the same channel. self._extra_session_id = os.environ.get("CURA_DEBUG_DBUS_SESSION_ID", "").strip() if self._extra_session_id: self._extra_session_id = "." + self._extra_session_id self._service_id = self.DEFAULT_SESSION_ID + self._extra_session_id self._session_bus = QDBusConnection.sessionBus() if not self._session_bus.isConnected(): Logger.log("e", "Could not connect to D-Bus") return Logger.log("i", "Registering D-Bus service [%s] ...", self._service_id) if not self._session_bus.registerService(self._service_id): Logger.log("e", "Could not register D-Bus service [%s]", self._service_id) return self._application_adaptor = _ApplicationAdaptor(self) self._session_bus.registerObject("/Application", self._application_adaptor, QDBusConnection.ExportAllContents) self._backend_adaptor = _BackendAdaptor(self) self._session_bus.registerObject("/Backend", self._backend_adaptor, QDBusConnection.ExportAllContents)
def __init__(self): super(SoundEffectInteface, self).__init__( "com.deepin.daemon.SoundEffect", "/com/deepin/daemon/SoundEffect", "com.deepin.daemon.SoundEffect", QDBusConnection.sessionBus(), None)
def __init__(self): super(FileManagerInterface, self).__init__( "org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", QDBusConnection.sessionBus(), None)
def __init__(self): super(SocialSharingInterface, self).__init__( "com.deepin.SocialSharing", "/com/deepin/SocialSharing", "com.deepin.SocialSharing", QDBusConnection.sessionBus(), None)
def __init__(self, qobject): ''' Starts the d-bus service to watch for any stray notifications ''' super().__init__(qobject) sb = QDBusConnection.sessionBus() print("Notifs_Dbus: Registering notif. service…") try: sb.registerService("org.freedesktop.Notifications") except: print("Couldn't register freedesktop notifications service!") print("Notifs_Dbus: Registering notif. object…") try: sb.registerObject("/org/freedesktop/Notifications", qobject) except: print("Couldn't register freedesktop notifications object!") # match string m = "eavesdrop='true', interface='org.freedesktop.Notifications', member='Notify', type='method_call'" i = QDBusInterface("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus") i.call("AddMatch", m) print("Notifs_Dbus: Listener should start by now.")
def __init__(self): super(NotificationsInterface, self).__init__( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection.sessionBus(), None)
def __init__(self): super(ScreenshotInterface, self).__init__( "com.deepin.DeepinScreenshot", "/com/deepin/DeepinScreenshot", "com.deepin.DeepinScreenshot", QDBusConnection.sessionBus(), None)
def unmount_usb_device(block_device: str): """ Attempts to unmount a USB device via org.freedesktop.UDisks2.Filesystem D-Bus interface as described at http://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Filesystem.html#gdbus-method-org-freedesktop-UDisks2-Filesystem.Unmount. :param block_device: a partition name to unmount, for example /dev/sdb1 """ if block_device is None: raise TypeError("'block_device' cannot be of type 'NoneType'") elif block_device == '': raise ValueError("'block_device' cannot be empty") path = block_device.replace('/dev', '/org/freedesktop/UDisks2/block_devices') file_system_interface = QDBusInterface( 'org.freedesktop.UDisks2', path, 'org.freedesktop.UDisks2.Filesystem', QDBusConnection.systemBus()) if not file_system_interface.isValid(): raise RuntimeError(_translate('DriveUtils', 'Invalid D-Bus interface')) reply = file_system_interface.call('Unmount', {}) if reply.type() == QDBusMessage.ErrorMessage: raise RuntimeError(reply.errorMessage()) elif reply.type() != QDBusMessage.ReplyMessage: raise RuntimeError( _translate('DriveUtils', 'Unexpected reply from Udisks'))
def start(): app = QCoreApplication([]) bus = QDBusConnection.sessionBus() server = MyServer() bus.registerObject('/mydbus', server) bus.registerService('com.home.dbus') app.exec()
def __init__(self): super(HotZoneInterface, self).__init__( "com.deepin.daemon.Zone", "/com/deepin/daemon/Zone", 'com.deepin.daemon.Zone', QDBusConnection.sessionBus(), None)
def packagekit_install(pack="ffmpeg"): """ Equivalent of: qdbus org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit.Modify.InstallPackageNames 0 ffmpeg "show-confirm-search,hide-finished" Or: qdbus org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit.Query.IsInstalled 0 ffmpeg See also (dbus) http://www.freedesktop.org/software/PackageKit/pk-faq.html#session-methods Doc: http://blog.fpmurphy.com/2013/11/packagekit-d-bus-abstraction-layer.html """ from PyQt5.QtDBus import QDBusConnection from PyQt5.QtDBus import QDBusInterface bus = QDBusConnection.sessionBus() service_name = "org.freedesktop.PackageKit" service_path = "/org/freedesktop/PackageKit" interface = "org.freedesktop.PackageKit.Query.IsInstalled" install = QDBusInterface(service_name, service_path, interface, bus) reply = install.call(0, pack, "show-confirm-search,hide-finished") print(reply.arguments()) interface = "org.freedesktop.PackageKit.Modify.InstallPackageNames" install = QDBusInterface(service_name, service_path, interface, bus) reply = install.call(0, pack, "show-confirm-search,hide-finished") print(reply.arguments())
def createUI(self): self.home = os.getenv("HOME") # vlc player init self.instance = vlc.Instance('-q') # self.instance = vlc.Instance('-q --network-caching=1000') self.mediaplayer = self.instance.media_player_new() # self.mediaplayer.set_xwindow(self.winId()) # Main window settings self.gridLayout = QGridLayout(self) self.gridLayout.setObjectName("gridLayout") self.videoFrame = QFrame(self) self.videoFrame.setObjectName("videoFrame") self.gridLayout.addWidget(self.videoFrame, 0, 0, 1, 1) self.mediaplayer.set_xwindow(self.winId()) # self.mediaplayer.set_xwindow(self.videoFrame.winId()) self.setWindowIcon( QIcon(scriptDir + os.path.sep + 'pics' + os.path.sep + 'logo.png')) self.resize(cfg.value('Width', 456, type=int), cfg.value('Height', 256, type=int)) self.setGeometry( cfg.value('Left', 456, type=int) + WINDOW_DECORATION_WIDTH_BORDER, cfg.value('Top', 256, type=int) + WINDOW_DECORATION_HEIGHT_TITLE, cfg.value('Width', 456, type=int), cfg.value('Height', 256, type=int)) pal = self.palette() pal.setColor(self.backgroundRole(), Qt.blue) self.setPalette(pal) # self.setAutoFillBackground(True) self.currentCursor = self.cursor() # Save status audio mute self.AudioMuteOnStart = self.mediaplayer.audio_get_mute() self.AudioVolumeOnStart = self.mediaplayer.audio_get_volume() self.Volume = cfg.value('Volume', 80, type=int) # Registered DBUS service DBUSName = 'tv.ok' DBUSConn = QDBusConnection.connectToBus(QDBusConnection.SessionBus, DBUSName) DBUSConn.registerService(DBUSName) DBUSConn.registerObject("/", self, QDBusConnection.ExportAllContents) # Timer 1 second init. Once second call function t1secEvent self.t1sec = QTimer(self) self.t1sec.timeout.connect(self.t1secEvent) self.t1sec.start(1000) # Select channel saved previous run self.chNum = cfg.value('Channel', 1, type=int) self.chPrev = self.chNum + 1 self.chChange() self.trayIcon = QSystemTrayIcon() self.trayIcon.setToolTip('TVOK Python') self.trayIcon.activated.connect(self.ToggleMute) self.swapIcon() self.selectChannel = '' self.tChSelect = QTimer(self) self.tChSelect.timeout.connect(self.tChSelectTimeout)
def __init__(self, parent=None): super(TaskbarProgress, self).__init__(parent) self.parent = parent if sys.platform.startswith('linux'): self._sessionbus = QDBusConnection.sessionBus() if self._sessionbus.isConnected(): self._desktopfile = 'application://{}.desktop'.format(vidcutter.__desktopid__) self.init()
def __init__(self, playbackController, current_episode_data, ep_play): super(mprisIntegration, self).__init__() mprisMain(self, playbackController) mprisPlayer(self, playbackController, current_episode_data, ep_play) self.connection = QDBusConnection.sessionBus() self.connection.registerObject("/org/mpris/MediaPlayer2", self) self.serviceName = "org.mpris.MediaPlayer2.kodkast" self.connection.registerService(self.serviceName)
def __init__(self, parent): super(AppService, self).__init__(parent) self.connection = QDBusConnection.sessionBus() path = '/AppService' service = 'org.autokey.Service' self.connection.registerObject(path, parent) self.connection.registerService(service) self.setAutoRelaySignals(True)
def main(): signal.signal(signal.SIGINT, signal.SIG_DFL) app = QCoreApplication([]) bus = QDBusConnection.systemBus() udisk_manager = UDiskManager(bus) udisk_manager.print_info() app.exec()
def createServer(): global BUS, ROOT_OBJ ROOT_OBJ = SimpleHandler() BUS = QDBusConnection.sessionBus() BUS.registerService('re.indigo.eye') BUS.registerObject('/', ROOT_OBJ, QDBusConnection.ExportAllContents)
def __init__(self): QtCore.QObject.__init__(self) self.session_bus = QDBusConnection.sessionBus() self.session_bus.connect(self.DBUS_NAME, self.DBUS_PATH, self.DBUS_IFACE, 'MenuItemClicked', self.MenuItemClickedSlot) self.session_bus.connect(self.DBUS_NAME, self.DBUS_PATH, self.DBUS_IFACE, 'CheckMenuItemClicked', self.CheckMenuItemClickedSlot) self._iface = QDBusInterface(self.DBUS_NAME, self.DBUS_PATH, self.DBUS_IFACE, self.session_bus)
def __init__(self): super(ScreenSaverInterface, self).__init__( SCREEN_SAVER_SERVICE, SCREEN_SAVER_PATH, SCREEN_SAVER_INTERFACE, QDBusConnection.sessionBus(), None) self._inhibit_cookie = None
def method2(): sys.stdout.write("Method 2:\n") bus = QDBusConnection.sessionBus() dbus_iface = 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))
def __init__(self) -> None: # Allow Ctrl-C killing of the Qt app, see: # http://stackoverflow.com/questions/4938723/ signal.signal(signal.SIGINT, signal.SIG_DFL) self.cache_dir = os.path.join(xdg.BaseDirectory.xdg_cache_home, "dt-fileview") self.config_dir = os.path.join(xdg.BaseDirectory.xdg_config_home, "dt-fileview") self.config_file = os.path.join(self.config_dir, "config.ini") if not os.path.isdir(self.config_dir): os.makedirs(self.config_dir) self.stream_dir = os.path.join(self.cache_dir, "streams") if not os.path.isdir(self.stream_dir): os.makedirs(self.stream_dir) logging_config = os.path.join(self.config_dir, "logging.ini") if os.path.exists(logging_config): print("loading logger config from: {}".format(logging_config)) try: logging.config.fileConfig(logging_config, defaults=None, disable_existing_loggers=False) except Exception as err: print(traceback.format_exc()) settings.init(self.config_file) self.file_history = SqlHistory(os.path.join(self.config_dir, "file.sqlite")) self.location_history = SqlHistory(os.path.join(self.config_dir, "locations.sqlite")) self.bookmarks = Bookmarks(os.path.join(self.config_dir, "bookmarks.txt")) QPixmapCache.setCacheLimit(102400) self.qapp = QApplication([]) self.qapp.setQuitOnLastWindowClosed(False) self.qapp.lastWindowClosed.connect(self.on_last_window_closed) self.stream_manager = StreamManager(self.stream_dir) self.vfs = VirtualFilesystem(self.cache_dir, self) self.executor = Executor(self) self.thumbnailer = Thumbnailer(self.vfs) self.metadata_collector = MetaDataCollector(self.vfs.get_stdio_fs()) self.session_bus = QDBusConnection.sessionBus() self.dbus_thumbnail_cache = DBusThumbnailCache(self.session_bus) self.mime_database = MimeDatabase(self.vfs) self.mime_associations = XdgMimeAssociations.system() self.fs_operations = FilesystemOperations(self) self.fs = Filesystem() self.directory_thumbnailer = DirectoryThumbnailer(self) self.directory_thumbnailer.start() self.controllers: List[Controller] = [] self.actions = ApplicationActions(self) self._preferences_dialog = PreferencesDialog()
def __init__(self, parent=None): super(Controller, self).__init__(parent) self.ui = Ui_Controller() self.ui.setupUi(self) self.car = CarInterface('org.example.CarExample', '/Car', QDBusConnection.sessionBus(), self) self.startTimer(1000)
def method1(): sys.stdout.write("Method 1:\n") reply = QDBusConnection.sessionBus().interface().registeredServiceNames() if not reply.isValid(): sys.stdout.write("Error: %s\n" % reply.error().message()) sys.exit(1) # Mimic the output from the C++ version. for name in reply.value(): sys.stdout.write('"%s"\n' % name)
def __init__(self, parent = None): super().__init__(parent) self.sessionBus = QDBusConnection.sessionBus() self._dbusInterface = QDBusInterface("org.freedesktop.DBus", "/", "org.freedesktop.DBus") if self.serviceExists(self.serviceName): raise RuntimeError("There's a DBus that has the same name.") created = self.sessionBus.registerService(self.serviceName) if not created: raise RuntimeError("Cannot create DBus Service.") self.registerObject("/", self)
def main(argv): args = parse_args(argv[1:]) signal.signal(signal.SIGINT, signal.SIG_DFL) app = QCoreApplication([]) session_bus = QDBusConnection.sessionBus() thumbnailer = DBusThumbnailer(session_bus, ThumbnailerProgressListener( app, verbose=args.verbose)) thumbnail_cache = DBusThumbnailCache(session_bus) rc = 0 if args.list_flavors: for flavor in thumbnailer.get_flavors(): print(flavor) elif args.list_uri_types: uri_types, mime_types = thumbnailer.get_supported() for uri_type in sorted(set(uri_types)): print(uri_type) elif args.list_mime_types: uri_types, mime_types = thumbnailer.get_supported() for mime_type in sorted(set(mime_types)): print(mime_type) elif args.list_schedulers: for scheduler in thumbnailer.get_schedulers(): print(scheduler) elif args.delete: thumbnail_cache.delete(args.FILE) app.quit() elif args.cleanup: thumbnail_cache.cleanup(args.FILE) app.quit() elif args.FILE != []: if args.flavor == 'all': for flavor in thumbnailer.get_flavors(): request_thumbnails(thumbnailer, args.FILE, flavor, args.recursive) else: request_thumbnails(thumbnailer, args.FILE, args.flavor, args.recursive) rc = app.exec() else: pass return rc
def sendRequest(req, *args): global BUS LOGGER.debug('sending request %r%r', req, args) method_args = [req] method_args.extend(args) msg = QDBusMessage.createMethodCall('re.indigo.eye', '/', 're.indigo.eye', 'request') msg.setArguments(method_args) BUS = QDBusConnection.sessionBus() reply = BUS.call(msg) if reply.type() == QDBusMessage.ErrorMessage: raise ValueError(reply.errorMessage()) return list(reply.arguments())
def __init__(self, application): self.application = application service_name = 'org.mpris.MediaPlayer2.clementine' service_path = '/Player' interface_name = 'org.freedesktop.MediaPlayer' signal_name = 'TrackChange' self.session_bus_connection = QDBusConnection.sessionBus() self.player = QDBusInterface( service_name, service_path, interface_name, self.session_bus_connection) self._on_message(self.player.call('GetMetadata')) self.dbus_message_handler = DBusMsgHandler(self._on_message) self.session_bus_connection.connect( None, None, interface_name, signal_name, self.dbus_message_handler.handle)