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 __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 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 __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 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 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 __init__(self): super(ScreenSaverInterface, self).__init__("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", 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): super(HotZoneInterface, self).__init__( "com.deepin.daemon.Zone", "/com/deepin/daemon/Zone", 'com.deepin.daemon.Zone', QDBusConnection.sessionBus(), None)
def start(): app = QCoreApplication([]) bus = QDBusConnection.sessionBus() server = MyServer() bus.registerObject('/mydbus', server) bus.registerService('com.home.dbus') app.exec()
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 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): super(DisplayPropertyInterface, self).__init__( "com.deepin.daemon.Display", "/com/deepin/daemon/Display", "org.freedesktop.DBus.Properties", QDBusConnection.sessionBus(), None)
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(ScreenshotInterface, self).__init__( "com.deepin.DeepinScreenshot", "/com/deepin/DeepinScreenshot", "com.deepin.DeepinScreenshot", QDBusConnection.sessionBus(), None)
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): 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__( NOTIFICATIONS_SERVICE, NOTIFICATIONS_PATH, NOTIFICATIONS_INTERFACE, QDBusConnection.sessionBus(), None)
def __init__(self): super(NotificationsInterface, self).__init__( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection.sessionBus(), None)
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 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, 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 __init__(self): super(ScreenSaverInterface, self).__init__( SCREEN_SAVER_SERVICE, SCREEN_SAVER_PATH, SCREEN_SAVER_INTERFACE, QDBusConnection.sessionBus(), None) self._inhibit_cookie = None
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, parent: QObject = None) -> None: super().__init__(bridge) if not qtutils.version_check('5.14'): raise Error("Notifications are not supported on Qt < 5.14") if utils.is_windows: # The QDBusConnection destructor seems to cause error messages (and # potentially segfaults) on Windows, so we bail out early in that case. # We still try to get a connection on macOS, since it's theoretically # possible to run DBus there. raise Error("libnotify is not supported on Windows") bus = QDBusConnection.sessionBus() if not bus.isConnected(): raise Error( "Failed to connect to DBus session bus: " + self._dbus_error_str(bus.lastError())) self._watcher = QDBusServiceWatcher( self.SERVICE, bus, QDBusServiceWatcher.WatchForUnregistration, self, ) self._watcher.serviceUnregistered.connect( # type: ignore[attr-defined] self._on_service_unregistered) test_service = 'test-notification-service' in objects.debug_flags service = self.TEST_SERVICE if test_service else self.SERVICE self.interface = QDBusInterface(service, self.PATH, self.INTERFACE, bus) if not self.interface.isValid(): raise Error( "Could not construct a DBus interface: " + self._dbus_error_str(self.interface.lastError())) connections = [ ("NotificationClosed", self._handle_close), ("ActionInvoked", self._handle_action), ] for name, func in connections: if not bus.connect(service, self.PATH, self.INTERFACE, name, func): raise Error( f"Could not connect to {name}: " + self._dbus_error_str(bus.lastError())) self._quirks = _ServerQuirks() if not test_service: # Can't figure out how to make this work with the test server... # https://www.riverbankcomputing.com/pipermail/pyqt/2021-March/043724.html self._get_server_info() if self._quirks.skip_capabilities: self._capabilities = _ServerCapabilities.from_list([]) else: self._fetch_capabilities()
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 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(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 main(localedir=None, autoupdate=True): # Some libs (ie. Phonon) require those to be set QtWidgets.QApplication.setApplicationName(PICARD_APP_NAME) QtWidgets.QApplication.setOrganizationName(PICARD_ORG_NAME) QtWidgets.QApplication.setDesktopFileName(PICARD_DESKTOP_NAME) # Allow High DPI Support QtWidgets.QApplication.setAttribute( QtCore.Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) QtWidgets.QApplication.setAttribute( QtCore.Qt.ApplicationAttribute.AA_EnableHighDpiScaling) # HighDpiScaleFactorRoundingPolicy is available since Qt 5.14. This is # required to support fractional scaling on Windows properly. # It causes issues without scaling on Linux, see https://tickets.metabrainz.org/browse/PICARD-1948 if IS_WIN and hasattr(QtGui.QGuiApplication, 'setHighDpiScaleFactorRoundingPolicy'): QtGui.QGuiApplication.setHighDpiScaleFactorRoundingPolicy( QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) # Enable mnemonics on all platforms, even macOS QtGui.qt_set_sequence_auto_mnemonic(True) signal.signal(signal.SIGINT, signal.SIG_DFL) picard_args, unparsed_args = process_picard_args() if picard_args.version: return version() if picard_args.long_version: return longversion() try: from PyQt5.QtDBus import QDBusConnection dbus = QDBusConnection.sessionBus() dbus.registerService(PICARD_APP_ID) except ImportError: pass tagger = Tagger(picard_args, unparsed_args, localedir, autoupdate) # Initialize Qt default translations translator = QtCore.QTranslator() locale = QtCore.QLocale() translation_path = QtCore.QLibraryInfo.location( QtCore.QLibraryInfo.LibraryLocation.TranslationsPath) log.debug("Looking for Qt locale %s in %s", locale.name(), translation_path) if translator.load(locale, "qtbase_", directory=translation_path): tagger.installTranslator(translator) else: log.debug('Qt locale %s not available', locale.name()) tagger.startTimer(1000) sys.exit(tagger.run())
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 __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)
def __init__(self, argv): QGuiApplication.__init__(self, argv) self.view = QQuickView() self.bus = QDBusConnection.sessionBus() self.server = MyDBUSServer(self) self.bus.registerObject("/app", self.server) self.bus.registerService("sevanteri.TabletShortcuts") self.view.setTitle("TabletShortcuts") self.view.setResizeMode(QQuickView.SizeRootObjectToView) self.view.setSource(QUrl('main.qml')) self.root = self.view.rootObject() self.showView() self.root.runCommand.connect(self.run) self.root.hideView.connect(self.view.hide) self.view.engine().quit.connect(self.quit)