Ejemplo n.º 1
0
 def aborted(self):
     # remove partial file
     try:
         gnomevfs.unlink(self.output_filename)
     except:
         log("cannot delete: '%s'" % beautify_uri(self.output_filename))
     return
Ejemplo n.º 2
0
 def aborted(self):
     # remove partial file
     try:
         gnomevfs.unlink(self.output_filename)
     except:
         log('cannot delete: \'%s\'' % beautify_uri(self.output_filename))
     return
Ejemplo n.º 3
0
    def finished(self):
        Pipeline.finished(self)

        if self.aborted:
            # remove partial file
            try:
                gnomevfs.unlink(self.output_filename)
            except:
                pass
            return

        # Copy file permissions
        try:
            info = gnomevfs.get_file_info(self.sound_file.uri,
                                        gnomevfs.FILE_INFO_FIELDS_PERMISSIONS)
            gnomevfs.set_file_info(self.output_filename, info,
                                            gnomevfs.SET_FILE_INFO_PERMISSIONS)
        except:
            log('Cannot set permission on \'%s\'' %
                        gnomevfs.format_uri_for_display(self.output_filename))

        if self.delete_original and self.processing and not self.error:
            log('deleting: \'%s\'' % self.sound_file.uri)
            try:
                gnomevfs.unlink(self.sound_file.uri)
            except:
                log('Cannot remove \'%s\'' %
                        gnomevfs.format_uri_for_display(self.output_filename))
Ejemplo n.º 4
0
 def unlink(self, uri):
     """Deletes the specified URI.
     
     @param uri: The URI to delete.
     @type uri: a gnomevfs.URI
     
     """
     # Be sure the file exists then delete it
     if gnomevfs.exists(uri):
         file_info = gnomevfs.get_file_info(uri)
         
         # Double check the user wants to delete the file
         response = dialogs.choice_ok_cancel(fmt0001 % str(uri), True)
         
         if response == gtk.RESPONSE_OK:
             try:
                 if files.is_dir(file_info):
                     self.__remove_directory(uri)
                 else:
                     gnomevfs.unlink(uri)
                     
             except Exception, e:
                 dialogs.error(fmt0002 % e)
                 
             self.refresh()
Ejemplo n.º 5
0
 def __remove_directory(self, uri):
     """Deletes a folder recursively."""
     directory = gnomevfs.DirectoryHandle(uri)
     for file_info in directory:
         file_uri = uri.append_file_name(file_info.name)
         is_self = file_uri == uri
         is_parent = bool(file_uri.is_parent(uri, False))
         if not is_self and not is_parent:
             if files.is_dir(file_info):
                 self.__remove_directory(file_uri)
             else:
                 gnomevfs.unlink(file_uri)
     gnomevfs.remove_directory(uri)
Ejemplo n.º 6
0
    def finished(self):
        Pipeline.finished(self)

        # Copy file permissions
        try:
            info = gnomevfs.get_file_info(self.sound_file.uri, gnomevfs.FILE_INFO_FIELDS_PERMISSIONS)
            gnomevfs.set_file_info(self.output_filename, info, gnomevfs.SET_FILE_INFO_PERMISSIONS)
        except:
            log("Cannot set permission on '%s'" % gnomevfs.format_uri_for_display(self.output_filename))

        if self.delete_original and self.processing and not self.error:
            log("deleting: '%s'" % self.sound_file.uri)
            try:
                gnomevfs.unlink(self.sound_file.uri)
            except:
                log("Cannot remove '%s'" % gnomevfs.format_uri_for_display(self.output_filename))
Ejemplo n.º 7
0
def vfs_unlink(filename):
    """Delete a gnomevfs file."""

    gnomevfs.unlink(gnomevfs.URI(filename))
	def add(self, sound_file):
		output_filename = self.window.prefs.generate_filename(sound_file)
		
		path = urlparse.urlparse(output_filename) [2]
		
		path = urllib.unquote(path)
		
		exists = True
		try:
			gnomevfs.get_file_info(gnomevfs.URI(output_filename))
		except gnomevfs.NotFoundError:
			exists = False
				
		if exists:

			if self.overwrite_action != None:
				result = self.overwrite_action
			else:
				dialog = self.window.existsdialog

				dpath = os.path.basename(path)
				dpath = dpath.replace("&","&")

				msg = \
				_("The output file <i>%s</i>\n exists already.\n Do you want to skip the file, overwrite it or cancel the conversion?\n") % \
				( dpath )

				dialog.message.set_markup(msg)

				if self.overwrite_action != None:
					dialog.apply_to_all.set_active(True)
				else:
					dialog.apply_to_all.set_active(False)

				result = dialog.run()
				dialog.hide()

				if dialog.apply_to_all.get_active():
					if result == 1 or result == 0:
						self.overwrite_action = result
 

			if result == 1: 
				# overwrite
				#os.remove(path)
				gnomevfs.unlink(gnomevfs.URI(output_filename))
			elif result == 0: 
				# skip file
				return
			else:
				# cancel operation
				# TODO
				raise ConverterQueueCanceled()
				#self.stop()
			
		c = Converter(sound_file, output_filename, 
					  self.window.prefs.get_string("output-mime-type"))
		c.set_vorbis_quality(self.window.prefs.get_float("vorbis-quality"))
		
		quality = {
			"cbr": "mp3-cbr-quality",
			"abr": "mp3-abr-quality",
			"vbr": "mp3-vbr-quality"
		}
		mode = self.window.prefs.get_string("mp3-mode")
		c.set_mp3_mode(mode)
		c.set_mp3_quality(self.window.prefs.get_int(quality[mode]))
		TaskQueue.add(self, c)
		self.total_bytes += c.get_size_in_bytes()
Ejemplo n.º 9
0
 def delete(self):
     # close the file and the handle so that the file info is refreshed
     self.close()
     result = gnomevfs.unlink(self._URI)
Ejemplo n.º 10
0
def vfs_unlink(filename):
    gnomevfs.unlink(gnomevfs.URI(filename))
Ejemplo n.º 11
0
def vfs_unlink(filename):
    """Delete a gnomevfs file."""

    gnomevfs.unlink(gnomevfs.URI(filename))