def __init__(self, uri, path, headers={}, date_started="", date_completed=""): gobject.GObject.__init__(self) self.config = config.Configuration() self.dbus_service = dbus_service.DBusService() self.uri = gnomevfs.make_uri_from_shell_arg(uri) self.file_name = os.path.basename(self.uri) self.path = path self.headers = headers if not self.config.ask_for_location: folder = utils.get_folder_for_extension(uri) if folder: self.path = folder if uri.endswith(".metalink") or metalink.urlhead(uri, metalink=True)["content-type"].startswith(metalink.MIME_TYPE): self.is_metalink = True else: self.is_metalink = False self.file = os.path.join(path, self.file_name) self.has_started = False self.current_size = self.__get_current_size() self.total_size = 0 self.old_total_size = 0 self.percent_complete = 0 self.bit_rate = 0.0 self.last_bitrate = datetime.datetime.now() self.old_status = -1 self.status = -1 self.mime_type = gnomevfs.get_file_mime_type(self.file_name) self.pixbuf = gui.load_icon_from_mime_type(self.mime_type, 32) if date_started == "": self.date_started = datetime.datetime.now() else: self.date_started = datetime.datetime.strptime(date_started, DATE_FORMAT_DIGIT) if date_completed == "": self.date_completed = None else: self.date_completed = datetime.datetime.strptime(date_completed, DATE_FORMAT_DIGIT) self.id = self.date_started.strftime("%Y%m%d%H%M%S") self.connect("status-changed", self.__status_changed)
def __init__(self, uri="", headers={}): self.headers = headers self.config = config.Configuration() self.__get_widgets() self.__connect_widgets() self.clipboard = gtk.Clipboard(selection="PRIMARY") self.owner_change_id = self.clipboard.connect("owner-change", self.__clipboard_owner_change) if uri: self.uri_entry.set_text(uri) else: self.uri_entry.set_text(gui.get_uri_from_clipboard() or "") # self.uri_entry.paste_clipboard() # self.uri_entry.select_region(0, -1) folder = utils.get_folder_for_extension(uri) if not folder: folder = self.config.default_folder self.download_filechooserbutton.set_current_folder(folder) self.download = None