示例#1
0
def downloadPkgAndExtract(url):
	extractPath = None
	pkgname = None
	pkgf = None
	cwd = None
	pkgname = pkgnameFromPath(url)
	cwd = os.getcwd()
	extractPath = cwd + "/.floatfind/" #  + pkgname + "/"
	fsMisc.ensure_path(True,extractPath)
	os.chdir(extractPath)
	download(url)
	extractPath = debExtract(extractPath + pkgname + ".deb")
	os.chdir(cwd) # go back to the orig dir to not create dirs inside dirs
	return extractPath
示例#2
0
def arExtract(filename, tempdir=None):
	# print "arExtract:: filename = ", filename
	dirname = "ARextracted"
	cwd = os.getcwd()
	if tempdir:
		# print "* tempdir specified ", tempdir
		fsMisc.ensure_path(True,tempdir)
		# print "* changing dir to ", tempdir
		os.chdir(tempdir)
	print "* Creating dir ",dirname
	os.mkdir(dirname)
	print "* Changing dir to ",dirname
	os.chdir(dirname)
	ardir = os.getcwd()
	arExtractArchive(filename)
	os.chdir(cwd)
	return ardir
示例#3
0
def WriteCert(tofilename, cert): # expects cert to already be a string of hexadecimals pairs each representing a byte
	# print "CERT_DIR = ",CERT_DIR
	# print "CERT_DLL = ",CERT_DLL
	f = None # file "handle"
	cert_byte = cert.decode('hex')
	fsMisc.ensure_path(True,CERT_DIR)
	# print "tofilename = ",tofilename
	# print "cert = ", cert
	shutil.copy(CERT_DLL, tofilename)
	try:
		f = open(tofilename,'r+b')
	except:
		# print "Faild to open %s" % tofilename
		return CERT_SYST_ERROR
	if not LocateCert(f,None):
		return CERT_LOCATE_ERROR
	# print "f's position: ",f.tell()
	f.write(cert_byte)
	f.close()
	return CERT_SUCCESS
示例#4
0
def debExtract(filename,tempdir=None):
#	print "debExtract:: filename = ",filename
	dirname = pkgnameFromPath(filename)
	cwd = os.getcwd()
	if tempdir:
#		print "* tempdir specified ", tempdir
		fsMisc.ensure_path(True,tempdir)
#		print "* changing dir to ", tempdir
		os.chdir(tempdir)
	print "* Creating dir ",dirname
	os.mkdir(dirname)
	print "* Changing dir to",dirname
	os.chdir(dirname)
	pkgdir = os.getcwd()                                                                                                                                
	# pkgf = file(cwd+"/"+filename)
	pkgf = file(filename)
	# print "trying to extract ",cwd+"/"+filename
#	print "* trying to extract ", filename
	apt_inst.debExtractArchive(pkgf)
	os.chdir(cwd)
	return pkgdir # returning the path where we extracted