Пример #1
0
def generate_manifest(cookies, url, path):
	if not url.endswith('/'):
		url = url + '/'

	# We need the forged content, not the original files!
	build(cookies, path, 'reload')

	manifest = {}
	src_path = os.path.join(path, "development", "reload", "src")

	output_path = tempfile.mkdtemp('reload_manifest')

	for root, dirs, files in os.walk(src_path):
		for index, dir_ in enumerate(dirs):
			if dir_ in ('.hg', '.git',):
				del dirs[index]

		for file_ in files:
			full_path = os.path.join(root, file_)
			rel_path = os.path.relpath(full_path, src_path)
			with async.current_call().io_lock:
				with open(full_path) as in_file:
					hash_ = hashlib.sha1()
					while True:
						buf = in_file.read(0x100000)
						if not buf:
							break
						hash_.update(buf)
			hash_value = hash_.hexdigest()

			shutil.copyfile(full_path, os.path.join(output_path, hash_value))
			manifest[rel_path] = url + hash_value
			print "copied", full_path, "to", os.path.join(output_path, hash_value)
Пример #2
0
def push(cookies, path, stream_name):
	# Override cookies for any new remote objects
	from forge import remote
	remote.override_cookies = cookies

	build(cookies, path, 'reload')
	with cd(path):
		forge_main.handle_primary_options(['reload', 'push', stream_name])
		forge_main.handle_secondary_options('reload', ['push', stream_name])
		forge_main.reload(['push', stream_name])