def PromptContinue(self): #returns False if user quits return not askYes( self.parent, _('You did not create a backup of the Bash settings.\n') + _('If you continue, your current settings may be overwritten.\n') + _('Do you want to quit Wrye Bash now?'), _('No backup created!'))
def PromptQuit(self): #returns True if user quits return askYes(self.parent, _('There was an error while trying to backup the Bash settings!\n') + _('If you continue, your current settings may be overwritten.\n') + _('Do you want to quit Wrye Bash now?'), _('Unable to create backup!'))
def InfoSuccess(self): if self.quit: return showInfo( self.parent, _('Your Bash settings have been backed up successfully.\n') + _('Backup Path: %s\n') % (self.dir.join(self.archive).s), _('Backup File Created'))
def PromptContinue(self): #returns False if user quits return not askYes(self.parent, _('You did not create a backup of the Bash settings.\n') + _('If you continue, your current settings may be overwritten.\n') + _('Do you want to quit Wrye Bash now?'), _('No backup created!'))
def PromptMismatch(self): #returns False if same app version or old version == 0 (as in not previously installed) or user cancels if basher.settings['bash.readme'][1] == '0': return False return not self.SameAppVersion() and self.PromptConfirm( _('A different version of Wrye Bash was previously installed.\n') + _('Previous Version: %s\n') % (basher.settings['bash.readme'][1]) + _('Current Version: %s\n') % (self.verApp) + _('Do you want to create a backup of your Bash settings before they are overwritten?'))
def PromptMismatch(self): # return True if same app version or user confirms return self.SameAppVersion() or askWarning(self.parent, _('The version of Bash used to create the selected backup file does not match the current Bash version!\n') + _('Backup v%s does not match v%s\n') % (self.verApp, basher.settings['bash.readme'][1]) + _('\n') + _('Do you want to restore this backup anyway?'), _('Warning: Version Mismatch!'))
def PromptMismatch(self): # return True if same app version or user confirms return self.SameAppVersion() or askWarning( self.parent, _('The version of Bash used to create the selected backup file does not match the current Bash version!\n' ) + _('Backup v%s does not match v%s\n') % (self.verApp, basher.settings['bash.readme'][1]) + _('\n') + _('Do you want to restore this backup anyway?'), _('Warning: Version Mismatch!'))
def PromptQuit(self): #returns True if user quits return askYes( self.parent, _('There was an error while trying to backup the Bash settings!\n') + _('If you continue, your current settings may be overwritten.\n') + _('Do you want to quit Wrye Bash now?'), _('Unable to create backup!'))
def monitor(sleepSeconds=0.25): """Monitor for requests to rip appearance, etc.""" global data print header data = Data() running = True while running: try: time.sleep(sleepSeconds) data.update() if data.hasPing(): print time.strftime('%H:%M:%S',time.localtime()), 'ping' data.ping.moveTo(data.pong) data.setSignals() if not data.hasRequest(): continue except KeyboardInterrupt: print time.strftime('\n%H:%M:%S',time.localtime()),_("Bashmon stopped.") running = False continue except IOError: print time.strftime('\n%H:%M:%S',time.localtime()),_("Fallout.ini is busy.") continue except: data.failed.touch() traceback.print_exc() running = False break #--Handle lines in request print time.strftime('%H:%M:%S request',time.localtime()) #, '='*60 ins = data.request.open('r') try: for line in ins: line =line.strip() if not line: continue args = string.split(line) #--Handle request command,args = args[0],args[1:] print ' ', line command = monitorCommands[command] command(*args) ins.close() print ' Completed\n' data.completed.touch() if data.removeRequest: data.request.remove() while data.completed.exists(): time.sleep(0.1) data.setSignals() except: print ' Failed\n' data.failed.touch() traceback.print_exc() running = False break raw_input('\nSTOPPED: Press any key to exit.')
def PromptMismatch(self): #returns False if same app version or old version == 0 (as in not previously installed) or user cancels if basher.settings['bash.readme'][1] == '0': return False return not self.SameAppVersion() and self.PromptConfirm( _('A different version of Wrye Bash was previously installed.\n') + _('Previous Version: %s\n') % (basher.settings['bash.readme'][1]) + _('Current Version: %s\n') % (self.verApp) + _('Do you want to create a backup of your Bash settings before they are overwritten?' ))
def moveSave(oldSave,newSave): """Temporarilty moves quicksave.ess to quicktemp.ess.""" #--Use path.tail to prevent access outside of saves directory oldPath = data.savesDir.join(GPath(oldSave).tail) newPath = data.savesDir.join(GPath(newSave).tail) if newPath.exists() and not newPath.isfile(): raise bolt.BoltError(newPath+_(' exists and is not a save file.')) if oldPath.exists(): if not oldPath.isfile(): raise bolt.BoltError(oldPath+_(' is not a save file.')) oldPath.moveTo(newPath) bosh.CoSaves(oldPath).move(newPath)
def ErrorConflict(self): #returns True if the data format doesn't match if self.CmpDataVersion() > 0: showError(self.parent, _('The data format of the selected backup file is newer than the current Bash version!\n') + _('Backup v%s is not compatible with v%s\n') % (self.verApp, basher.settings['bash.readme'][1]) + _('\n') + _('You cannot use this backup with this version of Bash.'), _('Error: Version Conflict!')) return True #end if return False
def unpack7z(srcFile, dstDir, progress=None): # extract srcFile to dstDir progress = progress or Progress() # count the files in the archive length = 0 reList = re.compile('Path = (.*?)(?:\r\n|\n)') if bosh.inisettings['EnableUnicode']: command = r'"%s" l -slt "%s"' % (dirs['compiled'].join('7zUnicode.exe').s, srcFile.s) else: command = r'"%s" l -slt "%s"' % (dirs['compiled'].join('7z.exe').s, srcFile.s) ins, err = Popen(command, stdout=PIPE, startupinfo=startupinfo).communicate() ins = stringBuffer(ins) for line in ins: length += 1 ins.close() if progress: progress(0,_("%s\nExtracting files...") % srcFile.s) progress.setFull(1+length) #end if if bosh.inisettings['EnableUnicode']: app7z = dirs['compiled'].join('7zUnicode.exe').s else: app7z = dirs['compiled'].join('7z.exe').s command = '"%s" x "%s" -y -o"%s"' % (app7z, srcFile.s, dstDir.s) #--Extract files ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error Checking, and progress feedback #--Note subArchives for recursive unpacking reExtracting = re.compile('Extracting\s+(.+)') regMatch = reExtracting.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maExtracting = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maExtracting: extracted = GPath(maExtracting.group(1).strip()) if progress: progress(index,_("%s\nExtracting files...\n%s") % (srcFile.s,extracted.s)) #end if index += 1 #end if #end for result = ins.close() if result: raise StateError(_("%s: Extraction failed:\n%s") % (srcFile.s, "\n".join(errorLine)))
def ErrorConflict(self): #returns True if the data format doesn't match if self.CmpDataVersion() > 0: showError( self.parent, _('The data format of the selected backup file is newer than the current Bash version!\n' ) + _('Backup v%s is not compatible with v%s\n') % (self.verApp, basher.settings['bash.readme'][1]) + _('\n') + _('You cannot use this backup with this version of Bash.'), _('Error: Version Conflict!')) return True #end if return False
def pack7z(dstFile, srcDir, progress=None): # archive srcdir to dstFile in 7z format without solid compression progress = progress or Progress() #--Used solely for the progress bar length = sum([len(files) for x, y, files in os.walk(srcDir.s)]) if bosh.inisettings['EnableUnicode']: app7z = dirs['compiled'].join('7zUnicode.exe').s else: app7z = dirs['compiled'].join('7z.exe').s command = '"%s" a "%s" -y -r "%s\\*"' % (app7z, dstFile.temp.s, srcDir.s) progress(0, _("%s\nCompressing files...") % dstFile.s) progress.setFull(1 + length) #--Pack the files ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error checking and progress feedback reCompressing = re.compile('Compressing\s+(.+)') regMatch = reCompressing.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maCompressing = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maCompressing: progress( index, dstFile.s + _("\nCompressing files...\n%s") % maCompressing.group(1).strip()) index += 1 #end if #end for result = ins.close() if result: dstFile.temp.remove() raise StateError( _("%s: Compression failed:\n%s") % (dstFile.s, "\n".join(errorLine))) #end if #--Finalize the file, and cleanup dstFile.untemp()
def PromptFile(self): #prompt for backup filename #returns False if user cancels if self.archive == None or not self.dir.join(self.archive).exists(): path = askOpen(self.parent,_('Restore Bash Settings'),self.dir,'','*.7z') if not path: return False self.dir = path.head self.archive = path.tail #end if self.maketmp() return True
def pack7z(dstFile, srcDir, progress=None): # archive srcdir to dstFile in 7z format without solid compression progress = progress or Progress() #--Used solely for the progress bar length = sum([len(files) for x,y,files in os.walk(srcDir.s)]) if bosh.inisettings['EnableUnicode']: app7z = dirs['compiled'].join('7zUnicode.exe').s else: app7z = dirs['compiled'].join('7z.exe').s command = '"%s" a "%s" -y -r "%s\\*"' % (app7z, dstFile.temp.s, srcDir.s) progress(0,_("%s\nCompressing files...") % dstFile.s) progress.setFull(1+length) #--Pack the files ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error checking and progress feedback reCompressing = re.compile('Compressing\s+(.+)') regMatch = reCompressing.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maCompressing = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maCompressing: progress(index,dstFile.s+_("\nCompressing files...\n%s") % maCompressing.group(1).strip()) index += 1 #end if #end for result = ins.close() if result: dstFile.temp.remove() raise StateError(_("%s: Compression failed:\n%s") % (dstFile.s, "\n".join(errorLine))) #end if #--Finalize the file, and cleanup dstFile.untemp()
def PromptFile(self): #prompt for backup filename #returns False if user cancels if self.archive == None or not self.dir.join(self.archive).exists(): path = askOpen(self.parent, _('Restore Bash Settings'), self.dir, '', '*.7z') if not path: return False self.dir = path.head self.archive = path.tail #end if self.maketmp() return True
def getRecordReader(ins, flags, size): """Decompress record data as needed.""" if not bosh.MreRecord.flags1(flags).compressed: return (ins, ins.tell() + size) else: import zlib sizeCheck, = struct.unpack("I", ins.read(4)) decomp = zlib.decompress(ins.read(size - 4)) if len(decomp) != sizeCheck: raise ModError(self.inName, _("Mis-sized compressed data. Expected %d, got %d.") % (size, len(decomp))) reader = bosh.ModReader(fileName, cStringIO.StringIO(decomp)) return (reader, sizeCheck)
def WarnRestart(self): if self.quit: return basher.appRestart = True showWarning(self.parent, _('Your Bash settings have been successfuly restored.\n') + _('Backup Path: %s\n') % (self.dir.join(self.archive).s) + _('\n') + _('Before the settings can take effect, Wrye Bash must restart.\n') + _('Click OK to restart now.'), _('Bash Settings Restored'))
def WarnRestart(self): if self.quit: return basher.appRestart = True showWarning( self.parent, _('Your Bash settings have been successfuly restored.\n') + _('Backup Path: %s\n') % (self.dir.join(self.archive).s) + _('\n') + _('Before the settings can take effect, Wrye Bash must restart.\n') + _('Click OK to restart now.'), _('Bash Settings Restored'))
def PromptFile(self): #prompt for backup filename #returns False if user cancels if self.archive == None or self.dir.join(self.archive).exists(): dt = datetime.datetime.now() file = 'Backup Bash Settings v%s (%s).7z' % (self.verApp,dt.strftime('%d-%m-%Y %H%M.%S')) if not self.quit: path = askSave(self.parent,_('Backup Bash Settings'),self.dir,file,'*.7z') if not path: return False self.dir = path.head self.archive = path.tail elif not self.archive: self.archive = file #end if self.maketmp() return True
def PromptFile(self): #prompt for backup filename #returns False if user cancels if self.archive == None or self.dir.join(self.archive).exists(): dt = datetime.datetime.now() file = 'Backup Bash Settings v%s (%s).7z' % ( self.verApp, dt.strftime('%d-%m-%Y %H%M.%S')) if not self.quit: path = askSave(self.parent, _('Backup Bash Settings'), self.dir, file, '*.7z') if not path: return False self.dir = path.head self.archive = path.tail elif not self.archive: self.archive = file #end if self.maketmp() return True
def PromptConfirm(self, msg=None): # returns False if user cancels msg = msg or _( 'Do you want to restore your Bash settings from a backup?') return askYes(self.parent, msg, _('Restore Bash Settings?'))
def PromptConfirm(self,msg=None): msg = msg or _('Do you want to backup your Bash settings now?') return askYes(self.parent,msg,_('Backup Bash Settings?'))
def WarnFailed(self): showWarning(self.parent, _('There was an error while trying to backup the Bash settings!\n') + _('No backup was created.'), _('Unable to create backup!'))
def WarnFailed(self): showWarning( self.parent, _('There was an error while trying to backup the Bash settings!\n') + _('No backup was created.'), _('Unable to create backup!'))
except: pass if basherImported and basher.appRestart: exePath = GPath(sys.executable) sys.argv = [exePath.stail] + sys.argv + ['--restarting'] sys.argv = ['\"' + x + '\"' for x in sys.argv] #quote all args in sys.argv try: import subprocess subprocess.Popen( sys.argv, executable=exePath.s, close_fds=bolt.close_fds ) #close_fds is needed for the one instance checker except Exception, error: print error print _("Error Attempting to Restart Wrye Bash!") print _("cmd line: "), exePath.s, sys.argv print raise # Main ------------------------------------------------------------------------ def main(): global opts, extra parser = optparse.OptionParser() pathGroup = optparse.OptionGroup( parser, "Path Arguments", r"All path arguments must be absolute paths and use either forward slashes (/) or two backward slashes (\\). All of these can also be set in the ini (where you can also use relative paths) and if set in both cmd line takes precedence." ) pathGroup.add_option(
def WarnFailed(self): showWarning(self.parent, _('There was an error while trying to restore your settings from the backup file!\n') + _('No settings were restored.'), _('Unable to restore backup!'))
def PromptConfirm(self, msg=None): msg = msg or _('Do you want to backup your Bash settings now?') return askYes(self.parent, msg, _('Backup Bash Settings?'))
reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maExtracting = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maExtracting: extracted = GPath(maExtracting.group(1).strip()) if progress: progress( index, _("%s\nExtracting files...\n%s") % (srcFile.s, extracted.s)) #end if index += 1 #end if #end for result = ins.close() if result: raise StateError( _("%s: Extraction failed:\n%s") % (srcFile.s, "\n".join(errorLine))) #end if # Main ------------------------------------------------------------------------ if __name__ == '__main__': print _('Compiled')
def __init__(self,message=_('Cancelled')): BoltError.__init__(self,message)
#--Extract files ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error Checking, and progress feedback #--Note subArchives for recursive unpacking reExtracting = re.compile('Extracting\s+(.+)') regMatch = reExtracting.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maExtracting = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maExtracting: extracted = GPath(maExtracting.group(1).strip()) if progress: progress(index,_("%s\nExtracting files...\n%s") % (srcFile.s,extracted.s)) #end if index += 1 #end if #end for result = ins.close() if result: raise StateError(_("%s: Extraction failed:\n%s") % (srcFile.s, "\n".join(errorLine))) #end if # Main ------------------------------------------------------------------------ if __name__ == '__main__': print _('Compiled')
def PromptConfirm(self,msg=None): # returns False if user cancels msg = msg or _('Do you want to restore your Bash settings from a backup?') return askYes(self.parent,msg,_('Restore Bash Settings?'))
def WarnFailed(self): showWarning( self.parent, _('There was an error while trying to restore your settings from the backup file!\n' ) + _('No settings were restored.'), _('Unable to restore backup!'))
def InfoSuccess(self): if self.quit: return showInfo(self.parent, _('Your Bash settings have been backed up successfully.\n') + _('Backup Path: %s\n') % (self.dir.join(self.archive).s), _('Backup File Created'))
('Clothing',), ('Weapon',), ('Tweak',2,-1), ('Overhaul',4,-1), ('Misc.',1), ('Magic',2), ('NPC',), ('Home',1), ('Place',1), ('Quest',3,-1), ('Last',1,-1), ) # Tes3 Group/Top Types ------------------------------------------------------------- groupTypes = [ _('Top (Type)'), _('World Children'), _('Int Cell Block'), _('Int Cell Sub-Block'), _('Ext Cell Block'), _('Ext Cell Sub-Block'), _('Cell Children'), _('Topic Children'), _('Cell Persistent Childen'), _('Cell Temporary Children'), _('Cell Visible Distant Children'), ] #--Top types in Oblivion order. # topTypes = ['GMST', 'GLOB', 'CLAS', 'FACT', 'HAIR', 'EYES', 'RACE', 'SOUN', 'SKIL', # 'MGEF', 'SCPT', 'LTEX', 'ENCH', 'SPEL', 'BSGN', 'ACTI', 'APPA', 'ARMO', 'BOOK',
def __init__(self, message=_('Cancelled')): BoltError.__init__(self, message)
def unpack7z(srcFile, dstDir, progress=None): # extract srcFile to dstDir progress = progress or Progress() # count the files in the archive length = 0 reList = re.compile('Path = (.*?)(?:\r\n|\n)') if bosh.inisettings['EnableUnicode']: command = r'"%s" l -slt "%s"' % ( dirs['compiled'].join('7zUnicode.exe').s, srcFile.s) else: command = r'"%s" l -slt "%s"' % (dirs['compiled'].join('7z.exe').s, srcFile.s) ins, err = Popen(command, stdout=PIPE, startupinfo=startupinfo).communicate() ins = stringBuffer(ins) for line in ins: length += 1 ins.close() if progress: progress(0, _("%s\nExtracting files...") % srcFile.s) progress.setFull(1 + length) #end if if bosh.inisettings['EnableUnicode']: app7z = dirs['compiled'].join('7zUnicode.exe').s else: app7z = dirs['compiled'].join('7z.exe').s command = '"%s" x "%s" -y -o"%s"' % (app7z, srcFile.s, dstDir.s) #--Extract files ins = Popen(command, stdout=PIPE, startupinfo=startupinfo).stdout #--Error Checking, and progress feedback #--Note subArchives for recursive unpacking reExtracting = re.compile('Extracting\s+(.+)') regMatch = reExtracting.match reError = re.compile('Error: (.*)') regErrMatch = reError.match errorLine = [] index = 0 for line in ins: maExtracting = regMatch(line) if len(errorLine) or regErrMatch(line): errorLine.append(line) if maExtracting: extracted = GPath(maExtracting.group(1).strip()) if progress: progress( index, _("%s\nExtracting files...\n%s") % (srcFile.s, extracted.s)) #end if index += 1 #end if #end for result = ins.close() if result: raise StateError( _("%s: Extraction failed:\n%s") % (srcFile.s, "\n".join(errorLine)))
# Cleanup temp installers directory import bosh bosh.Installer.tempDir.rmtree(bosh.Installer.tempDir.stail) except: pass if basherImported and basher.appRestart: exePath = GPath(sys.executable) sys.argv = [exePath.stail] + sys.argv + ['--restarting'] sys.argv = ['\"' + x + '\"' for x in sys.argv] #quote all args in sys.argv try: import subprocess subprocess.Popen(sys.argv, executable=exePath.s, close_fds=bolt.close_fds) #close_fds is needed for the one instance checker except Exception, error: print error print _("Error Attempting to Restart Wrye Bash!") print _("cmd line: "), exePath.s, sys.argv print raise # Main ------------------------------------------------------------------------ def main(): global opts, extra parser = optparse.OptionParser() pathGroup = optparse.OptionGroup(parser, "Path Arguments", r"All path arguments must be absolute paths and use either forward slashes (/) or two backward slashes (\\). All of these can also be set in the ini (where you can also use relative paths) and if set in both cmd line takes precedence.") pathGroup.add_option('-o', '--falloutPath', action='store', type='string', default='',