def setXbianValue(self, value):
        if value == True or value == 'True':
            value = '1'
        elif value == False or value == 'False':
            value = '0'
        if self.exist and value in ('0', '1'):
            #replace
            def replace(x):
                if re.match('%s=.*' % self.setting, x):
                    return re.sub('[01]', value, x, 1)
                else:
                    return x

            with open(self.cfgfile, "r") as f:
                data = list(map(replace, open(self.cfgfile, 'r').readlines()))
            with open(self.cfgfile, "w") as f:
                f.writelines(data)
        elif value in ('0', '1'):
            with open(self.cfgfile, "a") as f:
                f.write('%s=%s\n' % (self.setting, value))
        else:
            return False
        xbianConfig('services', '%s' % ('start' if value == '1' else 'stop'),
                    'transmission-daemon')
        self.OKTEXT = _('Transmission has been %s now') % (
            _('started') if value == '1' else _('stopped'))
        return True
 def onInit(self) :
     tmp = xbianConfig('packages','list')
     self.packageCatList = []        
     self.packages = {}
     for cat in tmp :
         t = cat.split(',')
         tmp_cat = {}
         tmp_cat['name'] = t[0]
         tmp_cat['available'] = int(t[1])
         tmp_cat['installed'] = int(t[2])
         self.packageCatList.append(tmp_cat)
     for packageDetails in self.packageCatList :     
         self.packages[packageDetails['name']] = {}
         self.packages[packageDetails['name']]['group'] = MultiSettingControl()
         self.packages[packageDetails['name']]['label'] = CategoryLabelControl(Tag('label',packageDetails['name'].title()))
         self.packages[packageDetails['name']]['group'].addControl(self.packages[packageDetails['name']]['label'])
         self.packages[packageDetails['name']]['list'] = []
         self.packages[packageDetails['name']]['package'] = SpinControlex(Tag('label','Package'))
         self.packages[packageDetails['name']]['group'].addControl(self.packages[packageDetails['name']]['package'])
         tmp = xbianConfig('packages','list',packageDetails['name'])            
         for packag in tmp :
             packageTmp = packag.split(',')                
             pack = Content(Tag('label',packageTmp[0]),defaultSKin=False)
             self.packages[packageDetails['name']]['package'].addContent(pack)
             package = {}
             package['group'] = MultiSettingControl(Tag('visible','Container(%d).HasFocus(%d)'%(self.packages[packageDetails['name']]['package'].getWrapListId(),pack.getId())))
             package['status'] = ButtonControl(Tag('label',' -Status'))
             package['status'].onClick = lambda status : status.setValue(self.onStatusClick(self.getCurrentPackage(status),status.getValue()))
             package['group'].addControl(package['status'])
             package['info'] = ButtonControl(Tag('label',' -Info'))
             package['info'].onClick = lambda info : self.onInfoClick(self.getCurrentPackage(info))
             package['group'].addControl(package['info'])
             self.packages[packageDetails['name']]['group'].addControl(package['group'])
             self.packages[packageDetails['name']]['list'].append(package)
         self.addControl(self.packages[packageDetails['name']]['group'])
Exemplo n.º 3
0
    def actualizeSettings(self, notify=False):
        rc = xbianConfig('updates', 'enableauto')
        if rc and rc[0] == '1':
            self.enableauto = True
        else:
            self.enableauto = False

        try:
            rc = xbianConfig('updates', 'autoinventory')
            self.deltaCheck = int(rc[0].split(' ')[1])
            if rc[0].split(' ')[0] == '0':
                self.selfCheck = True
            else:
                self.selfCheck = False

        except:
            self.deltaCheck = 1
            self.selfCheck = True

        self.timeImageDiff = self.calcTimedelta('imgplan', self.xbiancopyDone)
        self.timeHomeDiff = self.calcTimedelta('homeplan', self.backuphomeDone)

        if int(getSetting('notifywhenbusy')) == 1:
            self.notifyWhenBusy = True
        else:
            self.notifyWhenBusy = False

        if notify:
            self.settingsUpdated = True
            self.loop = 1
 def onCustom(self):
     name = getText(_('Name'))
     if not name:
         return
     self.APPLYTEXT = _('Do you want to insert %s') % (name, )
     if self.askConfirmation():
         progress = dialogWait(_('Edit'), _('Please wait...'))
         progress.show()
         service = name.split(' ')
         name = service[0]
         service.append('')
         rc = xbianConfig('services', 'insert', service[0], service[1])
         if rc and rc[0] == '1':
             # check service status
             rcs = xbianConfig('services', 'status', name)
             if rcs:
                 self.services[name] = self._parseStatus(int(rcs[0].split(' ')[1]))
                 self.control.addService(name, self.services[name][0])
                 self.OKTEXT = _(
                     'The service has successfully been inserted')
                 self.notifyOnSuccess()
             else:
                 self.ERRORTEXT = _('Failed to refresh the service...')
                 self.notifyOnError()
         elif rc and rc[0] == '-2':
             self.ERRORTEXT = _('This service does not exists...')
             self.notifyOnError()
         else:
             self.ERRORTEXT = _('An unexpected error occurred')
             self.notifyOnError()
         progress.close()
    def startManualBackup(self):
        #self.value = self.control.getValue()
        self.value = self.getXbianValue()
        if self.value[0] == 1 and getSetting('advancedmode') == '1':
            dest = xbianConfig('xbiancopy', 'homedest', 'exp')[0]
            self.keep = self.value[3]
        else:
            dest ='/xbmc-backup/%s_backup_home_%s.img.gz' % (os.uname()[1], datetime.datetime.now().strftime("%d-%m-%y"))
            self.keep = 0

        AT = self.APPLYTEXT
        self.APPLYTEXT = _('Write backup to %s?') % ('...' + dest[len(dest)-57:] if len(dest) > 60 else dest, )
        confirm = False
        if self.askConfirmation(confirm):
            xbianConfig('xbiancopy', 'homestart', dest)
            msg = [
                _('It can take several minutes depending on size of your /home directory'),
                _('If file is created under /xbian-backup, it is also accessible through smb share'),
                _('Until finished, there will be just temp folder. Once ready, .img.gz file will appear.'),
                _('You can copy the file directly to you computer (the file will be deleted during boot!)'),
                _('To restore your /home folder, just copy .img.gz file to /xbian-backup/put_to_restore folder.'),
            ]
            dlg = dialogWaitBackground(
                _('Backup /home to file'),
                msg,
                self.checkcopyFinish,
                skinvar='backuprunning',
                id=xbmcgui.getCurrentWindowId(),
                onFinishedCB=self.oncopyFinished)
            dlg.show()
        self.APPLYTEXT = AT
        return ''
    def actualizeSettings(self, notify=False):
        rc = xbianConfig('updates', 'enableauto')
        if rc and rc[0] == '1':
            self.enableauto = True
        else:
            self.enableauto = False

        try:
            rc = xbianConfig('updates', 'autoinventory')
            self.deltaCheck = int(rc[0].split(' ')[1])
            if rc[0].split(' ')[0] == '0':
                self.selfCheck = True
            else:
                self.selfCheck = False

        except:
            self.deltaCheck = 1
            self.selfCheck = True

        self.timeImageDiff = self.calcTimedelta('imgplan', self.xbiancopyDone)
        self.timeHomeDiff = self.calcTimedelta('homeplan', self.backuphomeDone)

        if getSetting('notifywhenbusy') == '1':
            self.notifyWhenBusy = True
        else:
            self.notifyWhenBusy = False

        if notify:
            self.settingsUpdated = True
            self.loop = 10
    def getXbianValue(self):
        #value = [
        #  1/0,   #auto backup enable
        #  'Device'/'File',   #system destination type - if change need to be modif on content
        #  'UUID'/'backup_dir', #system Path
        #  BACKUP_PROFILE[x]#system backup delta
        # ]

        #TODO
        #read default Value from file here
        #value is like [1,'File','/home/belese/','Daily']
        if xbianConfig('xbiancopy','imgtype')[0] == 'file' :
           imgtype = 'File'
        else :
           imgtype = 'Device'
        delta = xbianConfig('xbiancopy','imgplan')
        if delta and delta[0] in BACKUP_PROFILE :
            delta = delta[0]
            actif = 1
        else :
            delta = BACKUP_PROFILE[0]
            actif = 0
        dest = xbianConfig('xbiancopy','imgdest')
        if dest :
            dest = dest[0]
        else :
            dest = ''
        return [actif,imgtype,dest,delta]
 def onSelect(self,cat,package) :        
     choice = ['Informations','Remove Package']
     select = self.dialog.select('Select',choice)
     if select == 0 :
         #display info dialog
         self.showInfo(package)
     elif select == 1 :
         #remove package
         self.APPLYTEXT = _('xbian-config.packages.remove.confirm')
         if self.askConfirmation(True) :
             self.tmppack = (cat,package)
             progressDlg = dialogWait(_('xbian-config.packages.label.remove'),_('xbian-config.common.pleasewait'))
             progressDlg.show()
             rc = xbianConfig('packages','removetest',package)
             if rc and rc[0] == '1' :
                rc = xbianConfig('packages','remove',package)
                if rc and rc[0] == '1' :
                    progressDlg.close()
                    dlg = dialogWaitBackground(self.DIALOGHEADER,[],self.checkInstallFinish,APTLOGFILE,skinvar=SKINVARAPTRUNNIG,onFinishedCB=self.onRemoveFinished)
                    dlg.show()
             else :
                 if rc and rc[0] == '2' :
                      #normally never pass here
                      self.ERRORTEXT = _('xbian-config.packages.not_installed')
                 elif rc and rc[0] == '3' :
                      self.ERRORTEXT = _('xbian-config.packages.essential')
                 else :
                      #normally never pass here
                      self.ERRORTEXT = _('xbian-config.dialog.unexpected_error')
                 progressDlg.close()
                 self.notifyOnError()
Exemplo n.º 9
0
 def onCustom(self):
     name = getText(_('Name'))
     if not name:
         return
     self.APPLYTEXT = _('Do you want to insert %s') % (name, )
     if self.askConfirmation():
         progress = dialogWait(_('Edit'), _('Please wait...'))
         progress.show()
         service = name.split(' ')
         name = service[0]
         service.append('')
         rc = xbianConfig('services', 'insert', service[0], service[1])
         if rc and rc[0] == '1':
             # check service status
             rcs = xbianConfig('services', 'status', name)
             if rcs:
                 self.services[name] = self._parseStatus(int(rcs[0].split(' ')[1]))
                 self.control.addService(name, self.services[name][0])
                 self.OKTEXT = _(
                     'The service has successfully been inserted')
                 self.notifyOnSuccess()
             else:
                 self.ERRORTEXT = _('Failed to refresh the service...')
                 self.notifyOnError()
         elif rc and rc[0] == '-2':
             self.ERRORTEXT = _('This service does not exists...')
             self.notifyOnError()
         else:
             self.ERRORTEXT = _('An unexpected error occurred')
             self.notifyOnError()
         progress.close()
Exemplo n.º 10
0
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER,_('xbian-config.snapshot.loadingvolume'))
     load.show()
     volumeList = xbianConfig('listvol',cmd=['sudo','btrfs-auto-snapshot'])
     load.close()
     volumeList = list(set(volumeList)-set(self.BLAKLISTVOLUME))
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop :
         volId = dialog.select(_('xbian-config.snapshot.volume'),volumeList)
         if volId == -1 :
            have_to_stop = True
         else :
             load = dialogWait(self.DIALOGHEADER,_('xbian-config.common.pleasewait'))
             load.show()
             snapshotList = xbianConfig('list',volumeList[volId],cmd=['sudo','btrfs-auto-snapshot'])
             snapshotList = filter(lambda x : x.split('@')[1],snapshotList)
             load.close()
             snapId = dialog.select('Snapshot',map(lambda x : x.split('@')[1],snapshotList))
             if snapId != -1 and self.askConfirmation() :
                 try :
                     dlg = dialogWait(self.DIALOGHEADER,self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(volumeList[volId],snapshotList[snapId])                        
                 except :
                     print 'error running btrfs-auto-spashot command %s %s'%(volumeList[volId],snapshotList[snapId])
                 finally :
                     have_to_stop = True
                     dlg.close()
     return ''
Exemplo n.º 11
0
 def addService(self,name) :
     self.control.setCustom(name)                   
     #wait.update(line2='Refreshing Value')
     serviceStatus = xbianConfig('services','status')
     for service in serviceStatus :
         status = service.split(' ')
         if status[0] == name :  
            running = False
            autostart = False
            if status[1] == '3' :
               autostart = True
            elif status[1] == '4' :
               running = True
            elif status[1] == '5' :
               running = True
               autostart = True
            #get dameon:
            daemon = xbianConfig('services','select',status[0])
            if daemon :
               daemon = daemon[0]
            else :
               daemon = False
            self.xbianValue[status[0]] = [running,autostart,daemon]
            self.setControlValue({status[0]:[running,autostart,daemon]})
            break
     self.control.setVisible(name,True)
     self.serviceInstalled.append(status[0])
    def getXbianValue(self):
        distup = False
        rc = xbianConfig('updates', 'distupgrade', 'query')
        if rc and not (rc[0] == '0'):
            self.control.switchDistribution.setLabel(_('Distribution upgrade to %s') % (rc[0]))
            setvisiblecondition(self.control.keyswitchdistribution, True)
            distup = True
        else:
            setvisiblecondition(self.control.keyswitchdistribution, False, xbmcgui.getCurrentWindowId())
        if self.xbianValue:
            # make sure that entire list is cleaned and hidden
            for update in self.xbianValue:
                self.control.removeUpdate(update)
            self.control.nbcanbeupdate = 0
        rc = xbianConfig('updates', 'list', self.key, cache=False, forcerefresh=self.needrefreshing)
        if rc and not (rc[0] < '1'):
            # (re)build list
            for update in rc[:15]:
                self.control.addUpdate(update)
        elif not distup:
            self.control.updateNo.setLabel(_('Update_to_date'))
        self.needrefreshing = False

        setvisiblecondition(KEYFORCECHECK, True)
        return rc
Exemplo n.º 13
0
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER, _('Loading volumes...'))
     load.show()
     mountList = xbianConfig('mount', '--helper', cmd=['sudo', 'btrfs-auto-snapshot'])
     sep = xbianConfig('fstype', cmd=['sudo', 'btrfs-auto-snapshot'])[1]
     load.close()
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop:
         #volId = dialog.select(_('Btrfs volume'), [x.split(sep)[0] for x in mountList])
         volId = dialog.select(_('Btrfs volume'), list(map(lambda x: x.split(sep)[0], mountList)))
         if volId == -1:
             have_to_stop = True
         else:
             #selectedVolume = [x.split(sep)[0] for x in mountList][volId]
             #mountItems = [x for x in mountList if selectedVolume + sep in x]
             #snapId = dialog.select('Snapshot', [x.split(sep)[1] for x in mountItems])
             selectedVolume = list(map(lambda x: x.split(sep)[0], mountList))[volId]
             mountItems = list(filter(lambda x: selectedVolume + sep in x, mountList))
             snapId = dialog.select('Snapshot', list(map(lambda x: x.split(sep)[1], mountItems)))
             if snapId != -1 and self.askConfirmation():
                 try:
                     dlg = dialogWait(self.DIALOGHEADER, self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(selectedVolume, mountItems[snapId])
                 except:
                     print('error running btrfs-auto-spashot command %s' % (mountItems[snapId]))
                 finally:
                     have_to_stop = True
                     dlg.close()
     return ''
Exemplo n.º 14
0
    def getXbianValue(self):
        distup = False
        rc = xbianConfig('updates', 'distupgrade', 'query')
        if rc and not (rc[0] == '0'):
            self.control.switchDistribution.setLabel(
                _('Distribution upgrade to %s') % (rc[0]))
            setvisiblecondition(self.control.keyswitchdistribution, True)
            distup = True
        else:
            setvisiblecondition(self.control.keyswitchdistribution, False,
                                xbmcgui.getCurrentWindowId())
        if self.xbianValue:
            # make sure that entire list is cleaned and hidden
            for update in self.xbianValue:
                self.control.removeUpdate(update)
            self.control.nbcanbeupdate = 0
        rc = xbianConfig('updates',
                         'list',
                         self.key,
                         cache=False,
                         forcerefresh=self.needrefreshing)
        if rc and not (rc[0] < '1'):
            # (re)build list
            for update in rc[:15]:
                self.control.addUpdate(update)
        elif not distup:
            self.control.updateNo.setLabel(_('Update_to_date'))
        self.needrefreshing = False

        setvisiblecondition(KEYFORCECHECK, True)
        return rc
Exemplo n.º 15
0
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER, _('Loading volumes...'))
     load.show()
     volumeList = xbianConfig('listvol', '--exclude=%s' % self.EXCLUDE, cmd=['sudo', 'btrfs-auto-snapshot'])
     load.close()
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop:
         volId = dialog.select(_('Btrfs volume'), volumeList)
         if volId == -1:
             have_to_stop = True
         else:
             load = dialogWait(self.DIALOGHEADER, _('Please wait...'))
             load.show()
             snapshotList = xbianConfig(
                 'list', volumeList[volId], cmd=['sudo', 'btrfs-auto-snapshot'])
             #snapshotList = [x for x in snapshotList if x.split('@')[1]]
             snapshotList = list(filter(lambda x: x.split('@')[1], snapshotList))
             load.close()
             #snapId = dialog.select('Snapshot', [x.split('@')[1] for x in snapshotList])
             snapId = dialog.select('Snapshot', list(map(lambda x: x.split('@')[1], snapshotList)))
             if snapId != -1 and self.askConfirmation():
                 try:
                     dlg = dialogWait(self.DIALOGHEADER, self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(volumeList[volId], snapshotList[snapId])
                 except:
                     print('error running btrfs-auto-spashot command %s %s' % (volumeList[volId], snapshotList[snapId]))
                 finally:
                     have_to_stop = True
                     dlg.close()
     return ''
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER, _('Loading volumes...'))
     load.show()
     mountList = xbianConfig('mount', '--helper', cmd=['sudo', 'btrfs-auto-snapshot'])
     sep = xbianConfig('fstype', cmd=['sudo', 'btrfs-auto-snapshot'])[1]
     load.close()
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop:
         volId = dialog.select(_('Btrfs volume'), map(lambda x: x.split(sep)[0], mountList))
         if volId == -1:
             have_to_stop = True
         else:
             selectedVolume = map(lambda x: x.split(sep)[0], mountList)[volId]
             mountItems = filter(lambda x: selectedVolume + sep in x, mountList)
             snapId = dialog.select('Snapshot', map(lambda x: x.split(sep)[1], mountItems))
             if snapId != -1 and self.askConfirmation():
                 try:
                     dlg = dialogWait(self.DIALOGHEADER, self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(selectedVolume, mountItems[snapId])
                 except:
                     print 'error running btrfs-auto-spashot command %s' % (mountItems[snapId])
                 finally:
                     have_to_stop = True
                     dlg.close()
     return ''
Exemplo n.º 17
0
    def startManualBackup(self):
        #self.value = self.control.getValue()
        self.value = self.getXbianValue()
        if self.value[0] == 1 and int(getSetting('advancedmode')) == 1:
            dest = xbianConfig('xbiancopy', 'homedest', 'exp')[0]
            self.keep = int(self.value[3])
        else:
            dest ='/xbmc-backup/%s_backup_home_%s.img.gz' % (os.uname()[1], datetime.datetime.now().strftime("%d-%m-%y"))
            self.keep = 0

        AT = self.APPLYTEXT
        self.APPLYTEXT = _('Write backup to %s?') % ('...' + dest[len(dest)-57:] if len(dest) > 60 else dest, )
        confirm = False
        if self.askConfirmation(confirm):
            xbianConfig('xbiancopy', 'homestart', dest)
            msg = [
                _('It can take several minutes depending on size of your /home directory'),
                _('If file is created under /xbmc-backup, it is also accessible through smb share'),
                _('Until finished, there will be just temp folder. Once ready, .img.gz file will appear.'),
                _('You can copy the file directly to you computer (the file will be deleted during boot!)'),
                _('To restore your /home folder, just copy .img.gz file to /xbmc-backup/put_to_restore folder.'),
            ]
            dlg = dialogWaitBackground(
                _('Backup /home to file'),
                msg,
                self.checkcopyFinish,
                skinvar='backuprunning',
                id=xbmcgui.getCurrentWindowId(),
                onFinishedCB=self.oncopyFinished)
            dlg.show()
        self.APPLYTEXT = AT
        return ''
Exemplo n.º 18
0
 def getXbianValue(self):
     # value = [
     #  1/0,                 # /home backup enable
     #  'backup_filepath',   # /home file incl. path
     #  BACKUP_PROFILE[x],   # /home backup delta
     #  n                    # /home number of images to keep
     # ]
     delta = xbianConfig('xbiancopy', 'homeplan')
     if delta and delta[0] in BACKUP_PROFILE:
         delta = delta[0]
         actif = 1
     else:
         delta = BACKUP_PROFILE[0]
         actif = 0
     dest = xbianConfig('xbiancopy', 'homedest')
     if dest:
         dest = dest[0]
     else:
         dest = ''
     num = xbianConfig('xbiancopy', 'homekeep')
     if num:
         num = num[0]
     else:
         num = 0
     return [actif, dest, delta, num]
    def onStart(self):
        # check is packages is updating
        if os.path.isfile('/var/lock/.packages'):
            if xbianConfig('updates', 'progress')[0] == '1':
                dlg = dialogWait('XBian' + ' ' +_('Update'), _('Please wait while updating'))
                dlg.show()
                while not self.StopRequested and xbianConfig('updates', 'progress')[0] == '1':
                    xbmc.sleep(300)
                dlg.close()
                if self.StopRequested:
                    return
            xbmc.executebuiltin("Notification(%s, %s)" % (_('Package') + ' ' + _('Update'), _('Updates installed successfully')))
            os.remove('/var/lock/.packages')

        if xbianConfig('updates', 'progress')[0] != '1':
            setvisiblecondition('aptrunning', False)

        while not self.StopRequested:  # End if XBMC closes
            self.onIdle()
            if self.loop == 0:
                self.loop = 600
            while not self.StopRequested and self.loop > 0:
                xbmc.sleep(500)  # Repeat (ms)
                self.loop = self.loop - 1

        xbianConfig() # Relese resources
        print 'XBian-config : xbianworker service finished'
Exemplo n.º 20
0
 def getXbianValue(self):
     # value = [
     #  1/0,                 # auto backup enable
     #  'Device'/'File',     # system destination type - if change need to be modif on content
     #  'UUID'/'backup_dir', # system Path
     #  BACKUP_PROFILE[x],   # system backup delta
     #  n                    # system number of images to keep
     # ]
     if xbianConfig('xbiancopy', 'imgtype')[0] == 'file':
         imgtype = 'File'
     else:
         imgtype = 'Device'
     delta = xbianConfig('xbiancopy', 'imgplan')
     if delta and delta[0] in BACKUP_PROFILE:
         delta = delta[0]
         actif = 1
     else:
         delta = BACKUP_PROFILE[0]
         actif = 0
     dest = xbianConfig('xbiancopy', 'imgdest')
     if dest:
         dest = dest[0]
     else:
         dest = ''
     num = xbianConfig('xbiancopy', 'imgkeep')
     if num:
         num = num[0]
     else:
         num = 0
     return [actif, imgtype, dest, delta, num]
Exemplo n.º 21
0
    def startManualBackup(self):
        #self.value = self.control.getValue()
        self.value = self.getXbianValue()
        AT = self.APPLYTEXT
        if self.value[1] == 'File':
            self.value[2] = 'file:' + self.value[2]
            dest = xbianConfig('xbiancopy', 'imgdest', 'exp')[0]
            self.APPLYTEXT = _('Write backup to %s?') % ('...' + dest[len(dest)-57:] if len(dest) > 60 else dest, )
            confirm = False
            self.keep = int(self.value[4])
        else:
            self.APPLYTEXT = _('This will erase ALL data on %s, continue?') % (
                self.value[2], )
            confirm = True
            self.keep = 0

        if self.askConfirmation(confirm):
            xbianConfig('xbiancopy', 'start', '/dev/root', self.value[2])
            dlg = dialogWaitBackground(
                _('XBian System Backup'), [_('Please wait while creating backup file')],
                self.checkcopyFinish,
                SYSTEMLOGFILE,
                skinvar='backuprunning',
                id=xbmcgui.getCurrentWindowId(),
                onFinishedCB=self.oncopyFinished)
            dlg.show()
        self.APPLYTEXT = AT
        return ''
Exemplo n.º 22
0
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER, _('Loading volumes...'))
     load.show()
     volumeList = xbianConfig('listvol', '--exclude=%s' % self.EXCLUDE, cmd=['sudo', 'btrfs-auto-snapshot'])
     try:
         self.fstype = xbianConfig('fstype', cmd=['sudo', 'btrfs-auto-snapshot'])[0] + '-'
     except:
         self.fstype=''
     load.close()
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop:
         volId = dialog.select('Volume', volumeList)
         if volId == -1:
             have_to_stop = True
         else:
             snapshot = getText(
                 _('Snapshot name'),
                 '%suser-snap-%s' % (
                     self.fstype, datetime.datetime.now().strftime("%Y-%m-%d-%H%M"), ))
             if snapshot and self.askConfirmation():
                 try:
                     dlg = dialogWait(self.DIALOGHEADER, self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(volumeList[volId], snapshot)
                 except:
                     print('error running btrfs-auto-spashot command %s %s' % (volumeList[volId], snapshot))
                 finally:
                     have_to_stop = True
                     dlg.close()
     return ''
 def getXbianValue(self):
     # value = [
     #  1/0,                 # auto backup enable
     #  'Device'/'File',     # system destination type - if change need to be modif on content
     #  'UUID'/'backup_dir', # system Path
     #  BACKUP_PROFILE[x],   # system backup delta
     #  n                    # system number of images to keep
     # ]
     if xbianConfig('xbiancopy', 'imgtype')[0] == 'file':
         imgtype = 'File'
     else:
         imgtype = 'Device'
     delta = xbianConfig('xbiancopy', 'imgplan')
     if delta and delta[0] in BACKUP_PROFILE:
         delta = delta[0]
         actif = 1
     else:
         delta = BACKUP_PROFILE[0]
         actif = 0
     dest = xbianConfig('xbiancopy', 'imgdest')
     if dest:
         dest = dest[0]
     else:
         dest = ''
     num = xbianConfig('xbiancopy', 'imgkeep')
     if num:
         num = num[0]
     else:
         num = 0
     return [actif, imgtype, dest, delta, num]
Exemplo n.º 24
0
    def onStart(self):
        # check is packages is updating
        if os.path.isfile('/var/lock/.packages'):
            if xbianConfig('updates', 'progress')[0] == '1':
                dlg = dialogWait('XBian Update', 'Please wait while updating')
                dlg.show()
                while not self.StopRequested and xbianConfig('updates', 'progress')[0] == '1':
                    xbmc.sleep(300)
                dlg.close()
                if self.StopRequested:
                    return
            xbmc.executebuiltin("Notification(%s,%s)" %
                                ('Package Update', 'Updates installed successfully'))
            os.remove('/var/lock/.packages')

        if xbianConfig('updates', 'progress')[0] != '1':
            setvisiblecondition('aptrunning', False)

        # for those one who deactivate its screensaver, force check every deltaCheck days
        if self.selfCheck and (getSetting('lastupdatecheck') == None or getSetting(
                'lastupdatecheck') < datetime.now() - timedelta(days=self.deltaCheck)):
            print 'XBian : screensaver is disabled, running internal updates'
            self.onScreensaverActivated()
            self.onScreensaverDeactivated()

        while not self.StopRequested:  # End if XBMC closes
            self.x = 0
            while not self.StopRequested and self.x < 600:
                xbmc.sleep(500)  # Repeat (ms)
                self.x = self.x + 1

            self.onIdle()

        print 'XBian : upgrade service finished'
 def getUserValue(self):
     load = dialogWait(self.DIALOGHEADER, _('Loading volumes...'))
     load.show()
     volumeList = xbianConfig('listvol', '--exclude=%s' % self.EXCLUDE, cmd=['sudo', 'btrfs-auto-snapshot'])
     try:
         self.fstype = xbianConfig('fstype', cmd=['sudo', 'btrfs-auto-snapshot'])[0] + '-'
     except:
         self.fstype=''
     load.close()
     have_to_stop = False
     dialog = xbmcgui.Dialog()
     while not have_to_stop:
         volId = dialog.select('Volume', volumeList)
         if volId == -1:
             have_to_stop = True
         else:
             snapshot = getText(
                 _('Snapshot name'),
                 '%suser-snap-%s' % (
                     self.fstype, datetime.datetime.now().strftime("%Y-%m-%d-%H%M"), ))
             if snapshot and self.askConfirmation():
                 try:
                     dlg = dialogWait(self.DIALOGHEADER, self.PROGRESSTEXT)
                     dlg.show()
                     self.runCmd(volumeList[volId], snapshot)
                 except:
                     print 'error running btrfs-auto-spashot command %s %s' % (volumeList[volId], snapshot)
                 finally:
                     have_to_stop = True
                     dlg.close()
     return ''
 def onGetMore(self, cat):
     progress = dialogWait(cat, _('Downloading remote package database...'))
     progress.show()
     tmp = xbianConfig('packages', 'list', cat)
     if tmp and tmp[0] == '-3':
         rc = xbianConfig('packages', 'updatedb')
         if rc[0] == '1':
             tmp = xbianConfig('packages', 'list', cat)
         else:
             tmp = []
     progress.close()
     if tmp[0] != '-2' and tmp[0] != '-3':
         packages = []
         for packag in tmp:
             packageTmp = packag.split(',')
             if packageTmp[1] == '0':
                 packages.append(packageTmp[0])
         select = self.dialog.select(_('Packages'), packages)
         if select != -1:
             package = packages[select]
             choice = [_('Information'), _('Install')]
             sel = self.dialog.select('Select', choice)
             if sel == 0:
                 # display info dialog
                 self.showInfo(package)
             elif sel == 1:
                 # install package
                 self.installPackage(cat, package)
    def startManualBackup(self):
        #self.value = self.control.getValue()
        self.value = self.getXbianValue()
        AT = self.APPLYTEXT
        if self.value[1] == 'File':
            self.value[2] = 'file:' + self.value[2]
            dest = xbianConfig('xbiancopy', 'imgdest', 'exp')[0]
            self.APPLYTEXT = _('Write backup to %s?') % ('...' + dest[len(dest)-57:] if len(dest) > 60 else dest, )
            confirm = False
            self.keep = self.value[4]
        else:
            self.APPLYTEXT = _('This will erase ALL data on %s, continue?') % (
                self.value[2], )
            confirm = True
            self.keep = 0

        if self.askConfirmation(confirm):
            xbianConfig('xbiancopy', 'start', '/dev/root', self.value[2])
            dlg = dialogWaitBackground(
                _('XBian System Backup'), [_('Please wait while creating backup file')],
                self.checkcopyFinish,
                SYSTEMLOGFILE,
                skinvar='backuprunning',
                id=xbmcgui.getCurrentWindowId(),
                onFinishedCB=self.oncopyFinished)
            dlg.show()
        self.APPLYTEXT = AT
        return ''
 def onCustom(self):
     name = getText(_('xbian-config.services.label.name'))
     if not name :
         return
     self.APPLYTEXT = _('xbian-config.services.label.confirminsert')%name
     if self.askConfirmation() :
        progress = dialogWait(_('xbian-config.services.label.edit'),_('xbian-config.common.pleasewait'))
        progress.show() 
        rc = xbianConfig('services','insert',name)                                            
        if rc and rc[0] == '1' :
            #check service status
            rcs = xbianConfig('services','status',name)
            if rcs :
                self.services[name] = self._parseStatus(int(rcs[0].split(' ')[1]))                                  
                self.control.addService(name,self.services[name][0])
                self.OKTEXT = _('xbian-config.services.inserted')
                self.notifyOnSuccess()
            else :
                self.ERRORTEXT = _('xbian-config.services.refresh')
                self.notifyOnError()  
        elif rc and rc[0] == '-2':           
            self.ERRORTEXT = _('xbian-config.services.not_exists')
            self.notifyOnError()
        else :
            self.ERRORTEXT = _('xbian-config.dialog.unexpected_error')
            self.notifyOnError()                            
        progress.close()         
 def onGetMore(self, cat):
     progress = dialogWait(cat, _('Downloading remote package database...'))
     progress.show()
     tmp = xbianConfig('packages', 'list', cat)
     if tmp and tmp[0] == '-3':
         rc = xbianConfig('packages', 'updatedb')
         if rc[0] == '1':
             tmp = xbianConfig('packages', 'list', cat)
         else:
             tmp = []
     progress.close()
     if tmp[0] != '-2' and tmp[0] != '-3':
         packages = []
         for packag in tmp:
             packageTmp = packag.split(',')
             if packageTmp[1] == '0':
                 packages.append(packageTmp[0])
         select = self.dialog.select(_('Packages'), packages)
         if select != -1:
             package = packages[select]
             choice = [_('Information'), _('Install')]
             sel = self.dialog.select('Select', choice)
             if sel == 0:
                 # display info dialog
                 self.showInfo(package)
             elif sel == 1:
                 # install package
                 self.installPackage(cat, package)
Exemplo n.º 30
0
    def onStart(self):
        #check if Xbian is upgrading
        if os.path.isfile('/var/lock/.upgrades') :
            if xbianConfig('updates','progress')[0] == '1':
                dlg = dialogWait('XBian Update','Please wait while updating')
                dlg.show()
                while not self.StopRequested and xbianConfig('updates','progress')[0] == '1':
                    xbmc.sleep(2000)
                dlg.close()
                if self.StopRequested :
                    return              
            xbmc.executebuiltin("Notification(%s,%s)"%('XBian Upgrade','XBian was updated successfully'))
            os.remove('/var/lock/.upgrades')
        
        #check is packages is updating
        if os.path.isfile('/var/lock/.packages') :
            if xbianConfig('updates','progress')[0] == '1':
                dlg = dialogWait('XBian Update','Please wait while updating')
                dlg.show()
                while not self.StopRequested and xbianConfig('updates','progress')[0] == '1':
                    xbmc.sleep(2000)
                dlg.close()
                if self.StopRequested :
                    return              
            xbmc.executebuiltin("Notification(%s,%s)"%('Package Update','Package was updated successfully'))
            os.remove('/var/lock/.packages')
        #for those one who deactivate its screensaver, force check every 10 days
        if getSetting('lastupdatecheck') != None and getSetting('lastupdatecheck') < datetime.now() - timedelta(days=10):
			self.onScreensaverActivated()
			self.onScreensaverDeactivated()
        while not self.StopRequested: #End if XBMC closes
            xbmc.sleep(100) #Repeat (ms) 
Exemplo n.º 31
0
 def addService(self,name) :
     self.control.setCustom(name)                   
     #wait.update(line2='Refreshing Value')
     serviceStatus = xbianConfig('services','status')
     for service in serviceStatus :
         status = service.split(' ')
         if status[0] == name :  
            running = False
            autostart = False
            if status[1] == '3' :
               autostart = True
            elif status[1] == '4' :
               running = True
            elif status[1] == '5' :
               running = True
               autostart = True
            #get dameon:
            daemon = xbianConfig('services','select',status[0])
            if daemon :
               daemon = daemon[0]
            else :
               daemon = False
            self.xbianValue[status[0]] = [running,autostart,daemon]
            self.setControlValue({status[0]:[running,autostart,daemon]})
            break
     self.control.setVisible(name,True)
     self.serviceInstalled.append(status[0])
 def getXbianValue(self):
     # value = [
     #  1/0,                 # /home backup enable
     #  'backup_filepath',   # /home file incl. path
     #  BACKUP_PROFILE[x],   # /home backup delta
     #  n                    # /home number of images to keep
     # ]
     delta = xbianConfig('xbiancopy', 'homeplan')
     if delta and delta[0] in BACKUP_PROFILE:
         delta = delta[0]
         actif = 1
     else:
         delta = BACKUP_PROFILE[0]
         actif = 0
     dest = xbianConfig('xbiancopy', 'homedest')
     if dest:
         dest = dest[0]
     else:
         dest = ''
     num = xbianConfig('xbiancopy', 'homekeep')
     if num:
         num = num[0]
     else:
         num = 0
     return [actif, dest, delta, num]
Exemplo n.º 33
0
 def onUpdate(self, updateId):
     self.updateId = str(updateId)
     if self.updateId == '+':
         self.APPLYTEXT = _(
             'Are you sure you want to do an Distritubion upgrade?\n\nThis will take a long time'
         )
     else:
         self.APPLYTEXT = _(
             'Are you sure you want to update these packages?')
     if self.askConfirmation(True):
         self.lockfile = '/var/lock/.%s' % self.key
         open(self.lockfile, 'w').close()
         setvisiblecondition(SKINVARAPTRUNNIG, True)
         if self.updateId == '+':
             progress = dialogWait(
                 _('Please wait...'),
                 _('Retrieving list of upgradeable packages...'))
             progress.show()
             rc = xbianConfig('updates', 'distupgrade', 'prepare')
             if rc and rc[0] == '1':
                 rc = xbianConfig('updates', 'distupgrade', 'execute')
             progress.close()
         else:
             rc = xbianConfig('updates', 'install', self.key, self.updateId)
         setvisiblecondition(SKINVARAPTRUNNIG, False)
         if rc and rc[0] == '1':
             self.needrefreshing = True
             self.checkStatus = True
             dlg = dialogWaitBackground(self.DIALOGHEADER, [],
                                        self.checkUpdateFinish,
                                        APTLOGFILE,
                                        skinvar=SKINVARAPTRUNNIG,
                                        id=xbmcgui.getCurrentWindowId(),
                                        onFinishedCB=self.onUpdateFinished)
             dlg.show()
         else:
             if rc and rc[0] == '2':
                 self.ERRORTEXT = _(
                     'The latest versions of these packages are already installed'
                 )
             elif rc and rc[0] == '3':
                 self.ERRORTEXT = _(
                     'The packages you are trying to install could not be found'
                 )
             elif rc and rc[0] == '4':
                 self.ERRORTEXT = _(
                     'The packages you are trying to install could not be found'
                 )
             elif rc and rc[0] == '5':
                 self.ERRORTEXT = _(
                     'There is a size mismatch for the remote packages')
             elif rc and rc[0] == '6':
                 self.ERRORTEXT = _(
                     'A serious error occured while processing these packages'
                 )
             else:
                 self.ERRORTEXT = _('An unexpected error occurred')
             os.remove(self.lockfile)
             self.notifyOnError()
    def onIdle(self):
        self.eventTime = datetime.now()

        # for those one who deactivate its screensaver, force check for refresh every 3 hours
        if self.forceRefresh or self.refreshNext < self.eventTime:
            self.doRefresh(True)
            return

        if self.settingsUpdated:
            xbmc.executebuiltin('Notification(' + _('Service') + ' XBianWorker' + ', ' + _('%s successfully updated') % (_('Service'),) +')')
            self.settingsUpdated = False

        if self.inScreenSaver or self.StopRequested or (not self.notifyWhenBusy and xbmc.Player().isPlaying()):
            return

        if self.msgcount > 0:
            self.showMessage(self.msgheader[self.msgdisp], self.msgcontent[self.msgdisp])
            self.msgdisp += 1
            if self.msgdisp < self.msgcount:
                self.loop = 10
            else:
                self.msgcount = 0
                self.msgdisp = 0
            return

        if os.path.isfile('/tmp/.xbian_config_python'):
            return

        if self.rebootPending:
            rebootneeded = xbianConfig('reboot')
            if rebootneeded and rebootneeded[0] == '1':
                stillrunning = xbianConfig('updates', 'progress')
                if stillrunning and stillrunning[0] == '0':
                    self.showRebootDialog()
                    return

        if not self.hideUpgradeNotify and self.upgradePending:
            rc = xbianConfig('updates', 'distupgrade', 'query')
            if rc and rc[0] <> '0':
                self.hideUpgradeNotify = self.showHint( _('Update') + ': ' + _('Distribution'), _('A distribution upgrade to %s is available') % (rc[0]), 'hide.upgradenotify')
            else:
                self.hideUpgradeNotify = False
            self.upgradePending = False
            return

        if not self.hideUpdatesAvailable and self.updatesAvailable:
            self.hideUpdatesAvailable = self.showHint( _('Package') + ' ' + _('Update'), _('Some XBian package can be updated'), 'hide.updates')
            self.updatesAvailable = False
            return

        if self.xbiancopyDate is not None:
            if not self.hideImageWarning and self.xbiancopyDate < (self.eventTime - self.timeImageDiff):
                self.hideImageWarning = self.showHint(_('System backup'), _('This type of backup has not been made for a long time!'), 'hide.xbiancopy')
                return

        if self.backuphomeDate is not None and self.xbiancopyDate is not None:
            if not self.hideHomeWarning and self.backuphomeDate < (self.eventTime - self.timeHomeDiff) and self.xbiancopyDate < (self.eventTime - self.timeImageDiff):
                self.hideHomeWarning = self.showHint(_('Home backup'), _('This type of backup has not been made for a long time!'), 'hide.backuphome')
                return
Exemplo n.º 35
0
 def getXbianValue(self):
     overclock = xbianConfig('overclocking', 'select')
     value = xbianConfig('overclocking', 'values')
     if overclock and value:
         overclock.extend(value[0].split(' '))
         return overclock
     else:
         return []
Exemplo n.º 36
0
 def setXbianValue(self, value):
     xbianConfig('xbmc', 'exitoff', str(value[2]))
     rc = xbianConfig('xbmc', 'tvoff', str(value[0]), str(value[3]),
                      str(value[1]))
     if rc and rc[0] == '1':
         return True
     else:
         return False
Exemplo n.º 37
0
 def getXbianValue(self):
     overclock = xbianConfig("overclocking", "select")
     value = xbianConfig("overclocking", "values")
     if overclock and value:
         overclock.extend(value[0].split(" "))
         return overclock
     else:
         return []
Exemplo n.º 38
0
 def getXbianValue(self):
     overclock =xbianConfig('overclocking','select')
     value = xbianConfig('overclocking','values')       
     if overclock and value:
         overclock.extend(value[0].split(' '))          
         return overclock
     else :
         return []                
Exemplo n.º 39
0
 def onInit(self) :
     self.interface = SpinControlex(Tag('label',_('xbian-config.network.interfaces.select')))
     self.addControl(self.interface)
     self.interfacelist = xbianConfig('network','list')
     self.interfaceValue = {}        
     
     for interface in self.interfacelist :
          self.interfaceValue[interface] = {}
          self.interfaceValue[interface]['content'] = Content(Tag('label',interface),defaultSKin=False)
          self.interface.addContent(self.interfaceValue[interface]['content'])
          
          #create the interface group             
          self.interfaceValue[interface]['group'] = MultiSettingControl(Tag('visible','StringCompare(Skin.String(%s),%s)'%(self.interface.getKey(),interface)))
          #self.interfaceValue[interface]['group'] = MultiSettingControl()
          self.addControl(self.interfaceValue[interface]['group'])
          
          #add status control
          self.interfaceValue[interface]['status'] = ButtonControl(Tag('label',' -%s'%_('xbian-config.network.label.status')))
          self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['status'])
          
          #check if Wifi
          self.interfaceValue[interface]['wifi'] = False
          if xbianConfig('network','type',interface)[0] == '1':
              self.interfaceValue[interface]['wifi'] = True
              self.interfaceValue[interface]['ssid'] = ButtonControl(Tag('label',' -%s'%_('xbian-config.network.label.ssid')))
              self.interfaceValue[interface]['ssid'].onClick = lambda wifi : self.wifi(interface) 
              self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['ssid'])
              
          
          #add interface mode Control (static/dhcp)
          self.interfaceValue[interface]['mode'] = SpinControlex(Tag('label',' -%s'%_('xbian-config.network.label.type')))
          dhcp = Content(Tag('label',self.DHCP),defaultSKin=False)
          static = Content(Tag('label',self.STATIC),defaultSKin=False)
          self.interfaceValue[interface]['mode'].addContent(dhcp)
          self.interfaceValue[interface]['mode'].addContent(static)
          self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['mode'])
          
          #add Static Group
          self.interfaceValue[interface]['staticgroup'] = MultiSettingControl(Tag('visible','StringCompare(Skin.String(%s),%s)'%(self.interfaceValue[interface]['mode'].getKey(),self.STATIC)))
          #self.interfaceValue[interface]['staticgroup'] = MultiSettingControl()
          self.interfaceValue[interface]['ipadress'] = ButtonControl(Tag('label','  -%s'%_('xbian-config.network.label.ipaddress')))
          self.interfaceValue[interface]['ipadress'].onClick = lambda ipadress: ipadress.setValue(getIp(_('xbian-config.network.label.ipaddress'),ipadress.getValue()))
          self.interfaceValue[interface]['subnet'] = ButtonControl(Tag('label','  -%s'%_('xbian-config.network.label.netmask')))
          self.interfaceValue[interface]['subnet'].onClick = lambda subnet: subnet.setValue(getIp(_('xbian-config.network.label.netmask'),subnet.getValue()))
          self.interfaceValue[interface]['gateway'] = ButtonControl(Tag('label','  -%s'%_('xbian-config.network.label.gateway')))
          self.interfaceValue[interface]['gateway'].onClick = lambda gateway: gateway.setValue(getIp(_('xbian-config.network.label.gateway'),gateway.getValue()))
          self.interfaceValue[interface]['dns1'] = ButtonControl(Tag('label','  -%s 1'%_('xbian-config.network.label.nameserver')))
          self.interfaceValue[interface]['dns1'].onClick = lambda dns1: dns1.setValue(getIp('-%s 1'%_('xbian-config.network.label.nameserver'),dns1.getValue()))
          self.interfaceValue[interface]['dns2'] = ButtonControl(Tag('label','  -%s 2'%_('xbian-config.network.label.nameserver')))
          self.interfaceValue[interface]['dns2'].onClick = lambda dns2: dns2.setValue(getIp('-%s 2'%_('xbian-config.network.label.nameserver'),dns2.getValue()))
          self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['ipadress'])
          self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['subnet'])
          self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['gateway'])
          self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['dns1'])
          self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['dns2'])
          self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['staticgroup'])
Exemplo n.º 40
0
    def runCmd(self,volume,snapshot) :
         #TODO check command
         mountdir = '/tmp/' + snapshot.split('/@')[0] + '@' + snapshot.split('/@')[1]
         if not os.path.isdir(mountdir):
            try :
                os.mkdir(mountdir)
            except :
                print 'XBian-Config : Cannot create mount dir : %s'%mountdir

         print xbianConfig('-t','btrfs','-o','subvol=%s'%snapshot,'/dev/root',mountdir,cmd=['sudo','/bin/mount'])
 def onGetMore(self,cat) :
     progress = dialogWait(cat,_('xbian-config.packages.list.download'))
     progress.show()
     tmp = xbianConfig('packages','list',cat)
     if tmp and tmp[0] == '-3' :
         rc = xbianConfig('packages','updatedb')
         if rc[0] == '1' :
             tmp = xbianConfig('packages','list',cat)
         else :
             tmp = []
     progress.close()
     if tmp[0]!= '-2' and tmp[0]!= '-3' :
        package = []
        for packag in tmp :
          packageTmp = packag.split(',')
          if packageTmp[1] == '0' :
             package.append(packageTmp[0])
        select =self.dialog.select(_('xbian-config.packages.name'),package)
        if select != -1 :
             choice = [_('xbian-config.packages.label.information'),_('xbian-config.packages.label.install')]
             sel = self.dialog.select('Select',choice)
             if sel == 0 :
                 #display info dialog
                 self.showInfo(package[select])
             elif sel == 1 :
                 self.APPLYTEXT = _('xbian-config.packages.install.confirm')
                 if self.askConfirmation(True) :
                     self.tmppack = (cat,package[select])
                     progressDlg = dialogWait(package[select],'xbian-config.common.pleasewait')
                     progressDlg.show()
                     rc = xbianConfig('packages','installtest',package[select])
                     if rc and rc[0] == '1' :
                          rc = xbianConfig('packages','install',package[select])
                     if rc and rc[0] == '1' :
                          progressDlg.close()
                          dlg = dialogWaitBackground(self.DIALOGHEADER,[],self.checkInstallFinish,APTLOGFILE,skinvar=SKINVARAPTRUNNIG,onFinishedCB=self.onInstallFinished)
                          dlg.show()
                     else :
                         if rc and rc[0] == '2' :
                             self.ERRORTEXT = _('xbian-config.packages.already_installed')
                         elif rc and rc[0] == '3' :
                             self.ERRORTEXT = _('xbian-config.packages.unavailable_version')
                         elif rc and rc[0] == '4' :
                             self.ERRORTEXT = _('xbian-config.packages.unavailable_version')
                         elif rc and rc[0] == '5' :
                             self.ERRORTEXT = _('xbian-config.packages.downgrade')
                         elif rc and rc[0] == '6' :
                             self.ERRORTEXT = _('xbian-config.packages.size_mismatch')
                         elif rc and rc[0] == '7' :
                             self.ERRORTEXT = _('xbian-config.packages.error')
                         else :
                             #normally never pass here
                             self.ERRORTEXT = _('xbian-config.dialog.unexpected_error')
                         progressDlg.close()
                         self.notifyOnError()
Exemplo n.º 42
0
    def onInit(self) :
        self.interface = SpinControlex(Tag('label','Interface'))
        self.addControl(self.interface)
        self.interfacelist = xbianConfig('network','list')
        self.interfaceValue = {}

        for interface in self.interfacelist :
             self.interfaceValue[interface] = {}
             self.interfaceValue[interface]['content'] = Content(Tag('label',interface),defaultSKin=False)
             self.interface.addContent(self.interfaceValue[interface]['content'])
             
             #create the interface group
             self.interfaceValue[interface]['group'] = MultiSettingControl(Tag('visible','Container(%d).HasFocus(%d)'%(self.interface.getWrapListId(),self.interfaceValue[interface]['content'].getId())))
             self.addControl(self.interfaceValue[interface]['group'])
             
             #add status control
             self.interfaceValue[interface]['status'] = ButtonControl(Tag('label',' -Status'))
             self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['status'])
             
             #check if Wifi
             self.interfaceValue[interface]['wifi'] = False
             if xbianConfig('network','type',interface)[0] == '1':
                 self.interfaceValue[interface]['wifi'] = True
                 self.interfaceValue[interface]['ssid'] = ButtonControl(Tag('label',' -Ssid'))
                 self.interfaceValue[interface]['ssid'].onClick = lambda wifi : self.wifi(interface) 
                 self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['ssid'])
                 
             
             #add interface mode Control (static/dhcp)
             self.interfaceValue[interface]['mode'] = SpinControlex(Tag('label',' -Mode'))
             dhcp = Content(Tag('label',self.DHCP),defaultSKin=False)
             static = Content(Tag('label',self.STATIC),defaultSKin=False)
             self.interfaceValue[interface]['mode'].addContent(dhcp)
             self.interfaceValue[interface]['mode'].addContent(static)
             self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['mode'])
             
             #add Static Group
             self.interfaceValue[interface]['staticgroup'] = MultiSettingControl(Tag('visible','Container(%d).HasFocus(%d)'%(self.interfaceValue[interface]['mode'].getWrapListId(),static.getId())))
             self.interfaceValue[interface]['ipadress'] = ButtonControl(Tag('label','  -Adress'))
             self.interfaceValue[interface]['ipadress'].onClick = lambda ipadress: ipadress.setValue(getIp('Ip adress',ipadress.getValue()))
             self.interfaceValue[interface]['subnet'] = ButtonControl(Tag('label','  -Subnet'))
             self.interfaceValue[interface]['subnet'].onClick = lambda subnet: subnet.setValue(getIp('Subnet',subnet.getValue()))
             self.interfaceValue[interface]['gateway'] = ButtonControl(Tag('label','  -Gateway'))
             self.interfaceValue[interface]['gateway'].onClick = lambda gateway: gateway.setValue(getIp('Gateway',gateway.getValue()))
             self.interfaceValue[interface]['dns1'] = ButtonControl(Tag('label','  -Primary Dns'))
             self.interfaceValue[interface]['dns1'].onClick = lambda dns1: dns1.setValue(getIp('Primary Dns',dns1.getValue()))
             self.interfaceValue[interface]['dns2'] = ButtonControl(Tag('label','  -Secondary Dns'))
             self.interfaceValue[interface]['dns2'].onClick = lambda dns2: dns2.setValue(getIp('Primary Dns',dns2.getValue()))
             self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['ipadress'])
             self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['subnet'])
             self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['gateway'])
             self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['dns1'])
             self.interfaceValue[interface]['staticgroup'].addControl(self.interfaceValue[interface]['dns2'])
             self.interfaceValue[interface]['group'].addControl(self.interfaceValue[interface]['staticgroup'])
Exemplo n.º 43
0
 def setXbianValue(self, value):
     # value is like [1,'/mnt/backup/$(hostname)_home_backup_$(date +%F).img.gz', 'Daily', 3]
     if value[0] == 0:
         value[2] = 'none'
     if xbianConfig('xbiancopy', 'homeplan', value[2])[0] != '1':
         return False
     if xbianConfig('xbiancopy', 'homedest', value[1])[0] != '1':
         return False
     if xbianConfig('xbiancopy', 'homekeep', str(value[3]))[0] != '1':
         return False
     return True
 def syncLocalCache(self):
     self.addedremoved = int(xbianConfig('packages', 'status')[0])
     xbmc.log('XBian-config : packages added/removed %d' % self.addedremoved, xbmc.LOGDEBUG)
     if self.addedremoved == 1:
         # have to update local cache for current category only
         xbianConfig('packages', 'list', self.tmppack[0], forcerefresh=True)
     elif self.addedremoved != 0:
         # unfortunately we have to update all categories because we do not know
         # where additional packages has been installed in other category
         for group in self.control.packages:
             xbianConfig('packages', 'list', group.getName(), forcerefresh=True)
Exemplo n.º 45
0
 def clean(self) :
     self.updateThread.stop()
     self.onClean()
     if os.path.isfile(LOCK_FILE) :
         os.remove(LOCK_FILE)
     if self.checkReboot :
         from resources.lib.xbianconfig import xbianConfig            
         rebootneeded = xbianConfig('reboot')
         updateinprogress = xbianConfig('updates','progress')
         if rebootneeded and rebootneeded[0] == '1' and updateinprogress[0] == '0' and xbmcgui.Dialog().yesno('XBian-config',_('xbian-config.main.reboot_question')):
             xbmc.executebuiltin('Reboot')
 def syncLocalCache(self):
     self.addedremoved = int(xbianConfig('packages', 'status')[0])
     xbmc.log('XBian-config : packages added/removed %d' % self.addedremoved, xbmc.LOGDEBUG)
     if self.addedremoved == 1:
         # have to update local cache for current category only
         xbianConfig('packages', 'list', self.tmppack[0], forcerefresh=True)
     elif self.addedremoved != 0:
         # unfortunately we have to update all categories because we do not know
         # where additional packages has been installed in other category
         for group in self.control.packages:
             xbianConfig('packages', 'list', group.getName(), forcerefresh=True)
 def setXbianValue(self, value):
     # value is like [1,'/mnt/backup/$(hostname)_home_backup_$(date +%F).img.gz', 'Daily', 3]
     if value[0] == 0:
         value[2] = 'none'
     if xbianConfig('xbiancopy', 'homeplan', value[2])[0] != '1':
         return False
     if xbianConfig('xbiancopy', 'homedest', value[1])[0] != '1':
         return False
     if xbianConfig('xbiancopy', 'homekeep', str(value[3]))[0] != '1':
         return False
     return True
Exemplo n.º 48
0
 def getXbianValue(self):
     rc = xbianConfig('updates', 'list', self.key)
     if rc and rc[0] == '-3':
         rctmp = xbianConfig('updates', 'updatedb')
         if rctmp and rctmp[0] == '1':
             rc = xbianConfig('updates', 'list', self.key)
         else:
             rc[0] = '0'
     if rc and rc[0] not in ('0', '-2'):
         for update in rc:
             self.control.addUpdate(update)
     return rc
Exemplo n.º 49
0
    def onStart(self):
        #check if resize sd is needed
        rc = xbianConfig('resizesd','check')
        if rc and rc[0] == '1' :
			dialog = xbmcgui.Dialog()
			if dialog.yesno('Resize SD','Your SD card is not resized','Do you want to resize now?') :
				rc = xbianConfig('resizesd','resize')
				if rc and rc[0] == '1' :
					if dialog.yesno('Resize SD','Resize SD card will be done on next reboot','Do you want to reboot now?') :
						xbmc.executebuiltin('Reboot')
				else :
					xbmc.executebuiltin("Notification(%s,%s)"%('Resize SD','Something went wrong when resizing SD'))
 def setXbianValue(self, values):
     ok = True
     for interface in values:
         modified = False
         if str(values[interface][0]) != str(self.xbianValue[interface][0]):
             modified = True
         elif values[interface][0] != 'dhcp':
             j = (0, 2, 3, 4, 5, 6)
             for i in j:
                 if str(values[interface][i]) != str(
                         self.xbianValue[interface][i]):
                     modified = True
                     break
         if modified:
             if values[interface][0].lower() == NetworkControl.DHCP.lower():
                 mode = 'dhcp'
                 cmd = [mode, interface]
             else:
                 mode = 'static'
                 cmd = [
                     mode, interface, values[interface][2],
                     values[interface][3], values[interface][4],
                     values[interface][5], values[interface][6],
                     str(values[interface][0].lower())
                 ]
             rc = xbianConfig('network', *cmd)
             if not rc:
                 ok = False
                 self.ERRORTEXT = _('An unexpected error occurred')
             elif rc[0] == '1' and str(
                     values[interface][0].lower()) != 'disable':
                 progress = dialogWait(
                     _('Restarting %s') % (interface, ),
                     _('Please wait while updating'))
                 progress.show()
                 xbianConfig('network', 'restart', interface)
                 rc = '2'
                 lc = 0
                 while (rc == '2' or rc == '-12') and lc < 60:
                     tmp = xbianConfig('network', 'progress', interface)
                     if tmp:
                         rc = tmp[0]
                     time.sleep(1)
                     lc += 1
                 self.reloadInterface(interface)
                 progress.close()
             elif str(values[interface][0].lower()) != 'disable':
                 ok = False
                 try:
                     self.ERRORTEXT = rc[1]
                 except:
                     self.ERRORTEXT = _('An unexpected error occurred')
     return ok
    def onInit(self):
        self.packages = []
        self.onGetMore = None
        self.onPackage = None

        packagelist = xbianConfig('packages', 'list', cache=True)
        if packagelist[0] == '-3':
            xbianConfig('packages', 'updatedb')
            packagelist = xbianConfig('packages', 'list', forcerefresh=True)
        for package in packagelist:
            self.packages.append(PackageCategory(package, self._onPackage, self._onGetMore))
            self.addControl(self.packages[-1].getControl())
Exemplo n.º 52
0
 def getXbianValue(self):
     self.guiloaded = True  # allow refresh.
     serviceList = xbianConfig('services', 'status')
     for service in serviceList:
         tmp = service.split(' ')
         self.services[tmp[0]] = self._parseStatus(int(tmp[1]))
         self.control.addService(tmp[0], self.services[tmp[0]][0])
Exemplo n.º 53
0
 def onAddCustom(self) :
     canInsert = False
     name = ""
     while not canInsert :
         name = getText('Service Name',name)
         if not name :
             canInsert = True
         else :
             daemon = getText('Daemon (leave empty if none)')               
             if daemon != None :
                 self.APPLYTEXT = 'Do you want to insert %s ?'%name
                 if self.askConfirmation() :
                     progress = dialogWait('Inserting','Please wait while inserting %s...'%name)
                     progress.show() 
                     rc = xbianConfig('services','insert',name,daemon)                                            
                     if rc and rc[0] == '1' :                       
                         self.addService(name)
                         progress.close()
                         self.OKTEXT = 'Service %s added successfully'%name
                         self.notifyOnSuccess()
                     elif rc and rc[0] == '-2':
                         progress.close()
                         self.ERRORTEXT = '%s is not installed, please install it first'%name
                         self.notifyOnError()
                     else :
                         progress.close()
                         self.ERRORTEXT = 'Unknwown error'
                         self.notifyOnError()                            
                 canInsert = True
Exemplo n.º 54
0
 def oncopyFinished(self):
     if self.rc == '1':
         # backup is finished
         self.OKTEXT = _('Backup system is finished')
         if self.value[1] == 'File':
             xbianConfig('xbiancopy', 'doclean', self.value[2], self.keep)
         self.notifyOnSuccess()
     else:
         if self.rc == '-1':
             self.ERRORTEXT = _("Can't prepare destination filesystem")
         elif self.rc == '-2':
             # shouldn't see this error
             self.ERRORTEXT = _('Backup not started')
         else:
             self.ERRORTEXT = _('An unexpected error occurred')
         self.notifyOnError()
Exemplo n.º 55
0
 def getXbianValue(self):
     rc = xbianConfig('xbiancopy', self.key)
     if rc:
         rc = rc[0].split(' ')
     if rc[0] == '0':
         rc.append(10)
     return list(map(int, rc))
Exemplo n.º 56
0
    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')
Exemplo n.º 57
0
 def setXbianValue(self, value):
     rc = xbianConfig('xbmc', 'priority', str(value[0]), str(value[1]),
                      str(value[2]))
     if rc and rc[0] == '1':
         return True
     else:
         return False
Exemplo n.º 58
0
 def setXbianValue(self, value):
     rc = xbianConfig('updates', 'autoinventory', str(value[0]),
                      str(value[1]))
     if rc and rc[0] == '1':
         return True
     else:
         return False
    def getXbianValue(self):
        self.default = False
        self.lanConfig = {}
        for interface in self.getControl().interfacelist:
            interface_config = xbianConfig('network', 'status', interface)
            if interface_config[2] == 'UP' or not self.default:
                self.default = interface
            self.lanConfig[interface] = []

            values = dict(map(lambda x: x.split(' '), interface_config))
            guivalues = [
                'mode', 'state', 'ip', 'netmask', 'gateway', 'nameserver1',
                'nameserver2', 'ssid'
            ]
            for val in guivalues:
                if val == 'ssid':
                    value = values.get('ssid')
                    if not value:
                        value = 'Not connected'
                    else:
                        value = base64.b64decode(value).decode('utf-8')
                else:
                    value = str(values.get(val))
                self.lanConfig[interface].append(value)
        return self.lanConfig
Exemplo n.º 60
0
 def showInfo(self,package) :
     progress = dialogWait('Loading','Please wait while loading the information for %s'%package)
     progress.show() 
     rc = xbianConfig('packages','info',package)
     progress.close() 
     if rc :         
         PackageInfo(package,rc[0].partition(' ')[2],rc[1].partition(' ')[2],rc[2].partition(' ')[2],rc[3].partition(' ')[2],rc[4].partition(' ')[2],rc[5].partition(' ')[2],rc[6].partition(' ')[2])