Ejemplo n.º 1
0
	def save_to_file(self, data, path):
		if os.path.exists(path):
			if not os.path.isdir(path):
				raise Exception(_("'%s' already exists and is not a directory!") %
						path)
		if not os.path.exists(path):
			os.mkdir(path)
		os.chdir(path)
		command = self.command
		source = data.source
		if command.find("'%s'") != -1:
			command = command % shell_escape(source.name)
			source = None
		try:
			pipe_through_command(command, source, None)
		finally:
			try:
				os.rmdir(path)	# Will only succeed if it's empty
			except:
				pass
			if os.path.exists(path):
				self.pull_up(path)
Ejemplo n.º 2
0
	def save_to_stream(self, data, stream):
		os.chdir(os.path.dirname(data.path))
		command = self.command % shell_escape(os.path.basename(data.path))
		pipe_through_command(command, None, stream)