def RestoreiPod(self,podPath):
	loadDialog = gtk.FileChooserDialog("Select Backup File to Restore", self.wTree.get_widget("BackuPodForm"), gtk.FILE_CHOOSER_ACTION_OPEN,(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
	loadDialogFilter = gtk.FileFilter()
	loadDialogFilter.set_name("iPod Backup File")
	loadDialogFilter.add_pattern("*.ipb")
	loadDialog.add_filter(loadDialogFilter)
	loadDialog.show()
	response = loadDialog.run()
	if response == gtk.RESPONSE_CANCEL:
		loadDialog.destroy()
	elif response == gtk.RESPONSE_OK:
		savedBackup = loadDialog.get_filename()
		loadDialog.destroy()
		backupFile = zipfile.ZipFile(savedBackup,"r")
		respond, dialog = BackuPod_shared.getAnswer("WARNING!","Restoring this backup file to your iPod will ERASE ALL YOUR MUSIC LIBRARY, if you are not sure please don't proceed.\nDo you want to continue?")
		if respond == gtk.RESPONSE_YES:
			if podPath[len(podPath)-2:len(podPath)-1]:
				podPath += "/"
			shutil.rmtree(podPath + "iPod_Control")
			os.mkdir(podPath + "iPod_Control")
			print "Working....."
			for filename in backupFile.namelist():
				if filename != "library.lib":
					storingPath = filename[filename.find("iPod_Control"):len(filename)]
					storingPodPath = podPath + storingPath
					if storingPodPath[len(storingPath)-1:len(storingPath)] != "/":
						createDirs(storingPodPath)
						file(storingPodPath, 'wb').write(backupFile.read(filename))
			print "Restore completed."
			BackuPod_shared.MessageBox("Restore Completed.","BackuPod finished restoring your iPod.")
			self.wTree.get_widget("StatusBar").push(self.statusContext, "iPod Restored.")
		dialog.destroy()
def Backup(self):
	iPodPath = BackuPod_shared.getipodPath()
	if iPodPath != None:
		CreateBackup(self,iPodPath)
Exemple #3
0
	def about(self,obj):
		BackuPod_shared.showAbout()
def Restore(self):
	iPodPath = BackuPod_shared.getipodPath()
	if iPodPath != None:
		RestoreiPod(self,iPodPath)