22 tar = tarfile.open(tar_path, mode=mode_string)
23 for input_file_name
in files:
25 archive_file_name = input_file_name[len(client_root):]
27 archive_file_name = archive_file_name.replace(
"\\",
"/")
29 with open(input_file_name,
'rb')
as input_file:
30 tarInfo = tarfile.TarInfo(name=archive_file_name)
32 tarInfo.size = input_file.tell()
35 tar.addfile(tarInfo, fileobj=input_file)
38 with open(tar_path,
"rb")
as fin:
39 uncompressed = fin.read()
40 with open(tar_path,
"wb")
as fout:
42 gz = gzip.GzipFile(fileobj=fout, mode=
"wb", filename=
"", mtime=0)
43 gz.write(uncompressed)
48 if not options.client_root:
49 sys.stderr.write(
'--client_root not specified')
53 for dirname, dirnames, filenames
in os.walk(options.client_root):
55 filenames = [f
for f
in filenames
if not f[0] ==
'.']
56 dirnames[:] = [d
for d
in dirnames
if not d[0] ==
'.']
58 src_path = os.path.join(dirname, f)
59 if (os.path.isdir(src_path)):
61 files.append(src_path)
118 if not options.output:
119 sys.stderr.write(
'--output not specified\n')
122 sys.stderr.write(
'--name not specified\n')
124 if not options.tar_input:
125 sys.stderr.write(
'--tar_input not specified\n')
129 with open(options.tar_input,
'rb')
as tar_file:
130 tar_archive = tar_file.read()
133 WriteCCFile(options.output, options.outer_namespace,
134 options.inner_namespace, options.name, tar_archive)