Beispiel #1
0
	def setUp(self):
		set_spring_dir(self.test_dir)

		# Speed up the test because if pool is present the 256 pool
		# directories are created on demand instead of beforehand.
		mkdir_p(rapid.pool_dir)

		if True:   # False to use real Downloader, True to use MockDownloader
			self.downloader = MockDownloader()
			self.rapid = Rapid(self.downloader)
			www = self.downloader.www
			www[master_url] = gzip_string(',http://ts1,,\n')
			# The last two packages have an identical name. This should not
			# actually happen in practice (leaves no good way to normalize
			# versions.gz), though it did happen once. (#9)
			# So it's present here to test that rapid handles it properly.
			www['http://ts1/versions.gz'] = gzip_string('xta:latest,1234,dependency,XTA 9.6\n,5678,,dependency\n,90AB,,dependency\n')
			www['http://ts1/packages/1234.sdp'] = gzip_string('\3foo' + binascii.unhexlify('d41d8cd98f00b204e9800998ecf8427e') + 8 * '\0')
			www['http://ts1/packages/5678.sdp'] = gzip_string('')
			www['http://ts1/packages/90AB.sdp'] = gzip_string('')
			www['http://ts1/streamer.cgi?1234'] = struct.pack('>L', len(gzip_string(''))) + gzip_string('')
		else:
			self.downloader = Downloader()
			self.rapid = Rapid(self.downloader)
Beispiel #2
0
import binascii, gzip, os
from rapid.rapid import Rapid, set_spring_dir

path = os.path.abspath("tmp")
dest = os.path.abspath("parse")

if not os.path.exists(dest):
    os.mkdir(dest)

set_spring_dir(path)
rapid = Rapid()


def process(p):
    print "processing", p.name

    print "  downloading sdp package file"
    files = [f for f in p.files if f.name.endswith(".lua")]

    print "  downloading lua files"
    p.download_files(files)

    print "  unpacking lua files"
    for f in files:
        cont = gzip.GzipFile(f.pool_path).read()
        md5 = binascii.hexlify(f.md5)
        with file(os.path.join(dest, md5) + ".lua", "w") as w:
            w.write(cont.replace("\r", "").rstrip())
            w.write("\n")
            w.write("-- package name : " + p.name + "\n")
            w.write("-- package hex  : " + p.hex + "\n")
Beispiel #3
0
	def setUp(self):
		set_spring_dir(self.test_dir)
		mkdir_p(rapid.content_dir)
		self.pt = PinnedTags()