コード例 #1
0
ファイル: main.py プロジェクト: kissthink/deepin-store
def start_main():
    # Init.
    DBusGMainLoop(set_as_default=True)
    gtk.gdk.threads_init()
    session_bus = dbus.SessionBus()
    options, arguments = get_parser()

    # Send hello message if updater has running.
    if is_dbus_name_exists(DSC_FRONTEND_NAME, True):

        bus_object = session_bus.get_object(DSC_FRONTEND_NAME, DSC_FRONTEND_PATH)
        bus_interface = dbus.Interface(bus_object, DSC_FRONTEND_NAME)
        bus_interface.raise_to_top()
        if options.show_page:
            bus_interface.show_page(options.show_page)
    else:
        # Init dbus.
        bus_name = dbus.service.BusName(DSC_FRONTEND_NAME, session_bus)

        software_center = DeepinSoftwareCenter(session_bus, arguments)
        if options.show_page:
            gtk.timeout_add(500, lambda:software_center.show_page(options.show_page))
        if options.show_recommend:
            software_center.recommend_status = options.show_recommend
        if options.start_quiet:
            software_center.init_hide = True

        try:
            software_center.run()
        except KeyboardInterrupt:
            software_center.bus_interface.request_quit()
コード例 #2
0
def start_module_process(slider, content_page_info, module_path, module_config, force_direction=None,
                         module_uid=None):
    global previous_module_id

    module_id = module_config.get("main", "id")
    module_slide_to_page = True
    if module_config.has_option("main", "slide_to_page"):
        if module_config.get("main", "slide_to_page") == "False":
            module_slide_to_page = False

    content_page = content_page_info.get_content_page(module_id)
    content_page_info.set_active_module_id(module_id)

    if module_slide_to_page:
        slider.slide_to_page(content_page, "none")

    module_dbus_name = "com.deepin.%s_settings" % (module_id)
    if not is_dbus_name_exists(module_dbus_name):
        if module_uid:
            subprocess.Popen("python %s %s" % (os.path.join(module_path, module_config.get("main", "program")), module_uid), shell=True)
        else:
            subprocess.Popen("python %s" % (os.path.join(module_path, module_config.get("main", "program"))), shell=True)
    else:
        if module_uid:
            send_message(module_id, "show_again", module_uid)
        else:
            send_message(module_id, "show_again", "")

    previous_module_id = module_id
コード例 #3
0
 def __button_press(self, widget, event, module_id, module_uid=""):
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = dbus.SessionBus().get_object(APP_DBUS_NAME,
                                                   APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method("goto", (module_id, module_uid),
                reply_handler=self.__handle_dbus_replay,
                error_handler=self.__handle_dbus_error)
コード例 #4
0
 def __send_message(self, message_type, message_content):
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = dbus.SessionBus().get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method(message_type,
                message_content,
                reply_handler=self.__handle_dbus_replay,
                error_handler=self.__handle_dbus_error)
コード例 #5
0
 def __button_press(self, widget, event, module_id, module_uid=""):
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = dbus.SessionBus().get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method("goto", 
                (module_id, module_uid), 
                reply_handler=self.__handle_dbus_replay, 
                error_handler=self.__handle_dbus_error)
コード例 #6
0
 def __send_message(self, message_type, message_content):
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = dbus.SessionBus().get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method(message_type, 
                message_content, 
                reply_handler=self.__handle_dbus_replay, 
                error_handler=self.__handle_dbus_error)
コード例 #7
0
 def send_message(self, message_type, message_content):    
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = self.bus.get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method(message_type, 
                message_content,
                reply_handler=self.handle_dbus_reply, # add reply handler
                error_handler=self.handle_dbus_error  # add error handler
                )
コード例 #8
0
 def send_message(self, message_type, message_content):
     if is_dbus_name_exists(APP_DBUS_NAME):
         bus_object = self.bus.get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
         method = bus_object.get_dbus_method("message_receiver")
         method(
             message_type,
             message_content,
             reply_handler=self.handle_dbus_reply,  # add reply handler
             error_handler=self.handle_dbus_error  # add error handler
         )
コード例 #9
0
def send_message(module_id, message_type, message_content):
    bus = dbus.SessionBus()
    module_dbus_name = "com.deepin.%s_settings" % (module_id)
    module_object_name = "/com/deepin/%s_settings" % (module_id)
    if is_dbus_name_exists(module_dbus_name):
        bus_object = bus.get_object(module_dbus_name, module_object_name)
        method = bus_object.get_dbus_method("message_receiver")
        method(message_type,
               message_content,
               reply_handler=handle_dbus_reply,
               error_handler=handle_dbus_error)
コード例 #10
0
 def __add_button_clicked(self, widget, argv):
     bus = dbus.SessionBus()
     module_dbus_name = "com.deepin.%s_settings" % (self.module_id)
     module_object_name = "/com/deepin/%s_settings" % (self.module_id)
     if is_dbus_name_exists(module_dbus_name):
         bus_object = bus.get_object(module_dbus_name, module_object_name)
         method = bus_object.get_dbus_method("message_receiver")
         method("add_button_cb",
                argv,
                reply_handler=self.__handle_dbus_reply,
                error_handler=self.__handle_dbus_error)
コード例 #11
0
 def start_updater(self, loop=True):
     try:
         if is_dbus_name_exists(DSC_UPDATER_NAME, False):
             self.logwarn("Deepin software center updater has running!")
         else:
             system_bus = dbus.SystemBus()
             bus_object = system_bus.get_object(DSC_UPDATER_NAME, DSC_UPDATER_PATH)
             dbus.Interface(bus_object, DSC_UPDATER_NAME)
             self.loginfo("Start dsc data update service.")
     except Exception, e:
         self.logerror("got error: %s" % (e))
コード例 #12
0
 def send_message(self, message_type, contents):
     bus = dbus.SessionBus()
     flash_dbus_name = "com.deepin.game_flash_%s" % (self.appid)
     flash_dbus_path = "/com/deepin/game_flash_%s" % (self.appid)
     if is_dbus_name_exists(flash_dbus_name):
         bus_object = bus.get_object(flash_dbus_name, flash_dbus_path)
         method = bus_object.get_dbus_method("message_receiver")
         method(message_type,
                contents,
                reply_handler=handle_dbus_reply,
                error_handler=handle_dbus_error)
コード例 #13
0
def send_message(module_id, message_type, message_content):
    bus = dbus.SessionBus()
    module_dbus_name = "com.deepin.%s_settings" % (module_id)
    module_object_name = "/com/deepin/%s_settings" % (module_id)
    if is_dbus_name_exists(module_dbus_name):
        bus_object = bus.get_object(module_dbus_name, module_object_name)
        method = bus_object.get_dbus_method("message_receiver")
        method(message_type,
               message_content,
               reply_handler=handle_dbus_reply,
               error_handler=handle_dbus_error
               )
コード例 #14
0
 def __add_button_clicked(self, widget, argv):                                      
     bus = dbus.SessionBus()                                                              
     module_dbus_name = "com.deepin.%s_settings" % (self.module_id)                  
     module_object_name = "/com/deepin/%s_settings" % (self.module_id)                  
     if is_dbus_name_exists(module_dbus_name):                                       
         bus_object = bus.get_object(module_dbus_name, module_object_name)       
         method = bus_object.get_dbus_method("message_receiver")                 
         method("add_button_cb",                                                        
                argv,                                                             
                reply_handler=self.__handle_dbus_reply,                          
                error_handler=self.__handle_dbus_error                          
               )                    
コード例 #15
0
ファイル: player.py プロジェクト: huowa222/deepin-game-center
 def send_message(self, message_type, contents):
     bus = dbus.SessionBus()
     flash_dbus_name = "com.deepin.game_flash_%s" % (self.appid)
     flash_dbus_path = "/com/deepin/game_flash_%s" % (self.appid)
     if is_dbus_name_exists(flash_dbus_name):
         bus_object = bus.get_object(flash_dbus_name, flash_dbus_path)
         method = bus_object.get_dbus_method("message_receiver")
         method(
             message_type, 
             contents,
             reply_handler=handle_dbus_reply,
             error_handler=handle_dbus_error
         )
コード例 #16
0
 def connect_signal(self):
     session_bus = dbus.SessionBus()
     GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % self.appid
     GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % self.appid
     if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME):
         session_bus.add_signal_receiver(
                 self.signal_receiver, 
                 signal_name="update_signal", 
                 dbus_interface=GAME_PLAYER_DBUS_NAME, 
                 path=GAME_PLAYER_DBUS_PATH)
         return False
     else:
         return True
コード例 #17
0
    def send_message(self, message_type, message_content):
        session_bus = dbus.SessionBus()
        GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % self.appid
        GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % self.appid
        if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME):

            bus_object = session_bus.get_object(GAME_PLAYER_DBUS_NAME, GAME_PLAYER_DBUS_PATH)
            method = bus_object.get_dbus_method("message_receiver")
            method(message_type, 
                   message_content,
                   reply_handler=self.handle_dbus_reply, # add reply handler
                   error_handler=self.handle_dbus_error  # add error handler
                   )
コード例 #18
0
def start_updater(loop=True):
    try:
        if is_dbus_name_exists(DSC_UPDATER_NAME, False):
            log("Deepin software center updater has running!")
            print "Deepin software center updater has running!"
        else:
            system_bus = dbus.SystemBus()
            bus_object = system_bus.get_object(DSC_UPDATER_NAME, DSC_UPDATER_PATH)
            dbus.Interface(bus_object, DSC_UPDATER_NAME)
            log("Start dsc data update service.")
            print "Start dsc data update service."
    except Exception, e:
        log("got error: %s" % (e))
        print "got error: %s" % (e)
        traceback.print_exc(file=sys.stdout)
コード例 #19
0
    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()
コード例 #20
0
ファイル: preference.py プロジェクト: kissthink/deepin-store
    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()
コード例 #21
0
def start_main_window():
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    if is_dbus_name_exists(GAME_CENTER_DBUS_NAME, True):
        print "deepin game center has running!"
        
        bus_object = session_bus.get_object(GAME_CENTER_DBUS_NAME,
                                            GAME_CENTER_DBUS_PATH)
        bus_interface = dbus.Interface(bus_object, GAME_CENTER_DBUS_NAME)
        bus_interface.hello()
        
    else:
        bus_name = dbus.service.BusName(GAME_CENTER_DBUS_NAME, session_bus)
        try:
            GameCenterApp(session_bus).run()
        except KeyboardInterrupt:
            pass
コード例 #22
0
def start_main_window():
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()

    if is_dbus_name_exists(GAME_CENTER_DBUS_NAME, True):
        print "deepin game center has running!"

        bus_object = session_bus.get_object(GAME_CENTER_DBUS_NAME,
                                            GAME_CENTER_DBUS_PATH)
        bus_interface = dbus.Interface(bus_object, GAME_CENTER_DBUS_NAME)
        bus_interface.hello()

    else:
        bus_name = dbus.service.BusName(GAME_CENTER_DBUS_NAME, session_bus)
        try:
            GameCenterApp(session_bus).run()
        except KeyboardInterrupt:
            pass
コード例 #23
0
    def start_dsc_backend(self):
        if is_dbus_name_exists(DSC_SERVICE_NAME, False):
            print "running..."
            self.label.set_label("软件中心后端正在运行...")
            self.show()

            self.system_bus = dbus.SystemBus()
            bus_object = self.system_bus.get_object(DSC_SERVICE_NAME, DSC_SERVICE_PATH)
            self.bus_interface = dbus.Interface(bus_object, DSC_SERVICE_NAME)
            gtk.timeout_add(2000, lambda :self.system_bus.add_signal_receiver(
                    self.backend_signal_receiver, 
                    signal_name="update_signal", 
                    dbus_interface=DSC_SERVICE_NAME, 
                    path=DSC_SERVICE_PATH))
        else:
            print "error..."
            self.label.set_label("出错了!\n软件中心的后端已退出")
            gtk.timeout_add(3000, gtk.main_quit)
            self.show()
コード例 #24
0
ファイル: main.py プロジェクト: w1748587889/deepin-store
def start_main():
    # Init.
    DBusGMainLoop(set_as_default=True)
    gtk.gdk.threads_init()
    session_bus = dbus.SessionBus()
    options, arguments = get_parser()
    logger.info("options:" + str(options))
    logger.info("arguments:" + str(arguments))

    # Send hello message if updater has running.
    if is_dbus_name_exists(DSC_FRONTEND_NAME, True):

        bus_object = session_bus.get_object(DSC_FRONTEND_NAME,
                                            DSC_FRONTEND_PATH)
        bus_interface = dbus.Interface(bus_object, DSC_FRONTEND_NAME)
        bus_interface.raise_to_top()
        if options.show_page:
            bus_interface.show_page(options.show_page)
        pkg_name = get_apt_argument(arguments)
        if pkg_name:
            bus_interface.show_page(pkg_name)
    else:
        # Init dbus.
        bus_name = dbus.service.BusName(DSC_FRONTEND_NAME, session_bus)

        software_center = DeepinSoftwareCenter(session_bus, arguments)
        if options.show_page:
            gtk.timeout_add(
                500, lambda: software_center.show_page(options.show_page))
        if options.show_recommend:
            software_center.recommend_status = options.show_recommend
        if options.start_quiet:
            software_center.init_hide = True

        pkg_name = get_apt_argument(arguments)
        if pkg_name:
            gtk.timeout_add(800, lambda: software_center.show_detail(pkg_name))

        try:
            software_center.run()
        except KeyboardInterrupt:
            software_center.bus_interface.request_quit()
コード例 #25
0
def start_module_process(slider,
                         content_page_info,
                         module_path,
                         module_config,
                         force_direction=None,
                         module_uid=None):
    global previous_module_id

    module_id = module_config.get("main", "id")
    module_slide_to_page = True
    if module_config.has_option("main", "slide_to_page"):
        if module_config.get("main", "slide_to_page") == "False":
            module_slide_to_page = False

    content_page = content_page_info.get_content_page(module_id)
    content_page_info.set_active_module_id(module_id)

    if module_slide_to_page:
        slider.slide_to_page(content_page, "none")

    module_dbus_name = "com.deepin.%s_settings" % (module_id)
    if not is_dbus_name_exists(module_dbus_name):
        if module_uid:
            subprocess.Popen(
                "python %s %s" %
                (os.path.join(module_path, module_config.get(
                    "main", "program")), module_uid),
                shell=True)
        else:
            subprocess.Popen("python %s" % (os.path.join(
                module_path, module_config.get("main", "program"))),
                             shell=True)
    else:
        if module_uid:
            send_message(module_id, "show_again", module_uid)
        else:
            send_message(module_id, "show_again", "")

    previous_module_id = module_id
コード例 #26
0
def start_player(args):
    args = args.split(',')
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    appid = args[0]
    GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % appid
    GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % appid

    if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME, True):
        print "deepin game center has running!"
        
        bus_object = session_bus.get_object(GAME_PLAYER_DBUS_NAME,
                                            GAME_PLAYER_DBUS_PATH)
        #bus_interface = dbus.Interface(bus_object, GAME_PLAYER_DBUS_NAME)
        method = bus_object.get_dbus_method("unique")
        method()

    else:
        bus_name = dbus.service.BusName(GAME_PLAYER_DBUS_NAME, session_bus)
        try:
            Player(session_bus, args, GAME_PLAYER_DBUS_NAME, GAME_PLAYER_DBUS_PATH).run()
        except KeyboardInterrupt:
            pass
コード例 #27
0
def start_player(args):
    args = args.split(',')
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    appid = args[0]
    GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % appid
    GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % appid

    if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME, True):
        print "deepin game center has running!"

        bus_object = session_bus.get_object(GAME_PLAYER_DBUS_NAME,
                                            GAME_PLAYER_DBUS_PATH)
        #bus_interface = dbus.Interface(bus_object, GAME_PLAYER_DBUS_NAME)
        method = bus_object.get_dbus_method("unique")
        method()

    else:
        bus_name = dbus.service.BusName(GAME_PLAYER_DBUS_NAME, session_bus)
        try:
            Player(session_bus, args, GAME_PLAYER_DBUS_NAME,
                   GAME_PLAYER_DBUS_PATH).run()
        except KeyboardInterrupt:
            pass
コード例 #28
0
 def wrap(*a, **kws):
     if is_dbus_name_exists("org.freedesktop.NetworkManager", False):
         return func(*a, **kws)
コード例 #29
0
        return self.socket.get_id()


gobject.type_register(ContentPage)

if __name__ == '__main__':
    import sys

    #sys.argv = sys.argv + ['100000614', '%E8%B7%B3%E8%B7%83%E5%B0%91%E5%A5%B3', '640', '480', '/media/game_media/100000614/100000614.swf']
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    appid = sys.argv[1]
    GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % appid
    GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % appid

    if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME, True):
        print "deepin game center has running!"

        bus_object = session_bus.get_object(GAME_PLAYER_DBUS_NAME,
                                            GAME_PLAYER_DBUS_PATH)
        #bus_interface = dbus.Interface(bus_object, GAME_PLAYER_DBUS_NAME)
        method = bus_object.get_dbus_method("unique")
        method()

    else:
        # Init dbus.
        bus_name = dbus.service.BusName(GAME_PLAYER_DBUS_NAME, session_bus)

        try:
            Player(session_bus, sys.argv[1:], GAME_PLAYER_DBUS_NAME,
                   GAME_PLAYER_DBUS_PATH).run()
コード例 #30
0
    def quit(self):
        gtk.main_quit()

    @dbus.service.method(DSC_UPDATE_MANAGER_NAME, in_signature="", out_signature="")    
    def hello(self):
        self.application.window.present()

class PackageItem(TreeItem):
    def __init__(self):
        pass

if __name__ == '__main__':
    arguments = sys.argv[1::]

    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    if is_dbus_name_exists(DSC_UPDATE_MANAGER_NAME, True):
        print "Update Manager is running"
        bus_object = session_bus.get_object(DSC_UPDATE_MANAGER_NAME,
                                            DSC_UPDATE_MANAGER_PATH)
        bus_interface = dbus.Interface(bus_object, DSC_UPDATE_MANAGER_NAME)
        bus_interface.hello()
    else:
        bus = dbus.service.BusName(DSC_UPDATE_MANAGER_NAME, session_bus)
        try:
            UpdateManager(session_bus).run()
        except KeyboardInterrupt:
            pass
コード例 #31
0
                    gtk.timeout_add(2000, gtk.main_quit)

            elif signal_type == "action-finish":
                (pkg_name, action_type, pkg_info_list) = action_content
                self.label.set_label("%s完成,2秒钟后退出" % ACTION_STR[action_type])
                gtk.timeout_add(2000, gtk.main_quit)

            elif signal_type == "action-failed":
                (pkg_name, action_type, pkg_info_list, errormsg) = action_content
                self.label.set_label("%s失败,2秒钟后退出" % ACTION_STR[action_type])
                gtk.timeout_add(2000, gtk.main_quit)

if __name__ == '__main__':
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    if is_dbus_name_exists(DSC_UPDATE_MONITOR_NAME):
        print "Update MONITOR is running"
        bus_object = session_bus.get_object(DSC_UPDATE_MONITOR_NAME,
                                            DSC_UPDATE_MONITOR_PATH)
        bus_interface = dbus.Interface(bus_object, DSC_UPDATE_MONITOR_NAME)
        bus_interface.hello()
    else:
        bus = dbus.service.BusName(DSC_UPDATE_MONITOR_NAME, session_bus)
        win = TipWindow(session_bus)
        try:
            win.run()
        except:
            if hasattr(win, 'bus_interface'):
                win.bus_interface.request_quit()
コード例 #32
0
 def wrap(*a, **kws):
     if is_dbus_name_exists("org.freedesktop.NetworkManager", False):
         return func(*a, **kws)
コード例 #33
0
    def run(self):
        self.ready_show()

    @dbus.service.method(GAME_CENTER_DBUS_NAME, in_signature="", out_signature="")    
    def hello(self):
        if self.in_wizard_showing:
            self.wizard_win.present()
        else:
            self.application.window.present()

if __name__ == '__main__':
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    if is_dbus_name_exists(GAME_CENTER_DBUS_NAME, True):
        print "deepin game center has running!"
        
        bus_object = session_bus.get_object(GAME_CENTER_DBUS_NAME,
                                            GAME_CENTER_DBUS_PATH)
        bus_interface = dbus.Interface(bus_object, GAME_CENTER_DBUS_NAME)
        bus_interface.hello()
        
    else:
        # Init dbus.
        bus_name = dbus.service.BusName(GAME_CENTER_DBUS_NAME, session_bus)
            
        try:
            GameCenterApp(session_bus).run()
        except KeyboardInterrupt:
            pass
コード例 #34
0
def is_dbus_name_exists(dbus_name, request_session_bus=True):
    print "Please import deepin_utils.ipc.is_dbus_name_exists, this function will departed in next release version."
    return ipc.is_dbus_name_exists(dbus_name, request_session_bus=True)
コード例 #35
0
        
    def home_values_to_list(self):
        data = []
        for key in self.home_values:
            data.append(self.home_values[key])
        return data

    @dbus.service.method(DEEPIN_USER_MANUAL_NAME, in_signature="", out_signature="")    
    def hello(self):
        self.window.present()

if __name__ == "__main__":
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    if is_dbus_name_exists(DEEPIN_USER_MANUAL_NAME, True):
        print "deepin user manual has running!"
        
        bus_object = session_bus.get_object(DEEPIN_USER_MANUAL_NAME,
                                            DEEPIN_USER_MANUAL_PATH)
        bus_interface = dbus.Interface(bus_object, DEEPIN_USER_MANUAL_NAME)
        bus_interface.hello()
        
    else:
        # Init dbus.
        bus_name = dbus.service.BusName(DEEPIN_USER_MANUAL_NAME, session_bus)
            
        try:
            user_manual = UserManual(session_bus)
        except KeyboardInterrupt:
            pass
コード例 #36
0

def start_ui(network):
    print "start ui"
    network.refresh()


if __name__ == '__main__':
    module_frame = ModuleFrame(
        os.path.join(get_parent_dir(__file__, 2), "config.ini"))
    Dispatcher.load_module_frame(module_frame)
    Dispatcher.load_slider(slider)

    module_frame.add(slider)

    if is_dbus_name_exists("org.freedesktop.NetworkManager", False):
        n = Network()
        Dispatcher.connect("service-start-do-more", lambda w: start_ui(n))

        def message_handler(*message):
            (message_type, message_content) = message
            if message_type == "show_again":
                slider._set_to_page("main")
                module_frame.send_module_info()
            elif message_type == "click_crumb":
                print "click_crumb"
                (crumb_index, crumb_label) = message_content
                if crumb_index == 1:
                    slider._slide_to_page("main", "none")
                if crumb_label == _("VPN"):
                    slider._slide_to_page("vpn", "none")
コード例 #37
0
        notification.notify()

if __name__ == "__main__" :

    uid = os.geteuid()
    if uid == 0:
        sys.exit(0)

    arguments = sys.argv[1::]

    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    
    mainloop = gobject.MainLoop()
    signal.signal(signal.SIGINT, lambda : mainloop.quit()) # capture "Ctrl + c" signal

    if is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME, True):
        print "Daemon is running"
    else:
        bus_name = dbus.service.BusName(DSC_UPDATE_DAEMON_NAME, session_bus)
            
        update = Update(session_bus, mainloop)
        try:
            if '--debug' in arguments:
                gobject.timeout_add_seconds(1, update.run)
            else:
                gobject.timeout_add_seconds(120, update.run)
            mainloop.run()
        except KeyboardInterrupt:
            update.exit_loop()
コード例 #38
0
        print "%s: 补丁%s合并完成" % (space_name, patch_name)
        log("%s: 补丁%s合并完成" % (space_name, patch_name))

    def clean(self):
        remove_file(os.path.join(DATA_DIR, "patch_status.ini"))
        for dir_name in os.listdir(DATA_DIR):
            if dir_name in ["newest", "update", "patch"]:
                remove_path(os.path.join(DATA_DIR, dir_name))
       
if __name__ == "__main__":
    # Init.
    dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
    arguments = sys.argv[1::]
    
    # Exit if updater has running.
    if is_dbus_name_exists(DSC_UPDATER_NAME, False):
        print "Deepin software center updater has running!"
        log("Deepin software center updater has running!")
    else:
        # Init mainloop.
        mainloop = glib.MainLoop()
        signal.signal(signal.SIGINT, lambda w, d: mainloop.quit()) # capture "Ctrl + c" signal
        
        # Auth with root permission.
        if not auth_with_policykit("com.linuxdeepin.softwarecenterupdater.action",
                                   "org.freedesktop.PolicyKit1", 
                                   "/org/freedesktop/PolicyKit1/Authority", 
                                   "org.freedesktop.PolicyKit1.Authority",
                                   ):
            print "Authority failed"
            log("Authority failed")
コード例 #39
0
    for module_info_list in module_infos:
        for module_info in module_info_list:
            content_page_info.create_content_page(module_info.id)

    # Connect widgets.
    body_box.pack_start(slider, True, True)

    main_box.pack_start(action_bar, False, False)
    main_box.pack_start(body_box, True, True)
    #main_box.pack_start(foot_box, False, False)
    main_align.add(main_box)
    application.main_box.pack_start(main_align)

    # Start dbus service.
    DBusService(action_bar, content_page_info, application, module_dict,
                slider, foot_box)

    if not module_dict.get(module_name):
        slider.set_to_page(navigate_page)
    else:
        if is_dbus_name_exists(APP_DBUS_NAME):
            session_bus = dbus.SessionBus()
            bus_object = session_bus.get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
            method = bus_object.get_dbus_method("message_receiver")
            method("goto", (module_name, ""),
                   reply_handler=handle_dbus_reply,
                   error_handler=handle_dbus_error)

    application.run()
コード例 #40
0
ファイル: player.py プロジェクト: huowa222/deepin-game-center
        return self.socket.get_id()
                
gobject.type_register(ContentPage)


if __name__ == '__main__':
    import sys

    #sys.argv = sys.argv + ['100000614', '%E8%B7%B3%E8%B7%83%E5%B0%91%E5%A5%B3', '640', '480', '/media/game_media/100000614/100000614.swf']
    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    appid = sys.argv[1]
    GAME_PLAYER_DBUS_NAME = "com.deepin.game_player_%s" % appid
    GAME_PLAYER_DBUS_PATH = "/com/deepin/game_player_%s" % appid

    if is_dbus_name_exists(GAME_PLAYER_DBUS_NAME, True):
        print "deepin game center has running!"
        
        bus_object = session_bus.get_object(GAME_PLAYER_DBUS_NAME,
                                            GAME_PLAYER_DBUS_PATH)
        #bus_interface = dbus.Interface(bus_object, GAME_PLAYER_DBUS_NAME)
        method = bus_object.get_dbus_method("unique")
        method()

    else:
        # Init dbus.
        bus_name = dbus.service.BusName(GAME_PLAYER_DBUS_NAME, session_bus)
            
        try:
            Player(session_bus, sys.argv[1:], GAME_PLAYER_DBUS_NAME, GAME_PLAYER_DBUS_PATH).run()
        except KeyboardInterrupt:
コード例 #41
0
ファイル: utils.py プロジェクト: chenzhiwei/deepin-ui
def is_dbus_name_exists(dbus_name, request_session_bus=True):
    print "Please import deepin_utils.ipc.is_dbus_name_exists, this function will departed in next release version."
    return ipc.is_dbus_name_exists(dbus_name, request_session_bus=True)
コード例 #42
0
            
    def handle_dbus_reply(self, *reply):
        # print "%s (reply): %s" % (self.module_dbus_name, str(reply))
        pass
        
    def handle_dbus_error(self, *error):
        #print "%s (error): %s" % (self.module_dbus_name, str(error))
        pass
        
    def send_flash_info(self):
        self.send_message("send_plug_id", (self.appid, self.plug.get_id()))

if __name__ == '__main__':
    import sys

    DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    appid = sys.argv[1]
    FLASH_DBUS_NAME = "com.deepin.game_flash_%s" % (appid)
    FLASH_DBUS_PATH = "/com/deepin/game_flash_%s" % (appid)

    if is_dbus_name_exists(FLASH_DBUS_NAME, True):
        print "deepin game %s has running!" % appid
        bus_object = session_bus.get_object(FLASH_DBUS_NAME, FLASH_DBUS_PATH)
    else:
        bus_name = dbus.service.BusName(FLASH_DBUS_NAME, session_bus)
        try:
            FlashFrame(session_bus, appid, FLASH_DBUS_NAME, FLASH_DBUS_PATH).run()
        except KeyboardInterrupt:
            pass
コード例 #43
0
            content_page_info.create_content_page(module_info.id)

    # Connect widgets.
    body_box.pack_start(slider, True, True)

    main_box.pack_start(action_bar, False, False)
    main_box.pack_start(body_box, True, True)
    #main_box.pack_start(foot_box, False, False)
    main_align.add(main_box)
    application.main_box.pack_start(main_align)

    # Start dbus service.
    DBusService(action_bar, content_page_info, application, module_dict,
            slider, foot_box)

    if not module_dict.get(module_name):
        slider.set_to_page(navigate_page)
    else:
        if is_dbus_name_exists(APP_DBUS_NAME):
            session_bus = dbus.SessionBus()
            bus_object = session_bus.get_object(APP_DBUS_NAME, APP_OBJECT_NAME)
            method = bus_object.get_dbus_method("message_receiver")
            method(
                "goto",
                (module_name, ""),
                reply_handler=handle_dbus_reply,
                error_handler=handle_dbus_error
                )

    application.run()
コード例 #44
0
from dss_log import log

slider = nm_module.slider

def start_ui(network):
    print "start ui"
    network.refresh()

if __name__ == '__main__':
    module_frame = ModuleFrame(os.path.join(get_parent_dir(__file__, 2), "config.ini"))
    Dispatcher.load_module_frame(module_frame)
    Dispatcher.load_slider(slider)

    module_frame.add(slider)

    if is_dbus_name_exists("org.freedesktop.NetworkManager", False):
        n = Network()
        Dispatcher.connect("service-start-do-more", lambda w: start_ui(n))
        
        def message_handler(*message):
            (message_type, message_content) = message
            if message_type == "show_again":
                slider._set_to_page("main")
                module_frame.send_module_info()
            elif message_type == "click_crumb":
                print "click_crumb"
                (crumb_index, crumb_label) = message_content
                if crumb_index == 1:
                    slider._slide_to_page("main", "none")
                if crumb_label == _("VPN"):
                    slider._slide_to_page("vpn", "none")