示例#1
0
def setup(app):
    """Request and return a dbus interface for controlling the MeldApp."""
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    request = bus.request_name(DBUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
    already_running = request == dbus.bus.REQUEST_NAME_REPLY_EXISTS
    if already_running:
        obj = dbus.Interface(bus.get_object(DBUS_NAME, DBUS_PATH), DBUS_NAME)
    else:
        obj = DBusProvider(bus, DBUS_NAME, DBUS_PATH, app)
    return already_running, obj
示例#2
0
def setup(app):
    """Request and return a dbus interface for controlling the MeldApp."""
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    request = bus.request_name(DBUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
    already_running = request == dbus.bus.REQUEST_NAME_REPLY_EXISTS
    if already_running:
        obj = dbus.Interface(bus.get_object(DBUS_NAME, DBUS_PATH), DBUS_NAME)
    else:
        obj = DBusProvider(bus, DBUS_NAME, DBUS_PATH, app)
    return already_running, obj
示例#3
0
def setup_dbus(gtk_app, bus_interface="org.ojuba.Monajat"):
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    request = bus.request_name(bus_interface, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)

    if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        app = OjDBus(gtk_app, bus, '/', bus_interface)
    else:
        print "Exiting: Application already running..."
        object = bus.get_object(bus_interface, "/")
        app = dbus.Interface(object, bus_interface)
        app.start()
        exit(-1)
示例#4
0
def setup_dbus(gtk_app, bus_interface="org.ojuba.Monajat"):
    dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
    bus = dbus.SessionBus ()
    request = bus.request_name (bus_interface, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
    
    if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        app = OjDBus(gtk_app, bus, '/', bus_interface)
    else:
        print "Exiting: Application already running..."
        object = bus.get_object (bus_interface, "/")
        app = dbus.Interface (object, bus_interface)
        app.start()
        exit(-1)
示例#5
0
def main():
    """The main entry point, compatible with setuptools entry points."""
    from optparse import OptionParser
    parser = OptionParser(version="%%prog v%s" % __version__,
                          usage="%prog [options] <gogdownloader URI> ...",
                          description=__doc__.replace(
                              '\r\n', '\n').split('\n--snip--\n')[0])
    parser.add_option(
        '-v',
        '--verbose',
        action="count",
        dest="verbose",
        default=2,
        help="Increase the verbosity. Use twice for extra effect")
    parser.add_option(
        '-q',
        '--quiet',
        action="count",
        dest="quiet",
        default=0,
        help="Decrease the verbosity. Use twice for extra effect")
    # Reminder: %default can be used in help strings.

    # Allow pre-formatted descriptions
    parser.formatter.format_description = lambda description: description

    opts, args = parser.parse_args()

    # Set up clean logging to stderr
    log_levels = [
        logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO,
        logging.DEBUG
    ]
    opts.verbose = min(opts.verbose - opts.quiet, len(log_levels) - 1)
    opts.verbose = max(opts.verbose, 0)
    logging.basicConfig(level=log_levels[opts.verbose],
                        format='%(levelname)s: %(message)s')

    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    request = bus.request_name(SVC_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
    if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        app = Application(bus, '/', SVC_NAME)
    else:
        obj = bus.get_object(SVC_NAME, "/")
        app = dbus.Interface(obj, SVC_NAME)

    app.start(vars(opts), args, int(time.time()))
    if app.is_running():
        gtk.gdk.notify_startup_complete()
示例#6
0
def main():
    """The main entry point, compatible with setuptools entry points."""
    from optparse import OptionParser
    parser = OptionParser(version="%%prog v%s" % __version__,
            usage="%prog [options] <gogdownloader URI> ...",
            description=__doc__.replace('\r\n', '\n').split('\n--snip--\n')[0])
    parser.add_option('-v', '--verbose', action="count", dest="verbose",
        default=2, help="Increase the verbosity. Use twice for extra effect")
    parser.add_option('-q', '--quiet', action="count", dest="quiet",
        default=0, help="Decrease the verbosity. Use twice for extra effect")
    # Reminder: %default can be used in help strings.

    # Allow pre-formatted descriptions
    parser.formatter.format_description = lambda description: description

    opts, args = parser.parse_args()

    # Set up clean logging to stderr
    log_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING,
                  logging.INFO, logging.DEBUG]
    opts.verbose = min(opts.verbose - opts.quiet, len(log_levels) - 1)
    opts.verbose = max(opts.verbose, 0)
    logging.basicConfig(level=log_levels[opts.verbose],
                        format='%(levelname)s: %(message)s')

    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    request = bus.request_name(SVC_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
    if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        app = Application(bus, '/', SVC_NAME)
    else:
        obj = bus.get_object(SVC_NAME, "/")
        app = dbus.Interface(obj, SVC_NAME)

    app.start(vars(opts), args, int(time.time()))
    if app.is_running():
        gtk.gdk.notify_startup_complete()
        self.main_window.show_all()

    @dbus.service.method(DBUS_NAME, in_signature='', out_signature='b')
    def is_running(self):
        return self.running

    @dbus.service.method(DBUS_NAME, in_signature='a{sv}i', out_signature='')
    def start(self, options, timestamp):
        if self.is_running():
            self.main_window.present_with_time(timestamp)
        else:
            self.running = True
            Gtk.main()
            self.running = False


dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
request = bus.request_name(DBUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
    app = DBusDaemon(bus, '/', DBUS_NAME)
else:
    obj = bus.get_object(DBUS_NAME, "/")
    app = dbus.Interface(obj, DBUS_NAME)

# Get your options from the command line, e.g. with OptionParser
options = {'option1': 'value1'}
app.start(options, int(time.time()))
if app.is_running():
    Gdk.notify_startup_complete()
示例#8
0
        self.main_window.connect('destroy', Gtk.main_quit)
        self.main_window.show_all()

    @dbus.service.method(DBUS_NAME, in_signature='', out_signature='b')
    def is_running(self):
        return self.running

    @dbus.service.method(DBUS_NAME, in_signature='a{sv}i', out_signature='')
    def start(self, options, timestamp):
        if self.is_running():
            self.main_window.present_with_time(timestamp)
        else:
            self.running = True
            Gtk.main()
            self.running = False

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
request = bus.request_name(DBUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
if request != dbus.bus.REQUEST_NAME_REPLY_EXISTS:
    app = DBusDaemon(bus, '/', DBUS_NAME)
else:
    obj = bus.get_object(DBUS_NAME, "/")
    app = dbus.Interface(obj, DBUS_NAME)

# Get your options from the command line, e.g. with OptionParser
options = {'option1': 'value1'}
app.start(options, int(time.time()))
if app.is_running():
    Gdk.notify_startup_complete()