コード例 #1
0
ファイル: update_style.py プロジェクト: liubin-cm/articles
def commit():
    #pdb.set_trace()
    #读取文件http列表
    url_transfer_path()
    #转换为路径
    #提交路径文件
    #两个工作,将新增的多层目录加到提交列表中,然后分组,按组提交
    commit_arr = [[], [], []]
    all_paths = online_paths[0:len(online_paths)]
    temp_paths = []
    for i in all_paths:
        temp_paths.append(i.lower())
    for online_path in online_paths:
        stat = pysvn.st(online_path.strip())
        if len(stat) == 1:
            if stat[0].find('?') == 0 or stat[0].find('is not a working copy') > -1:
                pysvn.py_cmd.command_str = 'svn add --parents "' + online_path.strip() + '"'
                pysvn.py_cmd.is_cmd_succeeded()
                addoutputs = pysvn.py_cmd.get_stdout_lines()
                for addoutput in addoutputs:
                    addoutput_path = addoutput.replace(addoutput[0],'',1).strip()            
                    try:
                        if temp_paths.index(addoutput_path.lower()) > -1:
                            continue
                    except:
                        all_paths.append(addoutput_path)  
                        temp_paths.append(addoutput_path.lower())              
    #分组
    for path in all_paths:
        if path.find(style_online_wks[0]) > -1:
            commit_arr[0].append(path)
        elif path.find(style_online_wks[1]) > -1:
            commit_arr[1].append(path)
        elif path.find(style_online_wks[2]) > -1:
            commit_arr[2].append(path)
    
    return_content = " "
    for index in range(0,len(commit_arr)):
        print(commit_arr[index])
        print("\n\n")
        if len(commit_arr[index]) > 0:
            pywincmds.py_write_svn_message_to_file(os.linesep.join(commit_arr[index]), workspace + os.sep + "changelist.txt")    
            return_content += pysvn.commit_targets(style_online_wks[index], workspace + os.sep + "changelist.txt", style_online_username, style_online_password, content, False)
    
    #发送邮件,确认已提交
    pyemail.send(["*****@*****.**"], content.strip() + "样式已提交", return_content, [])
    pass
コード例 #2
0
ファイル: process.py プロジェクト: liubin-cm/articles
def update_3(flag):
    '''
    py_file需要全局变量, pyfile不能在co_path内
    co_path为更新包路径检出位置
    py_file为更新文件列表存放文件
    '''
    global svn_revision
    pysvn.up("HEAD", site_path, username_online, password_online)
    if os.path.exists(co_path):
        pywincmds.del_dir(co_path)
    pysvn.co(svn_url, svn_revision, co_path, username, password)
    list_tree = pysvn.list_agile('svn list -R', svn_url, username, password)
    for i in range(0,len(list_tree)):
        list_tree[i] = list_tree[i].lower().strip().rstrip("/")
    list_tree_actual = []              
    pywincmds.py_write_svn_message_to_file(svn_url, url_file)
    pywincmds.py_robocopy(co_path, site_path, '.svn _svn', '')
    os.chdir(site_path)
    st = pysvn.st("") #更新文件列表
    #使用svn list url和svn st产生列表的分隔符不一致,下面的方法只适用于windows
    for item in st:
        try:
            if list_tree.index(item.strip().split()[-1].strip().replace("\\", "/").lower()) > -1:
                list_tree_actual.append(item.strip().split()[-1].strip().replace("\\", "/"))
        except:
            pass
    if len(list_tree_actual) == 0:
        print("无更新内容!")
        exit(1)
    list_str = '\n'.join(list_tree_actual).strip()
    pywincmds.py_write_svn_message_to_file(list_str, changelist)
    if flag:
        pywincmds.restart_app_pool(workspace + os.sep + "sbp", apppool)
    if pywincmds.web_check(sit_url, site_keyword, inteveral_time, web_decode):
        #三段启动成功
        svn_revision = pysvn.py_get_svn_info_revision(pysvn.info(co_path, username, password))
        content = "更新包url:" + svn_url + "\n" + "更新包版本:" + svn_revision + "\n\n"
        content = content + "三段差异内容:" + "\n"
        content = content + '\n'.join(st).strip()
        content = content + "\n" + "详情见:" + "\n" + log_url
        title = site_name + "三段更新成功,请测试,谢谢!"
        #邮件
        pyemail.send(to_list, title, content, [])