def apply_patch(patchFilePath, targetDir): if not os.path.isfile(patchFilePath): print "Invalid patch file path at: " + patchFilePath print "Not a file" return None baseDir = os.path.dirname(patchFilePath) patchDir = os.path.join(baseDir, "patch_temp") if validate_environment(): try: unzip_directory(patchFilePath, baseDir, silent=True) index = read_index(patchDir) print "Checking for correct version of files..." for (operation, path, checksumOld, checksumNew) in index: if operation != "A": print_verbose(2, path) validate_checksum_pre(os.path.join(targetDir, path), checksumOld) print "Applying Patch..." for (operation, path, checksumOld, checksumNew) in index: print_verbose(1, operation + " " + path) apply_file_operation(operation, path, patchDir, targetDir) print "Validating Result..." for (operation, path, checksumOld, checksumNew) in index: print_verbose(2, path) if operation != "D": validate_checksum_post(os.path.join(targetDir, path), checksumNew) except ChecksumException as ex: print ex.msg() shutil.rmtree(patchDir)
def apply_patch(patchFilePath, targetDir): if not os.path.isfile(patchFilePath): print 'Invalid patch file path at: ' + patchFilePath print 'Not a file' return None baseDir = os.path.dirname(patchFilePath) patchDir = os.path.join(baseDir, 'patch_temp') if validate_environment(): try: unzip_directory(patchFilePath, baseDir, silent=True) index = read_index(patchDir) print 'Checking for correct version of files...' for (operation, path, checksumOld, checksumNew) in index: if (operation != 'A'): print_verbose(2, path) validate_checksum_pre(os.path.join(targetDir, path), checksumOld) print 'Applying Patch...' for (operation, path, checksumOld, checksumNew) in index: print_verbose(1, operation + ' ' + path) apply_file_operation(operation, path, patchDir, targetDir) print 'Validating Result...' for (operation, path, checksumOld, checksumNew) in index: print_verbose(2, path) if (operation != 'D'): validate_checksum_post(os.path.join(targetDir, path), checksumNew) except ChecksumException as ex: print ex.msg() shutil.rmtree(patchDir)
def download_full_game(ftp): fileSize = find_full_game_size(ftp) print "Downloading full application (" + str(fileSize / 1000000) + " MB)..." clear_temp_dir() progress = Progress(fileSize, 50) progress.print_header(10) filename = os.path.join(TEMP_DIR, "latest") download_file(ftp, "latest", filename, progress) print "Extracting files..." unzip_directory(filename, TEMP_DIR) if os.path.exists(PROJECT_DIR): print "Deleting old files..." shutil.rmtree(PROJECT_DIR) print "Copying new files..." os.rename(os.path.join(TEMP_DIR, "bin"), PROJECT_DIR) shutil.rmtree(TEMP_DIR) print "Done."
def download_full_game(ftp): fileSize = find_full_game_size(ftp) print 'Downloading full application (' + str( fileSize / 1000000) + ' MB)...' clear_temp_dir() progress = Progress(fileSize, 50) progress.print_header(10) filename = os.path.join(TEMP_DIR, 'latest') download_file(ftp, 'latest', filename, progress) print 'Extracting files...' unzip_directory(filename, TEMP_DIR) if os.path.exists(PROJECT_DIR): print 'Deleting old files...' shutil.rmtree(PROJECT_DIR) print 'Copying new files...' os.rename(os.path.join(TEMP_DIR, 'bin'), PROJECT_DIR) shutil.rmtree(TEMP_DIR) print 'Done.'