rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
r = self._httpreq_json(service, 'POST', form=dict(query=qstr)) return self._mqlresult(r) def mqlreadmulti(self, queries, asof=None): | r = self._httpreq_json(service, 'POST', form=dict(query=qstr), headers=headers) return self._mqlresult(r) def mqlreadmulti(self, queries, asof=None, headers=None): | def mqlread(self, sq, asof=None): """read a structure query. For a more complete description, see http://www.freebase.com/view/en/api_service_mqlread""" subq = dict(query=sq, escape=False) if asof: subq['as_of_time'] = asof if isinstance(sq, list): subq['cursor'] = True service = '/api/service/mqlread' self.log.info... |
rs = self._httpreq_json(service, 'POST', form=dict(queries=qstr)) | rs = self._httpreq_json(service, 'POST', form=dict(queries=qstr), headers=headers) | def mqlreadmulti(self, queries, asof=None): """read a structure query""" keys = [('q%d' % i) for i,v in enumerate(queries)]; envelope = {} for i,sq in enumerate(queries): subq = dict(query=sq, escape=False) if asof: subq['as_of_time'] = asof # XXX put this back once mqlreadmulti is working in general #if isinstance(sq... |
http.conn.request("HEAD", url, headers = self.headers) | def get_size(self): ''' Take a best guess at size based on first 3 matching servers raise socket.error e.g. "Operation timed out" ''' i = 0 sizes = [] urls = list(self.urls) while (i < len(urls) and (len(sizes) < 3)): url = urls[i] protocol = get_transport(url) if protocol == "http": status = httplib.MOVED_PERMANENTL... | |
size = response.getheader("content-length") | def get_size(self): ''' Take a best guess at size based on first 3 matching servers raise socket.error e.g. "Operation timed out" ''' i = 0 sizes = [] urls = list(self.urls) while (i < len(urls) and (len(sizes) < 3)): url = urls[i] protocol = get_transport(url) if protocol == "http": status = httplib.MOVED_PERMANENTL... | |
if hashlib.sha1(chunkstring).hexdigest() == checksums["sha1"].lower(): | if sha1.sha1(chunkstring).hexdigest() == checksums["sha1"].lower(): | def verify_chunk_checksum(chunkstring, checksums={}): ''' Verify the checksum of a file First parameter, filename Second parameter, optional, expected dictionary of checksums Returns True if first checksum provided is valid Returns True if no checksums are provided Returns False otherwise ''' try: checksums["sha512"] ... |
if hashlib.md5(chunkstring).hexdigest() == checksums["md5"].lower(): | if md5.md5(chunkstring).hexdigest() == checksums["md5"].lower(): | def verify_chunk_checksum(chunkstring, checksums={}): ''' Verify the checksum of a file First parameter, filename Second parameter, optional, expected dictionary of checksums Returns True if first checksum provided is valid Returns True if no checksums are provided Returns False otherwise ''' try: checksums["sha512"] ... |
if filehash(local_file, hashlib.sha1()) == checksums["sha1"].lower(): | if filehash(local_file, sha1.sha1()) == checksums["sha1"].lower(): | def verify_checksum(local_file, checksums={}): ''' Verify the checksum of a file First parameter, filename Second parameter, optional, expected dictionary of checksums Returns True if first checksum provided is valid Returns True if no checksums are provided Returns False otherwise ''' try: return pgp_verify_sig(local... |
if filehash(local_file, hashlib.md5()) == checksums["md5"].lower(): | if filehash(local_file, md5.md5()) == checksums["md5"].lower(): | def verify_checksum(local_file, checksums={}): ''' Verify the checksum of a file First parameter, filename Second parameter, optional, expected dictionary of checksums Returns True if first checksum provided is valid Returns True if no checksums are provided Returns False otherwise ''' try: return pgp_verify_sig(local... |
md5hash = md5.new() sha1hash = sha.new() sha256hash = None try: md5hash = hashlib.md5() sha1hash = hashlib.sha1() sha256hash = hashlib.sha256() except: | md5hash = md5.md5() sha1hash = sha1.sha1() if sha256: sha256hash = sha256.sha256() else: sha256hash = None | def scan_file(self, filename, use_chunks=True, max_chunks=255, chunk_size=256, progresslistener=None): print "\nScanning file..." # Filename and size self.filename = os.path.basename(filename) self.size = int(os.stat(filename).st_size) # Calculate piece length if use_chunks: minlength = chunk_size*1024 self.piecelength... |
piecehash = sha.new() | piecehash = sha1.sha1() | def scan_file(self, filename, use_chunks=True, max_chunks=255, chunk_size=256, progresslistener=None): print "\nScanning file..." # Filename and size self.filename = os.path.basename(filename) self.size = int(os.stat(filename).st_size) # Calculate piece length if use_chunks: minlength = chunk_size*1024 self.piecelength... |
else: | elif self.hashlist[key] != "": | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # Publisher info if self.publisher_name.strip() != "" or self.publisher_url.strip() != "": lictext = "" if self.publisher_name.strip() != "": lictext += ' name="' + self.publisher_name + '... |
text += ' <pieces type="'+hashlookup(self.piecetype)+'" length="'+self.piecelength+'">\n' | text += ' <pieces type="'+hashlookup(self.piecetype)+'" length="'+str(self.piecelength)+'">\n' | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # Publisher info if self.publisher_name.strip() != "" or self.publisher_url.strip() != "": lictext = "" if self.publisher_name.strip() != "": lictext += ' name="' + self.publisher_name + '... |
else: | elif self.hashlist[key] != "": | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # File info if self.size != 0: text += ' <size>'+str(self.size)+'</size>\n' if self.language.strip() != "": text += ' <language>'+self.language+'</language>\n' if self.os.str... |
text += ' <hash type="%s">' % hashlookup(key) + self.hashlist[key].lower() + '</hash>\n' | text += ' <hash type="%s">' % key + self.hashlist[key].lower() + '</hash>\n' | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # File info if self.size != 0: text += ' <size>'+str(self.size)+'</size>\n' if self.language.strip() != "": text += ' <language>'+self.language+'</language>\n' if self.os.str... |
text += '<origin ' . attr . '>'+self.origin+'</origin>\n' | text += '<origin ' + attr + '>'+self.origin+'</origin>\n' | def generate(self): text = '<?xml version="1.0" encoding="utf-8"?>\n' text += '<metalink xmlns="urn:ietf:params:xml:ns:metalink">\n' |
class App: def __init__(self): | class App(threading.Thread): def __init__(self, url): threading.Thread.__init__(self) | def parse_config(configfile="config.ini"): configdict = {} config = ConfigParser.RawConfigParser() config.read(configfile) for sect in config.sections(): configdict[sect] = {} for options in config.items(sect): configdict[sect][options[0]] = options[1] return configdict |
def process_html(self, filename, url=''): handle = open(filename) text = handle.read() handle.close() | def process_html(self, text, url=''): | def process_html(self, filename, url=''): handle = open(filename) text = handle.read() handle.close() parser = LinkParser(url) try: parser.feed(text) except: pass for link in parser.links: if link.endswith(".metalink") or link.endswith(".meta4"): download_metalink(link) elif (link.startswith(os.path.dirname(url))): se... |
except: | except HTMLParser.HTMLParseError: | def process_html(self, filename, url=''): handle = open(filename) text = handle.read() handle.close() parser = LinkParser(url) try: parser.feed(text) except: pass for link in parser.links: if link.endswith(".metalink") or link.endswith(".meta4"): download_metalink(link) elif (link.startswith(os.path.dirname(url))): se... |
elif (link.startswith(os.path.dirname(url))): | else: | def process_html(self, filename, url=''): handle = open(filename) text = handle.read() handle.close() parser = LinkParser(url) try: parser.feed(text) except: pass for link in parser.links: if link.endswith(".metalink") or link.endswith(".meta4"): download_metalink(link) elif (link.startswith(os.path.dirname(url))): se... |
filename = os.path.join(CACHEDIR, m.hexdigest() + ".html") | def crawl(self, webpage): m = hashlib.md5() m.update(webpage) | |
handle = open(filename, "w") handle.write(text) handle.close() | def crawl(self, webpage): m = hashlib.md5() m.update(webpage) | |
self.process_html(filename, webpage) | self.process_html(text, webpage) | def crawl(self, webpage): m = hashlib.md5() m.update(webpage) |
if (page not in self.queue) and (page not in self.indexed): self.queue.append(page) | if not page.startswith(os.path.dirname(self.url)): return if os.path.basename(page).startswith("?view="): return loc = page.rfind(" if loc != -1: page = page[:page.rfind(" ext = page[page.rfind(".")+1:].lower() if ext in SKIPEXT: return if page in self.queue: return if page in self.indexed: return self.queue.append(pag... | def add(self, page): if (page not in self.queue) and (page not in self.indexed): self.queue.append(page) |
self.indexed.append(page) | def run(self): while len(self.queue) > 0: print "Queue len:", len(self.queue) page = self.queue.pop() print "Crawling", page self.crawl(page) self.indexed.append(page) | |
if not os.path.exists(CACHEDIR): os.makedirs(CACHEDIR) | def run(): parser = optparse.OptionParser(usage = "usage: %prog [options]") parser.add_option("--version", dest="printversion", action="store_true", help="Display the version information for this program") (options, args) = parser.parse_args() if options.printversion != None: print get_version() return if not os.pat... | |
app = App() | def run(): parser = optparse.OptionParser(usage = "usage: %prog [options]") parser.add_option("--version", dest="printversion", action="store_true", help="Display the version information for this program") (options, args) = parser.parse_args() if options.printversion != None: print get_version() return if not os.pat... | |
items = config.keys() | if options.threaded: items = config.keys() for key in items: app = App(key) app.start() time.sleep(PAUSETIME) return items = config.keys() | def run(): parser = optparse.OptionParser(usage = "usage: %prog [options]") parser.add_option("--version", dest="printversion", action="store_true", help="Display the version information for this program") (options, args) = parser.parse_args() if options.printversion != None: print get_version() return if not os.pat... |
app.add(key) app.run() | app = App(key) app.run() | def run(): parser = optparse.OptionParser(usage = "usage: %prog [options]") parser.add_option("--version", dest="printversion", action="store_true", help="Display the version information for this program") (options, args) = parser.parse_args() if options.printversion != None: print get_version() return if not os.pat... |
if url[0] == "" or url[0] == "http": port = httplib.HTTP_PORT if url[1].find("@") != -1: host = url[1].split("@", 2)[1] else: host = url[1] try: if url.port != None: port = url.port if url.username != None: self.headers["Proxy-authorization"] = "Basic " + base64.encodestring(url.username+':'+url.password) + "\r\n" exc... | if url.scheme == "" or url.scheme == "http": host = url.hostname port = url.port if url.username != None: self.headers["Proxy-authorization"] = "Basic " + base64.encodestring(url.username+':'+url.password) + "\r\n" | def connect(self, host, port=ftplib.FTP_PORT): if FTP_PROXY != "": # parse proxy URL url = urlparse.urlparse(FTP_PROXY) if url[0] == "" or url[0] == "http": port = httplib.HTTP_PORT if url[1].find("@") != -1: host = url[1].split("@", 2)[1] else: host = url[1] try: if url.port != None: port = url.port if url.username !... |
return self.conn.voidcmd(*args) | if FTP_PROXY == "": return self.conn.voidcmd(*args) | def voidcmd(self, *args): return self.conn.voidcmd(*args) |
self.host.reconnect() | try: self.host.reconnect() except: pass | def run(self): # Finish early if checksum is OK if self.checksum() and len(self.checksums) > 0: self.bytes += self.byte_count self.close() return # check for supported hosts/urls urlparts = urlparse.urlsplit(self.url) if self.host.conn == None: #print "bad socket" self.error = _("bad socket") self.close() return size... |
if metalinkobj == False: | if not metalinkobj: | def check_metalink(self, src): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL or file path to download from Returns the results of the check in a dictonary ''' self.running = True src = download.complete_url(src) try: metalinkobj = download.parse_metalink(src, nocheck=False) ... |
size = filenode.size name = filenode.filename | def check_metalink(self, src): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL or file path to download from Returns the results of the check in a dictonary ''' self.running = True src = download.complete_url(src) try: metalinkobj = download.parse_metalink(src, nocheck=False) ... | |
type = "" | typestr = "" | def _check_process(self, headers, filesize, checksums = {}): size = "?" checksum = "?" sizeheader = self._get_header(headers, "Content-Length") # digest code, untested since no servers seem to support this digest = self._get_header(headers, "Content-MD5") if digest != None: try: if binascii.hexlify(binascii.a2b_base6... |
type = "sha1" | typestr = "sha1" | def _check_process(self, headers, filesize, checksums = {}): size = "?" checksum = "?" sizeheader = self._get_header(headers, "Content-Length") # digest code, untested since no servers seem to support this digest = self._get_header(headers, "Content-MD5") if digest != None: try: if binascii.hexlify(binascii.a2b_base6... |
type = "md5" | typestr = "md5" | def _check_process(self, headers, filesize, checksums = {}): size = "?" checksum = "?" sizeheader = self._get_header(headers, "Content-Length") # digest code, untested since no servers seem to support this digest = self._get_header(headers, "Content-MD5") if digest != None: try: if binascii.hexlify(binascii.a2b_base6... |
if type != "" and checksum == "?": | if typestr != "" and checksum == "?": | def _check_process(self, headers, filesize, checksums = {}): size = "?" checksum = "?" sizeheader = self._get_header(headers, "Content-Length") # digest code, untested since no servers seem to support this digest = self._get_header(headers, "Content-MD5") if digest != None: try: if binascii.hexlify(binascii.a2b_base6... |
if binascii.hexlify(binascii.a2b_base64(value)).lower() == checksums[type].lower(): | if binascii.hexlify(binascii.a2b_base64(value)).lower() == checksums[typestr].lower(): | def _check_process(self, headers, filesize, checksums = {}): size = "?" checksum = "?" sizeheader = self._get_header(headers, "Content-Length") # digest code, untested since no servers seem to support this digest = self._get_header(headers, "Content-MD5") if digest != None: try: if binascii.hexlify(binascii.a2b_base6... |
if result != False: | if result: | def get(src, path, checksums = {}, force = False, handlers = {}, segmented = SEGMENTED, headers = {}): ''' Download a file, decodes metalinks. First parameter, file to download, URL or file path to download from Second parameter, file path to save to Third parameter, optional, expected dictionary of checksums Fourth pa... |
type = "" | typestr = "" | def parse_metalink(src, headers = {}, nocheck = False, ver=3): src = complete_url(src) is_metalink = nocheck # not all servers support HEAD where GET is also supported # also a WindowsError is thrown if a local file does not exist if src.endswith(".metalink") or src.endswith(".meta4"): is_metalink = True try: # add he... |
type = mydict["type"] | typestr = mydict["type"] | def parse_metalink(src, headers = {}, nocheck = False, ver=3): src = complete_url(src) is_metalink = nocheck # not all servers support HEAD where GET is also supported # also a WindowsError is thrown if a local file does not exist if src.endswith(".metalink") or src.endswith(".meta4"): is_metalink = True try: # add he... |
fileobj.add_url(parts[0].strip(" <>"), type=type, priority=pri) | fileobj.add_url(parts[0].strip(" <>"), type=typestr, priority=pri) | def parse_metalink(src, headers = {}, nocheck = False, ver=3): src = complete_url(src) is_metalink = nocheck # not all servers support HEAD where GET is also supported # also a WindowsError is thrown if a local file does not exist if src.endswith(".metalink") or src.endswith(".meta4"): is_metalink = True try: # add he... |
for hash in hashes: parts = hash.split("=", 1) | for myhash in hashes: parts = myhash.split("=", 1) | def parse_metalink(src, headers = {}, nocheck = False, ver=3): src = complete_url(src) is_metalink = nocheck # not all servers support HEAD where GET is also supported # also a WindowsError is thrown if a local file does not exist if src.endswith(".metalink") or src.endswith(".meta4"): is_metalink = True try: # add he... |
if rssobj == False: | if not rssobj: | def download_rss(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): rssobj = parse_rss(src, headers) if rssobj == False: return False urllist = rssobj.files if len(urllist) == 0: print _("No enclosures to download files from.") return False results = [] for rssitem in urll... |
headers = headers.copy() metalinkobj = parse_metalink(src, headers, nocheck) if metalinkobj == False: | myheaders = headers.copy() metalinkobj = parse_metalink(src, myheaders, nocheck) if not metalinkobj: | def download_metalink(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL, file path or Metalink object to download from Second parameter, file path to save to Third parameter, optional,... |
headers['referer'] = src | myheaders['referer'] = src | def download_metalink(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL, file path or Metalink object to download from Second parameter, file path to save to Third parameter, optional,... |
return download_metalink(origin, path, force, handlers, segmented, headers) | return download_metalink(origin, path, force, handlers, segmented, myheaders) | def download_metalink(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL, file path or Metalink object to download from Second parameter, file path to save to Third parameter, optional,... |
result = download_file_node(filenode, path, force, handlers, segmented, headers) | result = download_file_node(filenode, path, force, handlers, segmented, myheaders) | def download_metalink(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL, file path or Metalink object to download from Second parameter, file path to save to Third parameter, optional,... |
def run(self): | def run(self, wait=0.1): | def run(self): ''' ? ''' #try: if self.size == "" or self.size == 0: self.size = self.get_size() if self.size == None: #crap out and do it the old way self.close_handler() self.status = False return False |
return Manager.run(self, 0.1) | return Manager.run(self, wait) | def run(self): ''' ? ''' #try: if self.size == "" or self.size == 0: self.size = self.get_size() if self.size == None: #crap out and do it the old way self.close_handler() self.status = False return False |
resp = self._read_response(child_stderr, result) | self._read_response(child_stderr, result) | def _handle_gigo(self, args, file, result): ''' Handle a basic data call - pass data to GPG, handle the output including status information. Garbage In, Garbage Out :) ''' child_stdout, child_stdin, child_stderr = self._open_subprocess(*args) |
file = StringIO.StringIO(data) return self.verify_file(file) | fileobj = StringIO.StringIO(data) return self.verify_file(fileobj) | def verify(self, data): ''' Verify the signature on the contents of the string 'data' ''' file = StringIO.StringIO(data) return self.verify_file(file) |
resp = self._read_response(child_stderr, result) | self._read_response(child_stderr, result) | def import_key(self, key_data): ''' import the key_data into our keyring ''' child_stdout, child_stdin, child_stderr = \ self._open_subprocess('--import') |
file = StringIO.StringIO(data) return self.encrypt_file(file, recipients) | fileobj = StringIO.StringIO(data) return self.encrypt_file(fileobj, recipients) | def encrypt(self, data, recipients): '''Encrypt the message contained in the string "data"''' file = StringIO.StringIO(data) return self.encrypt_file(file, recipients) |
print "not implemented, header length", length_octets | print "not implemented, header length", octet1 | def decode_header(binary_data): ''' Decodes the header of a PGP formatted string. ''' results = {} packet_header = ord(binary_data[0]) binary_data = binary_data[1:] format = (packet_header & 0x40) >> 6 if format == 1: # new format packet #print "not implemented, new packet format" results["content_tag"] = packet_he... |
piecenum = 0 | def scan_file(self, filename, use_chunks=True, max_chunks=255, chunk_size=256, progresslistener=None): print "\nScanning file..." # Filename and size self.filename = os.path.basename(filename) self.size = int(os.stat(filename).st_size) # Calculate piece length if use_chunks: minlength = chunk_size*1024 self.piecelength... | |
if get_first(result) == False: | if not get_first(result): | def scan_file(self, filename, use_chunks=True, max_chunks=255, chunk_size=256, progresslistener=None): print "\nScanning file..." # Filename and size self.filename = os.path.basename(filename) self.size = int(os.stat(filename).st_size) # Calculate piece length if use_chunks: minlength = chunk_size*1024 self.piecelength... |
piecehash = sha.new() | piecehash = hashlib.sha1() | def scan_file(self, filename, use_chunks=True, max_chunks=255, chunk_size=256, progresslistener=None): print "\nScanning file..." # Filename and size self.filename = os.path.basename(filename) self.size = int(os.stat(filename).st_size) # Calculate piece length if use_chunks: minlength = chunk_size*1024 self.piecelength... |
for id in range(len(self.pieces)): text += ' <hash>'+self.pieces[id]+'</hash>\n' | for idstr in range(len(self.pieces)): text += ' <hash>'+self.pieces[idstr]+'</hash>\n' | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # Publisher info if self.publisher_name.strip() != "" or self.publisher_url.strip() != "": lictext = "" if self.publisher_name.strip() != "": lictext += ' name="' + self.publisher_name + '... |
for id in range(len(self.pieces)): text += ' <hash piece="'+str(id)+'">'+self.pieces[id]+'</hash>\n' | for idstr in range(len(self.pieces)): text += ' <hash piece="'+str(idstr)+'">'+self.pieces[idstr]+'</hash>\n' | def generate_file(self): if self.filename.strip() != "": text = ' <file name="' + self.filename + '">\n' else: text = ' <file>\n' # File info if self.size > 0: text += ' <size>'+str(self.size)+'</size>\n' if self.language.strip() != "": text += ' <language>'+self.language+'</language>\n' if self.os.stri... |
type = "bittorrent" | typestr = "bittorrent" | def validate_url(self, url): if url.endswith(".torrent"): type = "bittorrent" else: chars = url.find(":") type = url[:chars] allowed_types = ["ftp", "ftps", "http", "https", "rsync", "bittorrent", "magnet", "ed2k"] if not type in allowed_types: return False elif type in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: m... |
type = url[:chars] | typestr = url[:chars] | def validate_url(self, url): if url.endswith(".torrent"): type = "bittorrent" else: chars = url.find(":") type = url[:chars] allowed_types = ["ftp", "ftps", "http", "https", "rsync", "bittorrent", "magnet", "ed2k"] if not type in allowed_types: return False elif type in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: m... |
if not type in allowed_types: | if not typestr in allowed_types: | def validate_url(self, url): if url.endswith(".torrent"): type = "bittorrent" else: chars = url.find(":") type = url[:chars] allowed_types = ["ftp", "ftps", "http", "https", "rsync", "bittorrent", "magnet", "ed2k"] if not type in allowed_types: return False elif type in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: m... |
elif type in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: | elif typestr in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: | def validate_url(self, url): if url.endswith(".torrent"): type = "bittorrent" else: chars = url.find(":") type = url[:chars] allowed_types = ["ftp", "ftps", "http", "https", "rsync", "bittorrent", "magnet", "ed2k"] if not type in allowed_types: return False elif type in ['http', 'https', 'ftp', 'ftps', 'bittorrent']: m... |
setattr(self, "tags", self.data.strip()) | self.tags = self.data.strip() | def end_element(self, name): xmlns, name = name.rsplit(XMLSEP, 1) if xmlns != self.XMLNS and xmlns != "": return tag = self.parent.pop() |
setattr(self, "dynamic", tag.attrs["dynamic"]) | self.dynamic = tag.attrs["dynamic"] | def end_element(self, name): xmlns, name = name.rsplit(XMLSEP, 1) if xmlns != self.XMLNS: return tag = self.parent.pop() |
type = self.handle.read(4) | typestr = self.handle.read(4) | def get_chunk(self): type = self.handle.read(4) #print "type:", type length = int(binascii.hexlify(self.handle.read(6)[::-1]), 16) value = self.handle.read(length-10) if type == "BZIP": uncompressed = int(binascii.hexlify(value[:6][::-1]), 16) data = value[6:] data = bz2.decompress(data) assert(len(data) == uncompress... |
if type == "BZIP": | if typestr == "BZIP": | def get_chunk(self): type = self.handle.read(4) #print "type:", type length = int(binascii.hexlify(self.handle.read(6)[::-1]), 16) value = self.handle.read(length-10) if type == "BZIP": uncompressed = int(binascii.hexlify(value[:6][::-1]), 16) data = value[6:] data = bz2.decompress(data) assert(len(data) == uncompress... |
elif type == "DATA": | elif typestr == "DATA": | def get_chunk(self): type = self.handle.read(4) #print "type:", type length = int(binascii.hexlify(self.handle.read(6)[::-1]), 16) value = self.handle.read(length-10) if type == "BZIP": uncompressed = int(binascii.hexlify(value[:6][::-1]), 16) data = value[6:] data = bz2.decompress(data) assert(len(data) == uncompress... |
rsync = value[:8] | def mkiso(self): # go to the end to read the DESC section readhandle = open(os.path.basename(self.template), "rb") readhandle.seek(-6, 2) desclen = int(binascii.hexlify(readhandle.read(6)[::-1]), 16) readhandle.seek(-(desclen-10), 2) value = readhandle.read() # index DESC section into list chunks = [] count= 0 while l... | |
blocklen = int(binascii.hexlify(value[16:20][::-1]), 16) | def mkiso(self): # go to the end to read the DESC section readhandle = open(os.path.basename(self.template), "rb") readhandle.seek(-6, 2) desclen = int(binascii.hexlify(readhandle.read(6)[::-1]), 16) readhandle.seek(-(desclen-10), 2) value = readhandle.read() # index DESC section into list chunks = [] count= 0 while l... | |
if getattr(metalinkobj4, 'dynamic').lower() == "true": setattr(metalinkobj3, 'type', 'dynamic') | if metalinkobj4.dynamic.lower() == "true": metalinkobj3.type = 'dynamic' | def convert_4to3(metalinkobj4): metalinkobj3 = Metalink() for attr in ('generator', 'origin'): setattr(metalinkobj3, attr, getattr(metalinkobj4, attr)) if getattr(metalinkobj4, 'dynamic').lower() == "true": setattr(metalinkobj3, 'type', 'dynamic') if metalinkobj4.published != "": metalinkobj3.pubdate = time.strftime(... |
self.p = xml.parsers.expat.ParserCreate() | self.p = xml.parsers.expat.ParserCreate(namespace_separator=XMLSEP) self.p.buffer_text = True | def __init__(self): self.errors = [] self.files = [] self.generator = GENERATOR self.origin = "" |
text += '<metalink version="3.0" '+origin + typetext + gentext + 'xmlns="http://www.metalinker.org/">\n' | text += '<metalink version="3.0" '+origin + typetext + gentext + 'xmlns="' + self.XMLNS + '">\n' | def generate(self): text = '<?xml version="1.0" encoding="utf-8"?>\n' origin = "" if self.origin.strip() != "": origin = 'origin="'+self.origin+'" ' typetext = "" if self.type.strip() != "": typetext = 'type="'+self.type+'" ' gentext = "" if self.generator.strip() != "": gentext = 'generator="'+self.generator+'" ' text... |
text += '<metalink xmlns="urn:ietf:params:xml:ns:metalink">\n' | text += '<metalink xmlns="' + self.XMLNS + '">\n' | def generate(self): text = '<?xml version="1.0" encoding="utf-8"?>\n' text += '<metalink xmlns="urn:ietf:params:xml:ns:metalink">\n' |
xmlns = "" | if name.startswith("http://www.metalinker.org"): raise AssertionError, "Not a valid Metalink 4 (RFC) file." | def start_element(self, name, attrs): xmlns = "" self.data = "" self.parent.append(XMLTag(name, attrs)) if name == "file": fileobj = MetalinkFile4(attrs["name"], attrs) self.files.append(fileobj) if name == "metalink": try: xmlns = attrs["xmlns"] except KeyError: pass if xmlns != "urn:ietf:params:xml:ns:metalink": rai... |
if name == "metalink": try: xmlns = attrs["xmlns"] except KeyError: pass if xmlns != "urn:ietf:params:xml:ns:metalink": raise AssertionError, "Not a valid Metalink 4 (RFC) file." | def start_element(self, name, attrs): xmlns = "" self.data = "" self.parent.append(XMLTag(name, attrs)) if name == "file": fileobj = MetalinkFile4(attrs["name"], attrs) self.files.append(fileobj) if name == "metalink": try: xmlns = attrs["xmlns"] except KeyError: pass if xmlns != "urn:ietf:params:xml:ns:metalink": rai... | |
for attr in ('filename', 'pieces', 'piecelength', 'piecetype', 'language', 'os', 'size'): | for attr in ('filename', 'pieces', 'piecelength', 'language', 'os', 'size'): | def convert_4to3(metalinkobj4): metalinkobj3 = Metalink() for attr in ('generator', 'origin'): setattr(metalinkobj3, attr, getattr(metalinkobj4, attr)) if getattr(metalinkobj4, 'dynamic').lower() == "true": setattr(metalinkobj3, 'type', 'dynamic') if metalinkobj4.published != "": metalinkobj3.pubdate = time.strftime(... |
if not result: | if result: | def get(src, path, checksums = {}, force = False, handlers = {}, segmented = SEGMENTED, headers = {}): ''' Download a file, decodes metalinks. First parameter, file to download, URL or file path to download from Second parameter, file path to save to Third parameter, optional, expected dictionary of checksums Fourth pa... |
ed = dialogs.ErrorDialog(_("Could not find configuration directory in GConf"), _("Please make sure that gget.schemas was correctly installed.")) | ed = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("Could not find configuration directory in GConf")) ed.format_secondary_text(_("Please make sure that gget.schemas was correctly installed.")) ed.set_title(_("Error")) | def __init(self, *args): self.debug = args[0] or os.getenv("GGET_DEBUG") self.base_dir = os.path.expanduser(os.path.join(XDG_CONFIG_DIR, "gget")) if not os.path.exists(self.base_dir): os.makedirs(self.base_dir) |
if result: | if result != None: | def get(src, path, checksums = {}, force = False, handlers = {}, segmented = SEGMENTED, headers = {}): ''' Download a file, decodes metalinks. First parameter, file to download, URL or file path to download from Second parameter, file path to save to Third parameter, optional, expected dictionary of checksums Fourth pa... |
return False | return None | def download_metalink(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}, nocheck = False): ''' Decode a metalink file, can be local or remote First parameter, file to download, URL, file path or Metalink object to download from Second parameter, file path to save to Third parameter, optional,... |
if url.scheme == "" or url.scheme == "http": host = url.hostname port = url.port if url.username != None: self.headers["Proxy-authorization"] = "Basic " + base64.encodestring(url.username+':'+url.password) + "\r\n" | if url[0] == "" or url[0] == "http": port = httplib.HTTP_PORT if url[1].find("@") != -1: host = url[1].split("@", 2)[1] else: host = url[1] try: if url.port != None: port = url.port if url.username != None: self.headers["Proxy-authorization"] = "Basic " + base64.encodestring(url.username+':'+url.password) + "\r\n" exc... | def connect(self, host, port=ftplib.FTP_PORT): if FTP_PROXY != "": # parse proxy URL url = urlparse.urlparse(FTP_PROXY) if url.scheme == "" or url.scheme == "http": host = url.hostname port = url.port if url.username != None: self.headers["Proxy-authorization"] = "Basic " + base64.encodestring(url.username+':'+url.pass... |
if FTP_PROXY == "": return self.conn.voidcmd(*args) | return self.conn.voidcmd(*args) | def voidcmd(self, *args): if FTP_PROXY == "": return self.conn.voidcmd(*args) |
if metalinkfile.size == 0 and not os.path.exists(metalinkfile.filename + ".temp"): handlers["status"](1, actsize, actsize) print "" print _("Already downloaded %s.") % os.path.basename(metalinkfile.filename) return metalinkfile.filename | if os.path.exists(metalinkfile.filename + ".temp"): print _("Resuming download of %s.") % os.path.basename(metalinkfile.filename) | def download_file_urls(metalinkfile, force = False, handlers = {}, segmented = SEGMENTED, headers = {}): ''' Download a file. MetalinkFile object to download Second parameter, optional, force a new download even if a valid copy already exists Third parameter, optional, progress handler callback Fourth parameter, option... |
self.headers = headers | self.headers = headers.copy() | def __init__(self, metalinkfile, headers = {}): Manager.__init__(self) self.local_file = metalinkfile.filename self.size = metalinkfile.size self.chunksums = metalinkfile.get_piece_dict() self.checksums = metalinkfile.hashlist self.urllist = start_sort(metalinkfile.get_url_dict()) self.start_number = 0 self.number = 0 ... |
headers = self.temp.info() | myheaders = self.temp.info() | def __init__(self, remote_file, filename, checksums = {}, headers = {}): ''' modernized replacement for urllib.urlretrieve() for use with proxy ''' Manager.__init__(self) self.filename = filename self.checksums = checksums self.block_size = 1024 self.counter = 0 self.total = 0 |
self.size = int(headers['Content-Length']) | self.size = int(myheaders['Content-Length']) | def __init__(self, remote_file, filename, checksums = {}, headers = {}): ''' modernized replacement for urllib.urlretrieve() for use with proxy ''' Manager.__init__(self) self.filename = filename self.checksums = checksums self.block_size = 1024 self.counter = 0 self.total = 0 |
jigdo.mkiso() | md5 = jigdo.mkiso() checksum = verify_checksum(jigdo.filename, {'md5': md5}) if not checksum: print _("Checksum failed.") | def download_jigdo(src, path, force = False, handlers = {}, segmented = SEGMENTED, headers = {}): ''' Decode a jigdo file, can be local or remote First parameter, file to download, URL or file path to download from Second parameter, file path to save to Third parameter, optional, force a new download even if a valid co... |
Downloads a specific version of a program | def download_file_node(item, path, force = False, handler = None, segmented=SEGMENTED, headers = {}): ''' Downloads a specific version of a program First parameter, file XML node Second parameter, file path to save to Third parameter, optional, force a new download even if a valid copy already exists Fouth parameter, o... | |
urllist = {} | urllist = [] | def download_file_node(item, path, force = False, handler = None, segmented=SEGMENTED, headers = {}): ''' Downloads a specific version of a program First parameter, file XML node Second parameter, file path to save to Third parameter, optional, force a new download even if a valid copy already exists Fouth parameter, o... |
urllist[node.url] = node | urllist.append(node.url) | def download_file_node(item, path, force = False, handler = None, segmented=SEGMENTED, headers = {}): ''' Downloads a specific version of a program First parameter, file XML node Second parameter, file path to save to Third parameter, optional, force a new download even if a valid copy already exists Fouth parameter, o... |
hashes = item.hashlist size = item.size | def download_file_node(item, path, force = False, handler = None, segmented=SEGMENTED, headers = {}): ''' Downloads a specific version of a program First parameter, file XML node Second parameter, file path to save to Third parameter, optional, force a new download even if a valid copy already exists Fouth parameter, o... | |
chunksize = item.piecelength chunksums = {} chunksums[item.piecetype] = item.pieces | def download_file_node(item, path, force = False, handler = None, segmented=SEGMENTED, headers = {}): ''' Downloads a specific version of a program First parameter, file XML node Second parameter, file path to save to Third parameter, optional, force a new download even if a valid copy already exists Fouth parameter, o... | |
headers = temp.info() | myheaders = temp.info() | def urlretrieve(url, filename, reporthook = None, headers = {}): ''' modernized replacement for urllib.urlretrieve() for use with proxy ''' block_size = 1024 i = 0 counter = 0 temp = urlopen(url, headers = headers) headers = temp.info() try: size = int(headers['Content-Length']) except KeyError: size = 0 data = open(... |
size = int(headers['Content-Length']) | size = int(myheaders['Content-Length']) | def urlretrieve(url, filename, reporthook = None, headers = {}): ''' modernized replacement for urllib.urlretrieve() for use with proxy ''' block_size = 1024 i = 0 counter = 0 temp = urlopen(url, headers = headers) headers = temp.info() try: size = int(headers['Content-Length']) except KeyError: size = 0 data = open(... |
self.headers = headers | self.headers = headers.copy() | def __init__(self, metalinkfile, headers = {}): Manager.__init__(self) |
self.headers = headers | self.headers = headers.copy() | def __init__(self, host, start, end, filesize, checksums = {}, headers = {}): threading.Thread.__init__(self) self.host = host self.host.set_active(True) self.byte_start = start self.byte_end = end self.byte_count = end - start self.filesize = filesize self.url = host.url self.mem = host.mem self.checksums = checksums ... |
headers.update(self.headers) | myheaders = headers.copy() myheaders.update(self.headers) | def request(self, method, url, body="", headers={}): ''' raise socket.error e.g. "Operation timed out" ''' headers.update(self.headers) |
return self.conn.request(method, url, body, headers) | return self.conn.request(method, url, body, myheaders) | def request(self, method, url, body="", headers={}): ''' raise socket.error e.g. "Operation timed out" ''' headers.update(self.headers) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.