Example #1
0
def delete_deploy(deploy_dir, deploy_version):
	if os.path.isdir(deploy_dir) == False:
		print(u"不存在目录: %s,请确保目录存在!" % (deploy_dir))
		return
	version_dir  = os.path.join(deploy_dir, deploy_version)
	if os.path.isdir(version_dir) == False:
		print(u"不存在版本库目录:%s,将不做任何动作" % (version_dir))
		return
	del_files = []
	for f in os.listdir(deploy_dir):
		if f.startswith(deploy_version):
			del_files.append(os.path.join(deploy_dir, f))
		elif f.find("_to_" + deploy_version) != -1:
			del_files.append(os.path.join(deploy_dir, f))

	my_util.format_table(["file or directory to be delete"], [[f] for f in del_files])
	answer = raw_input("delete these files? (y/n):") 
	if answer == "y":
		os.system("rm -vrf %s" % (" ".join(del_files)))
	else:
		print(u"版本删除已终止")
Example #2
0
def generate_changed_files(all_rev_dir, rev1, rev2):
	if os.path.isdir(all_rev_dir) == False:
		print(u"不存在目录: %s,请确保版本库目录存在!" % (to_dir))
		return
	rev1_dir = os.path.join(all_rev_dir, rev1 + ".revision")
	rev2_dir = os.path.join(all_rev_dir, rev2 + ".revision")
	dict1   = json.loads(open(rev1_dir).read())
	dict2   = json.loads(open(rev2_dir).read())
	to_file = os.path.join(all_rev_dir, "%s_to_%s.change_list" % (rev1, rev2))
	fd      = open(to_file, "w")
	rows    = []
	for f, new_rev in dict2.items():
		old_rev = dict1.get(f, "0")
		if new_rev != old_rev:
			fd.write(str((os.path.getsize(os.path.join(all_rev_dir, rev2, f)) + 1023) / 1024) + "\n")
			fd.write(f + "\n")
			rows.append([f, str(old_rev), str(new_rev)])
	fd.close()
	headers = [u"added or updated file", u"old revision", u"new revision"]
	my_util.format_table(headers, rows)
	print(u"\n差异文件列表生成成功: %s" % (to_file))
	zip_changed_files(all_rev_dir, rev1, rev2, [d[0] for d in rows])
Example #3
0
def delete_deploy(deploy_dir, deploy_version):
    if os.path.isdir(deploy_dir) == False:
        print(u"不存在目录: %s,请确保目录存在!" % (deploy_dir))
        return
    version_dir = os.path.join(deploy_dir, deploy_version)
    if os.path.isdir(version_dir) == False:
        print(u"不存在版本库目录:%s,将不做任何动作" % (version_dir))
        return
    del_files = []
    for f in os.listdir(deploy_dir):
        if f.startswith(deploy_version):
            del_files.append(os.path.join(deploy_dir, f))
        elif f.find("_to_" + deploy_version) != -1:
            del_files.append(os.path.join(deploy_dir, f))

    my_util.format_table(["file or directory to be delete"],
                         [[f] for f in del_files])
    answer = raw_input("delete these files? (y/n):")
    if answer == "y":
        os.system("rm -vrf %s" % (" ".join(del_files)))
    else:
        print(u"版本删除已终止")
Example #4
0
def generate_changed_files(all_rev_dir, rev1, rev2):
    if os.path.isdir(all_rev_dir) == False:
        print(u"不存在目录: %s,请确保版本库目录存在!" % (to_dir))
        return
    rev1_dir = os.path.join(all_rev_dir, rev1 + ".revision")
    rev2_dir = os.path.join(all_rev_dir, rev2 + ".revision")
    dict1 = json.loads(open(rev1_dir).read())
    dict2 = json.loads(open(rev2_dir).read())
    to_file = os.path.join(all_rev_dir, "%s_to_%s.change_list" % (rev1, rev2))
    fd = open(to_file, "w")
    rows = []
    for f, new_rev in dict2.items():
        old_rev = dict1.get(f, "0")
        if new_rev != old_rev:
            fd.write(
                str((os.path.getsize(os.path.join(all_rev_dir, rev2, f)) +
                     1023) / 1024) + "\n")
            fd.write(f + "\n")
            rows.append([f, str(old_rev), str(new_rev)])
    fd.close()
    headers = [u"added or updated file", u"old revision", u"new revision"]
    my_util.format_table(headers, rows)
    print(u"\n差异文件列表生成成功: %s" % (to_file))
    zip_changed_files(all_rev_dir, rev1, rev2, [d[0] for d in rows])