コード例 #1
0
 def onInit(self):
     from resources.lib.xbianWindow import XbianWindow
     import categories
     self.window = None
     self.category_list = categories.__all__
     self.total = len(self.category_list)
     self.category_list_instance = []
     self.finished = 0
     self.globalProgress = 0
     self.stop = False
     self.checkReboot = True
     self.wait = xbmcgui.DialogProgress()
     self.wait.create(_('XBian Config'), _('Please wait...'))
     self.wait.update(0)
     open(
         os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR, SKIN_RES,
                      'SettingsXbianInfo.xml'), 'w').close()
     self.window = XbianWindow('SettingsXbianInfo.xml', ROOTDIR)
コード例 #2
0
class xbianSettingWindow(xbianSettingCommon):

    def onInit(self):
        from resources.lib.xbianWindow import XbianWindow
        import categories
        self.window = None
        self.category_list = categories.__all__
        self.total = len(self.category_list)
        self.category_list_instance = []
        self.finished = 0
        self.globalProgress = 0
        self.stop = False
        self.checkReboot = True
        self.wait = xbmcgui.DialogProgress()
        self.wait.create(_('XBian Config'), _('Please wait...'))
        self.wait.update(0)
        self.window = XbianWindow('SettingsXbianInfo.xml', ROOTDIR)

    def onClean(self):
        if self.wait:
            self.wait.close()

    def onShow(self):
        for i, module in enumerate(self.category_list):
            if self.wait.iscanceled():
                self.stop = True
                break
            self.globalProgress = int((float(self.finished) / (self.total)) * 100)
            self.update_progress(module.split('_')[1],
                                 '    %s' % (_('Initialisation...'), ), 0)
            catmodule = __import__('%s.%s' % (CATEGORY_PATH, module), globals(), locals(), [module])
            modu = getattr(catmodule, module.split('_')[-1])
            catinstance = modu(self.CmdQueue, self.update_progress)
            self.finished += 1
            if catinstance.TITLE:
                try:
                    self.window.addCategory(catinstance)
                except:
                    xbmc.log('XBian : Cannot add category: %s \n%s' %
                             (str(module), str(sys.exc_info())))

        if not self.stop:
            # really don't know why, all others are ok, but skindir have to be global???
            global SKIN_DIR
            global SKIN_RES
            if not os.path.isfile(
                    os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR, SKIN_RES, 'SettingsXbianInfo.template')):
                SKIN_DIR = 'Default'
            self.window.doXml(
                os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR, SKIN_RES, 'SettingsXbianInfo.template'))
            self.wait.close()
            self.wait = None
            self.window.doModal()
            xbmc.log('XBian : XBian-config-python closed')

    def update_progress(self, categoryname, settingName, perc):
        perc = self.globalProgress + int(perc / self.total)
        self.wait.update(perc,
                         '%s %s...' % (_('Loading'), categoryname),
                         '   %s' % (settingName, ))
コード例 #3
0
class xbian_config_python :
    def __init__(self) :
        self.onRun = os.path.join('/','tmp','.xbian_config_python')
        if os.path.isfile(self.onRun) :
            xbmcgui.Dialog().ok('XBian-config','Xbian-config is still running','Please wait a bit...')
        else :      
            open(self.onRun,'w').close()
            try :
                self.CmdQueue = Queue.Queue()
                self.updateThread = Updater(self.CmdQueue)
                self.updateThread.start()
                self.wait = xbmcgui.DialogProgress()
                self.window = XbianWindow('SettingsXbianInfo.xml',ROOTDIR)
                self.category_list = []
                self.category_list_thread = []
                self.category_list_instance = {}
                self.finished = 0
                self.stop = False
                for fn in os.listdir(os.path.join(ROOTDIR,CATEGORY_PATH)):
                    if fn[0] != '_' and fn.split('.')[-1] in ('py', 'pyw'):
                        modulename = fn.split('.')[0] # filename without extension
                        self.category_list.append(modulename)
                self.category_list.sort()
                self.total = len(self.category_list)
                self.wait.create('Generating Windows','Please wait')
                self.wait.update(0)
                for module in self.category_list :
                    self.category_list_thread.append(threading.Thread(None,self.threadInitCategory, None, (module,)))
                    self.category_list_thread[-1].start()
                for i,threadInst in enumerate(self.category_list_thread):
                    if not self.stop :
                        threadInst.join()
                        self.window.addCategory(self.category_list_instance[self.category_list[i]])
                if not self.stop :
                    self.window.doXml(os.path.join(ROOTDIR,'resources','skins','Default','720p','SettingsXbianInfo.template'))
                    self.wait.close()
                    self.window.doModal() 
            except :
                print sys.exc_info()
            finally :
                self.updateThread.stop()
                os.remove(self.onRun)
        
    def update_progress(self) :
        self.finished += 1
        if self.wait.iscanceled() :
            self.stop = True
            self.wait.close()
        else :
            self.wait.update(int((float(self.finished)/self.total) * 100))
        
    def threadInitCategory(self,modulename) :
        globals_, locals_ = globals(), locals()
        subpackage = ".".join([CATEGORY_PATH, modulename])
        module = __import__(subpackage, globals_, locals_, [modulename])                       
        catInstance = getattr(module,modulename.split('_')[1])
        self.category_list_instance[modulename] = catInstance(self.CmdQueue)
        self.update_progress()
コード例 #4
0
 def onInit(self):
     from resources.lib.xbianWindow import XbianWindow
     import categories
     self.window = None
     self.category_list = categories.__all__
     self.total = len(self.category_list)
     self.category_list_instance = []
     self.finished = 0
     self.globalProgress = 0
     self.stop = False
     self.checkReboot = True
     self.wait = xbmcgui.DialogProgress()
     self.wait.create(_('XBian Config'), _('Please wait...'))
     self.wait.update(0)
     self.window = XbianWindow('SettingsXbianInfo.xml', ROOTDIR)
コード例 #5
0
 def onInit(self) :
     from resources.lib.xbianWindow import XbianWindow
     import categories        
     self.window = None
     self.category_list = categories.__all__
     self.total = len(self.category_list)
     self.category_list_instance = []
     self.finished = 0
     self.globalProgress = 0
     self.stop = False
     self.checkReboot = True
     self.wait = xbmcgui.DialogProgress()
     self.wait.create('%s %s'%(_("distribution"),_('xbian-config.main.title')),_('xbian-config.common.pleasewait'))
     self.wait.update(0)        
     self.window = XbianWindow('SettingsXbianInfo.xml',ROOTDIR)        
コード例 #6
0
ファイル: default.py プロジェクト: brantje/xbian
 def __init__(self):
     xbmc.log("XBian : XBian-config-python started")
     self.onRun = os.path.join("/", "tmp", ".xbian_config_python")
     if os.path.isfile(self.onRun):
         xbmcgui.Dialog().ok("XBian-config", "XBian-config is still running", "Please wait...")
     else:
         open(self.onRun, "w").close()
         try:
             self.CmdQueue = Queue.Queue()
             self.updateThread = Updater(self.CmdQueue)
             self.updateThread.start()
             self.wait = xbmcgui.DialogProgress()
             self.window = XbianWindow("SettingsXbianInfo.xml", ROOTDIR)
             self.category_list = []
             self.category_list_thread = []
             self.category_list_instance = {}
             self.finished = 0
             self.stop = False
             for fn in os.listdir(os.path.join(ROOTDIR, CATEGORY_PATH)):
                 if fn[0] != "_" and fn.split(".")[-1] in ("py", "pyw"):
                     modulename = fn.split(".")[0]  # filename without extension
                     self.category_list.append(modulename)
             self.category_list.sort()
             self.total = len(self.category_list)
             self.wait.create("Generating Windows", "Please wait..., this process can take up to one minute")
             self.wait.update(0)
             for module in self.category_list:
                 self.category_list_thread.append(threading.Thread(None, self.threadInitCategory, None, (module,)))
                 self.category_list_thread[-1].start()
             for i, threadInst in enumerate(self.category_list_thread):
                 if not self.stop:
                     threadInst.join()
                     try:
                         self.window.addCategory(self.category_list_instance[self.category_list[i]])
                     except:
                         xbmc.log(
                             "XBian : Cannot add category: %s \n%s"
                             % (str(self.category_list[i]), str(sys.exc_info()))
                         )
             if not self.stop:
                 self.window.doXml(
                     os.path.join(ROOTDIR, "resources", "skins", "Default", "720p", "SettingsXbianInfo.template")
                 )
                 self.wait.close()
                 self.window.doModal()
                 xbmc.log("XBian : XBian-config-python closed")
                 self.window.stopRequested = True
                 progress = dialogWait("XBian config", "Checking if reboot is needed...")
                 progress.show()
                 rebootneeded = xbianConfig("reboot")
                 progress.close()
                 if rebootneeded and rebootneeded[0] == "1":
                     if xbmcgui.Dialog().yesno("XBian-config", "A reboot is needed", "Do you want to reboot now?"):
                         # reboot
                         xbmc.executebuiltin("Reboot")
         except:
             self.window.stopRequested = True
             xbmcgui.Dialog().ok(
                 "XBian-config",
                 "Something went wrong while creating the window",
                 "Please contact us on www.xbian.org for further support",
             )
             xbmc.log("XBian : Cannot create Main window: %s" % (str(sys.exc_info())))
         finally:
             self.updateThread.stop()
             os.remove(self.onRun)
コード例 #7
0
class xbianSettingWindow(xbianSettingCommon):
    def onInit(self):
        from resources.lib.xbianWindow import XbianWindow
        import categories
        self.window = None
        self.category_list = categories.__all__
        self.total = len(self.category_list)
        self.category_list_instance = []
        self.finished = 0
        self.globalProgress = 0
        self.stop = False
        self.checkReboot = True
        self.wait = xbmcgui.DialogProgress()
        self.wait.create(_('XBian Config'), _('Please wait...'))
        self.wait.update(0)
        open(
            os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR, SKIN_RES,
                         'SettingsXbianInfo.xml'), 'w').close()
        self.window = XbianWindow('SettingsXbianInfo.xml', ROOTDIR)

    def onClean(self):
        if self.wait:
            self.wait.close()

    def onShow(self):
        for i, module in enumerate(self.category_list):
            if self.wait.iscanceled():
                self.stop = True
                break
            self.globalProgress = int(
                (float(self.finished) / (self.total)) * 100)
            self.update_progress(
                module.split('_')[1], '    %s' % (_('Initialisation...'), ), 0)
            catmodule = __import__('%s.%s' % (CATEGORY_PATH, module),
                                   globals(), locals(), [module])
            modu = getattr(catmodule, module.split('_')[-1])
            catinstance = modu(self.CmdQueue, self.update_progress)
            self.finished += 1
            if catinstance.TITLE:
                try:
                    self.window.addCategory(catinstance)
                except:
                    xbmc.log('XBian-config : Cannot add category: %s \n%s' %
                             (str(module), str(sys.exc_info())))

        if not self.stop:
            # really don't know why, all others are ok, but skindir have to be global???
            global SKIN_DIR
            global SKIN_RES
            if not os.path.isfile(
                    os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR,
                                 SKIN_RES, 'SettingsXbianInfo.template')):
                SKIN_DIR = 'Default'
            self.window.doXml(
                os.path.join(ROOTDIR, 'resources', 'skins', SKIN_DIR, SKIN_RES,
                             'SettingsXbianInfo.template'))
            self.wait.close()
            self.wait = None
            self.window.doModal()
            xbmc.log('XBian-config : XBian-config-python closed')

    def update_progress(self, categoryname, settingName, perc):
        perc = self.globalProgress + int(perc / self.total)
        self.wait.update(perc, '%s %s...' % (_('Loading'), categoryname))
        #self.wait.update(perc, '%s %s...\n%s' % (_('Loading'), categoryname, settingName))#, %s' % (settingName, ))
        xbmc.sleep(50)
コード例 #8
0
 def __init__(self) :              
     xbmc.log('XBian : XBian-config-python started')
     self.onRun = os.path.join('/','tmp','.xbian_config_python')
     self.bootMnt = os.path.ismount('/boot')
     if os.path.isfile(self.onRun) :
         xbmcgui.Dialog().ok('XBian-config','XBian-config is still running','Please wait...')
     else :      
         open(self.onRun,'w').close()
         try :            
             #mount boot if not mounted
             if not self.bootMnt :
                 xbmc.log('XBian : Mount /boot')
                 subprocess.check_call(['mount','/boot'])                    
             self.CmdQueue = Queue.Queue()
             self.updateThread = Updater(self.CmdQueue)
             self.updateThread.start()
             self.wait = xbmcgui.DialogProgress()
             self.window = XbianWindow('SettingsXbianInfo.xml',ROOTDIR)
             self.category_list = []
             self.category_list_thread = []
             self.category_list_instance = {}
             self.finished = 0
             self.stop = False
             for fn in os.listdir(os.path.join(ROOTDIR,CATEGORY_PATH)):
                 if fn[0] != '_' and fn.split('.')[-1] in ('py', 'pyw'):
                     modulename = fn.split('.')[0] # filename without extension
                     self.category_list.append(modulename)
             self.category_list.sort()
             self.total = len(self.category_list)
             self.wait.create('Generating Windows','Please wait..., this process can take up to one minute')
             self.wait.update(0)
             for module in self.category_list :
                 self.category_list_thread.append(threading.Thread(None,self.threadInitCategory, None, (module,)))
                 self.category_list_thread[-1].start()
             for i,threadInst in enumerate(self.category_list_thread):
                 if not self.stop :
                     threadInst.join()
                     try :
                         self.window.addCategory(self.category_list_instance[self.category_list[i]])
                     except:
                         xbmc.log('XBian : Cannot add category: %s \n%s'%(str(self.category_list[i]),str(sys.exc_info())))                            
             if not self.stop :
                 self.window.doXml(os.path.join(ROOTDIR,'resources','skins',SKIN_DIR,'720p','SettingsXbianInfo.template'))
                 self.wait.close()                    
                 self.window.doModal() 
                 xbmc.log('XBian : XBian-config-python closed')
                 self.window.stopRequested = True 
                 progress = dialogWait('XBian config','Checking if reboot is needed...')
                 progress.show() 
                 rebootneeded = xbianConfig('reboot')
                 progress.close()
                 if rebootneeded and rebootneeded[0] == '1' :
                     if xbmcgui.Dialog().yesno('XBian-config','A reboot is needed','Do you want to reboot now?') :
                         #reboot
                         xbmc.executebuiltin('Reboot')
         except :
             self.window.stopRequested = True            
             xbmcgui.Dialog().ok('XBian-config','Something went wrong while creating the window','Please contact us on www.xbian.org for further support')
             xbmc.log('XBian : Cannot create Main window: %s'%(str(sys.exc_info())))                            
         finally :                
             self.updateThread.stop()
             os.remove(self.onRun)                
             if not self.bootMnt :
                 xbmc.log('XBian :  unmount /boot')
                 subprocess.check_call(['umount','/boot'])