Exemplo n.º 1
0
 def saveConfFile(self):
     confBackupFilePath = os.path.join(self.scriptDir, "conf.bak")
     if os.path.exists(confBackupFilePath):
         os.remove(confBackupFilePath)
     shutil.copy2(os.path.join(self.scriptDir, "conf.conf"),
                  os.path.join(self.scriptDir, "conf.bak"))
     confFile = open(os.path.join(self.scriptDir, "conf.conf"),
                     "w",
                     encoding="utf-8")
     listKeys = sorted(self.guiStrings.values(), key=attrgetter('order'))
     for key in listKeys:
         if key.id not in ['verify', 'save', 'proceed', 'confirm']:
             if key.help:
                 confFile.write('# ' + key.help.replace('#n', '\n# ') +
                                '\n')
             if key.id == 'images':
                 imagesValue = self.guiVars[self.guiStrings['images'].label
                                            + ' #1'].get()
                 if self.guiStrings['images'].label + ' #2' in self.guiVars:
                     imagesValue = imagesValue + '|' + self.guiVars[
                         self.guiStrings['images'].label + ' #2'].get()
                 confFile.write(key.id + ' = ' + imagesValue + '\n')
             elif key.id == 'keepLevel':
                 confFile.write(
                     key.id + ' = ' +
                     str(Sorter.getIntStatus(self.guiVars[key.id].get())) +
                     '\n')
             else:
                 if key.id in self.guiVars:
                     confFile.write(key.id + ' = ' +
                                    str(self.guiVars[key.id].get()) + '\n')
     confFile.close()
     self.logger.log('    Configuration saved in conf.conf file')
Exemplo n.º 2
0
 def saveConfInMem(self) :
     listKeys = sorted(self.guiStrings.values(), key=attrgetter('order'))        
     for key in listKeys :
         if key.id not in ['verify','save','proceed','confirm'] :                
             if key.id == 'images' :
                 imagesValue = self.guiVars[self.guiStrings['images'].label+' #1'].get()
                 if self.guiStrings['images'].label+' #2' in self.guiVars :
                     imagesValue = imagesValue + '|' + self.guiVars[self.guiStrings['images'].label+' #2'].get()
                 self.configuration['images']=  imagesValue
             elif key.id == 'keepLevel' :
                 self.configuration['keepLevel'] = str(Sorter.getIntStatus(self.guiVars[key.id].get()))
             else :                
                 if key.id in self.guiVars :
                     self.configuration[key.id] = str(self.guiVars[key.id].get())
     self.logger.log('    Configuration saved in memory')