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()
def __init__(self): xbmc.log('XBian-config : started') from resources.lib.updateworker import Updater if xbianConfig('updates', 'progress')[0] != '1': setvisiblecondition('aptrunning', False) else: setvisiblecondition('aptrunning', True) self.checkReboot = False self.CmdQueue = queue.Queue() self.updateThread = Updater(self.CmdQueue) self.updateThread.start() self.onInit()
class xbianSettingCommon: def __init__(self): xbmc.log('XBian-config : started') from resources.lib.updateworker import Updater if xbianConfig('updates', 'progress')[0] != '1': setvisiblecondition('aptrunning', False) else: setvisiblecondition('aptrunning', True) self.checkReboot = False self.CmdQueue = queue.Queue() self.updateThread = Updater(self.CmdQueue) self.updateThread.start() self.onInit() def onInit(self): pass def onClean(self): pass def onShown(self): pass def _checkIsRunning(self): if os.path.isfile(LOCK_FILE): xbmcgui.Dialog().ok('XBian-config', _('XBian-config is still running'), _('Please wait...')) return False open(LOCK_FILE, 'w').close() return True def clean(self): self.updateThread.stop() self.onClean() if os.path.isfile(LOCK_FILE): os.remove(LOCK_FILE) if self.checkReboot: rebootneeded = xbianConfig('reboot') if not rebootneeded or rebootneeded[0] != '1': return if xbianConfig('updates', 'progress')[0] != '0': return if xbmcgui.Dialog().yesno( 'XBian-config', _('A reboot is required. Do you want to reboot now?')): xbmc.executebuiltin('Reboot') def show(self): if self._checkIsRunning(): self.onShow() self.clean()
class xbianSettingCommon: def __init__(self): xbmc.log('XBian : XBian-config started') from resources.lib.updateworker import Updater if xbianConfig('updates', 'progress')[0] != '1': setvisiblecondition('aptrunning', False) else: setvisiblecondition('aptrunning', True) self.checkReboot = False self.CmdQueue = Queue.Queue() self.updateThread = Updater(self.CmdQueue) self.updateThread.start() self.onInit() def onInit(self): pass def onClean(self): pass def onShown(self): pass def _checkIsRunning(self): if os.path.isfile(LOCK_FILE): xbmcgui.Dialog().ok('XBian-config', _('XBian-config is still running'), _('Please wait...')) return False open(LOCK_FILE, 'w').close() return True def clean(self): self.updateThread.stop() self.onClean() if os.path.isfile(LOCK_FILE): os.remove(LOCK_FILE) if self.checkReboot: rebootneeded = xbianConfig('reboot') if not rebootneeded or rebootneeded[0] != '1': return if xbianConfig('updates', 'progress')[0] != '0': return if xbmcgui.Dialog().yesno( 'XBian-config', _('A reboot is required. Do you want to reboot now?')): xbmc.executebuiltin('Reboot') def show(self): if self._checkIsRunning(): self.onShow() self.clean()
def __init__(self): xbmc.log('XBian : XBian-config started') from resources.lib.updateworker import Updater if xbianConfig('updates', 'progress')[0] != '1': setvisiblecondition('aptrunning', False) else: setvisiblecondition('aptrunning', True) self.checkReboot = False self.CmdQueue = Queue.Queue() self.updateThread = Updater(self.CmdQueue) self.updateThread.start() self.onInit()
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)
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'])