Exemple #1
0
 def on_button4_click_event(self, event):
     path.local_path = self.m_dirPicker1.GetPath()
     path.udisk_path = self.m_dirPicker2.GetPath()
     local_path_test = path_win.is_path_valid_and_is_project_exists(
         path.local_path)
     udisk_path_test = path_win.is_path_valid_and_is_project_exists_and_is_dir_same(
         path.udisk_path)
     self.m_staticText3.SetLabelText("")
     if local_path_test and udisk_path_test:
         sync.init_local()
         sync.fully_push(path.local_path, path.udisk_path)
         self.m_staticText3.SetLabelText("执行全量push完成,程序正常退出!")
     else:
         self.m_staticText3.SetLabelText("路径选择错误,请重新选择")
Exemple #2
0
def test_run_time():
    test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path
    test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path
    test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path
    tmp1()
    # 2.初始化
    sync.init_local()
    sync.init_udisk()
    # 3.1.全量push
    sync.fully_push(path.local_path, path.udisk_path)
    # 3.2.全量pull
    path.local_path = test_remote_path
    sync.fully_pull(path.udisk_path, path.local_path)
    # 4.本地新增文件
    tmp2()
    # 10.本地增量push、远程增量pull
    path.local_path = test_local_path
    path.udisk_path = test_udisk_path
    sync.incrementally_push()
    path.local_path = test_remote_path
    sync.incrementally_pull()
Exemple #3
0
def fully_push(local_path, udisk_path):
    sync.fully_push(local_path, udisk_path)
Exemple #4
0
def run():
    print prompt.prompt_init
    num = raw_input(prompt.prompt_init_choose)
    # 获取用户输入,直到输入正确
    while True:
        if not num.isdigit():
            # 输入不是数字字符时,提示再次输入
            num = raw_input(prompt.prompt_choose_again)
        else:
            # 输入为数字字符,字符转换成数
            num = int(num)
            if num == 1 or num == 2 or num == 3 \
                    or num == 4 or num == 5 or num == 6 or num == 7:
                break
            elif num == 8:
                exit()
            else:
                # 输入不是数字1-7时,提示再次输入
                num = raw_input(prompt.prompt_choose_again)

    if num == 1:  # 增量pull
        # 获取路径
        path.local_path = path.get_valid_path_with_project(
            prompt.prompt_local_path)
        path.udisk_path = path.get_valid_path_with_project_same_name(
            prompt.prompt_udisk_path)
        sync.incrementally_pull()
        print "执行增量pull完成,程序正常退出!"
        exit()
    elif num == 2:  # 增量push
        # 获取路径
        path.local_path = path.get_valid_path_with_project(
            prompt.prompt_local_path)
        path.udisk_path = path.get_valid_path_with_project_same_name(
            prompt.prompt_udisk_path)
        sync.incrementally_push()
        print "执行增量push完成,程序正常退出!"
        exit()
    elif num == 3:  # 全量pull
        # 获取路径
        path.local_path = path.get_valid_path_with_path_empty(
            prompt.prompt_local_path)
        path.udisk_path = path.get_valid_path_with_project_same_name_and_all_the_project(
            prompt.prompt_udisk_path)
        # 将U盘.sync目录下的同步目录同步到本地并将U盘的.synchash文件复制到本地 shiweihua
        sync.fully_pull(path.udisk_path, path.local_path)
        print "执行全量pull完成,程序正常退出!"
        exit()
    elif num == 4:  # 全量push
        # 获取路径
        path.local_path = path.get_valid_path_with_project(
            prompt.prompt_local_path)
        path.udisk_path = path.get_valid_path_with_project_same_name(
            prompt.prompt_udisk_path)
        # 本地项目初始化  见本地项目初始化流程图 shiweihua
        sync.init_local()
        # 将本地的所有文件复制到U盘的全量目录下 shiweihua
        sync.fully_push(path.local_path, path.udisk_path)
        print "执行全量push完成,程序正常退出!"
        exit()
    elif num == 5:  # 手动删除U盘上的全量目录
        # 获取路径
        path.udisk_path = path.get_valid_path_with_project(
            prompt.prompt_udisk_path)
        # 检查U盘上是否已经有全量目录 shiweihua
        if os.path.exists(path.udisk_path + os.sep + ".sync" + os.sep +
                          ".all"):
            # 如果有则删除U盘上的全量目录 shiweihua
            shutil.rmtree(path.udisk_path + os.sep + ".sync" + os.sep + ".all")
            print "删除全量目录成功,程序正常退出!"
        else:
            # 如果没有就提示没有全量目录,然后不做任何操作 shiweihua
            print "U盘上并没有全量目录!程序正常退出!"
        exit()
    elif num == 6:  # 初始化本地已有的项目
        # 获取路径
        # 输入本地目录(该目录要满足: 有效性、 不存在项目)
        path.local_path = path.get_valid_path_with_project_is_not_exists(
            prompt.prompt_local_path)
        # 本地项目初始化  见本地项目初始化流程图 shiweihua
        sync.init_local()
        print "本地项目初始化完成,程序正常退出!"
        exit()
    elif num == 7:  # 初始化U盘
        # 获取路径
        # 输入U盘目录(该目录要满足: 有效性、 文件夹为空)
        path.udisk_path = path.get_valid_path_with_path_empty(
            prompt.prompt_udisk_path)
        # 初始化U盘
        sync.init_udisk()
        print "U盘初始化完成,程序正常退出!"
        exit()
Exemple #5
0
def test_cpu_time():
    test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path
    test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path
    test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path
    if os.path.exists(test_local_path + os.path.sep + ".sync"):
        shutil.rmtree(test_local_path + os.path.sep + ".sync")
    if os.path.exists(test_local_path + os.path.sep + "test"):
        shutil.rmtree(test_local_path + os.path.sep + "test")
    if os.path.exists(test_udisk_path):
        shutil.rmtree(test_udisk_path)
    if os.path.exists(test_remote_path):
        shutil.rmtree(test_remote_path)
    os.mkdir(test_udisk_path)
    os.mkdir(test_remote_path)

    # 1.本地新增测试需要的文件夹、文件
    os.mkdir(test_local_path + os.path.sep + "test")
    os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2")
    os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
             os.path.sep + "test3")
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep +
        "update_local_test_1.txt", "w")
    file_temp.write("update_local_test_1.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep +
        "delete_local_test_1.txt", "w")
    file_temp.write("delete_local_test_1.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "update_local_test_2.txt", "w")
    file_temp.write("update_local_test_2.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "delete_local_test_2.txt", "w")
    file_temp.write("delete_local_test_2.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt", "w")
    file_temp.write("update_local_test_3.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt", "w")
    file_temp.write("delete_local_test_3.txt")
    file_temp.close()

    path.local_path = test_local_path
    path.udisk_path = test_udisk_path
    # 2.初始化
    sync.init_local()
    sync.init_udisk()
    # 3.1.全量push
    sync.fully_push(path.local_path, path.udisk_path)
    # 3.2.全量pull
    path.local_path = test_remote_path
    sync.fully_pull(path.udisk_path, path.local_path)
    # 4.本地新增文件
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep +
        "add_local_test_1.txt", "w")
    file_temp.write("add_local_test_1.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "add_local_test_2.txt", "w")
    file_temp.write("add_local_test_2.txt")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "add_local_test_3.txt", "w")
    file_temp.write("add_local_test_3.txt")
    file_temp.close()
    # 5.本地修改文件
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep +
        "update_local_test_1.txt", "w")
    file_temp.write("update_local_test_1.txt local_update")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "update_local_test_2.txt", "w")
    file_temp.write("update_local_test_2.txt local_update")
    file_temp.close()
    file_temp = file(
        test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt", "w")
    file_temp.write("update_local_test_3.txt local_update")
    file_temp.close()
    # 6.本地删除文件
    os.remove(test_local_path + os.path.sep + "test" + os.path.sep +
              "delete_local_test_1.txt")
    os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
              os.path.sep + "delete_local_test_2.txt")
    os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "test2" +
              os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")
    # 7.远程新增文件
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep +
        "add_remote_test_1.txt", "w")
    file_temp.write("add_remote_test_1.txt")
    file_temp.close()
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "add_remote_test_2.txt", "w")
    file_temp.write("add_remote_test_2.txt")
    file_temp.close()
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "add_remote_test_3.txt", "w")
    file_temp.write("add_remote_test_3.txt")
    file_temp.close()
    # 8.远程修改文件
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep +
        "update_local_test_1.txt", "w")
    file_temp.write("update_local_test_1.txt remote_update")
    file_temp.close()
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "update_local_test_2.txt", "w")
    file_temp.write("update_local_test_2.txt remote_update")
    file_temp.close()
    file_temp = file(
        test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
        os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt", "w")
    file_temp.write("update_local_test_3.txt remote_update")
    file_temp.close()
    # 9.远程删除文件
    os.remove(test_remote_path + os.path.sep + "test" + os.path.sep +
              "delete_local_test_1.txt")
    os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
              os.path.sep + "delete_local_test_2.txt")
    os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "test2" +
              os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")
    # 10.本地增量push、远程增量pull
    path.local_path = test_local_path
    path.udisk_path = test_udisk_path
    sync.incrementally_push()
    path.local_path = test_remote_path
    sync.incrementally_pull()