Пример #1
0
 def commit_offline(self,site_name):
     product_dir = self.workspace + os.sep + self.sites[site_name]["product_dir"]
     online_dir = self.workspace + os.sep + self.sites[site_name]["online_dir"]
     site_dir = self.workspace + os.sep +  self.sites[site_name]["site_dir"]
     pywincmds.del_all_except_hidden_directories(product_dir)
     pywincmds.robocopy(online_dir, product_dir, py_exclude_dirs=".svn _svn")
     try:
         self.substitute(site_dir + os.sep + "config_test" + os.sep + "config", product_dir + os.sep + self.sites[site_name]["config"])
         self.substitute(site_dir + os.sep + "config_test" + os.sep + self.sites[site_name]["web_config"]["config_test"], product_dir + os.sep + self.sites[site_name]["web_config"]["online"])
     except:
         pass
     pywincmds.robocopy(site_dir + os.sep + "config_online", product_dir + os.sep + "Config_online", py_exclude_dirs = ".svn _svn")
     os.chdir(product_dir + os.sep + "Config_online")
     os.rename(self.sites[site_name]["web_config"]["config_online"], self.sites[site_name]["web_config"]["online"])
     os.chdir(online_dir)
     lines = pysvn.st("")
     lines = [line.strip() for line in lines]
     if len(lines) == 0:
         pyemail.send(self.to_list, site_name + "无变化内容", "")
         return
     else:
         pywincmds.py_write_svn_message_to_file("\n".join(lines), product_dir + os.sep + "changelist.txt")
         if os.path.exists(self.getversion_exe):
             pywincmds.call_cmd(self.getversion_exe + " \"" + self.sourcecode_dir + "\"")
             time.sleep(10)
             #pywincmds.copy(self.sourcecode_dir + os.sep + "my_version.txt", self.product_dir + os.sep + self.site_names[site_name] + os.sep + "revision_numbers.txt")
         svn_log_message = "sourcecode : " + pysvn.py_get_svn_info_url(site_dir, self.sourcecode_username, self.sourcecode_password) + '\n' + "version number : " + pysvn.py_get_svn_info_revision(site_dir, self.sourcecode_username, self.sourcecode_password) + '\n'
         svn_log_message = svn_log_message + "main updated contents : " + '\n' + self.message
         pywincmds.py_write_svn_message_to_file(svn_log_message, self.py_log_file)
         updated_content = pysvn.commit_all(product_dir, self.product_username, self.product_password, self.py_log_file)
         pyprocessemail.commit_to_product(site_name, self.to_list, updated_content, self.sites[site_name]["product_url"], svn_log_message, self.log_url)
Пример #2
0
 def make_label(self):
     title = self.full_site_name + "标签已打,谢谢!"
     os.chdir(self.product_tag_dir)
     svn_log = pysvn.py_get_log_message(self.online_site_path, self.online_username, self.online_password)
     pywincmds.py_write_svn_message_to_file(svn_log, self.py_log_file)
     commited_content = pysvn.commit_all(self.product_tag_dir, self.product_username, self.product_password, self.py_log_file)
     if commited_content == "":
         print("提交内容为空")
         exit(1)
     pyemail.send(self.to_list, title, commited_content)
     st = pysvn.st(self.product_tag_dir)
     pyemail.send("*****@*****.**", self.full_site_name + "标签内容如下,便于检查", '\n'.join(st).strip())
Пример #3
0
def update_3_resend_email():
    os.chdir(site_path)
    st = pysvn.st("") #更新文件列表
    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, [])
Пример #4
0
    def commit_to_online(site, to_list, updated_content, product_release_revision, product_release_message, log_url, release_notes_path=[]):
        #其中release_notes_path为版本说明路径,必须为列表路径,如[r"c:\版本说明"]
        title = site + "三段测试通过,请更新线上"
        content = '''
提交内容为:
${1}

svn日志信息为:
${3}

详细日志查询:${4}
'''
        content = content.replace('${1}', updated_content).replace('${2}', product_release_revision).replace('${3}', product_release_message).replace('${4}', log_url)
        pyemail.send(to_list, title, content, release_notes_path)
Пример #5
0
    def update_to_three(site, to_list, product_test_url, product_test_revision, updated_content, log_url):
        title = site + "三段更新成功,请测试"
        content = '''
线下产品库地址:${1}

线下产品库版本号为:${2}

三段更新详细内容如下:
${3}

详细日志查询:${4}
'''
        content = content.replace('${1}', product_test_url).replace('${2}', product_test_revision).replace('${3}', updated_content).replace('${4}', log_url)
        pyemail.send(to_list, title, content, [])
Пример #6
0
    def commit_to_product(site, to_list, commited_content, product_test_url, product_test_message, log_url):
        title = site + "已提交产品库成功,请测试线下环境"
        content = '''
提交内容:
${1}

线下产品库地址:${2}

svn日志信息:
${3}

详细日志查询:${4}
'''
        content = content.replace('${1}', commited_content).replace('${2}', product_test_url).replace('${3}', product_test_message).replace('${4}', log_url)
        pyemail.send(to_list, title, content, [])
Пример #7
0
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
Пример #8
0
    def build_success(site, to_list, sourcecode_url, sourcecode_revision, updated_content, log_url):
        '''
       parameters数组,内容是sourcecode_url, sourcecode_revision, updated_content, log_url
        '''
        title = site + "构建通过,请查看详情"
        content = '''
源代码URL:${1}

版本号:${2}
 
与线上版本比较,更新内容如下:
${3}

详细日志查询:${4}
'''
        content = content.replace('${1}', sourcecode_url).replace('${2}', sourcecode_revision).replace('${3}', updated_content).replace('${4}', log_url)
        pyemail.send(to_list, title, content, [])
Пример #9
0
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, [])
Пример #10
0
def commit():
    global release_notes_url
    title = site_name + "三段测试通过,请更新线上服务器,谢谢!"
    if release_notes_url == None:
        f = open(url_file)
        svn_url = f.readlines()[0].strip()
        release_notes_url = os.path.dirname(svn_url)
        try:
            if svn_url.rindex('/') == len(svn_url) - 1 or  svn_url.rindex('\\') == len(svn_url):
                release_notes_url = os.path.dirname(release_notes_url)
        except:
            pass
        f.close()
    pt = pyupdate_three()
    sourcecode = {"username":username, "password":password}
    release_notes_file = pt.get_release_notes_path(release_notes_url, sourcecode, release_notes_local_path)
    commit_content = pysvn.commit_targets(site_path, changelist, username_online, password_online, message, isfile=False)
    content = "各位好:" + "\n" + "三段测试通过,请更新线上服务器,谢谢!" + "\n" + "提交内容为:" + "\n" + commit_content + "\n"
    content = content + "日志信息:\n" + message
    content = content + "\n" + "详情见:" + "\n" + log_url
    if release_notes_file == None:
        pyemail.send(to_list, title, content, [])
    else:
        pyemail.send(to_list, title, content, [release_notes_file])
    st = pysvn.st(site_path)
    pyemail.send(["*****@*****.**"], site_name + "站点目录当前内容如下,便于检查", '\n'.join(st).strip() + " ", [])
Пример #11
0
def update_3():
    #pdb.set_trace()
    #更新样式线下和线上本地拷贝
    for style_offline in style_offline_woringcopy:
        pysvn.up("HEAD", style_offline, style_offline_username, style_offline_password)
    
    for style_online in style_online_woringcopy:
        pysvn.up("HEAD",  style_online, style_online_username , style_online_password)
    #读取文件http列表
    #转换为路径
    url_transfer_path()
    #拷贝文件
    for i in range(0,len(offline_paths)):
        if os.path.isfile(offline_paths[i]):
            pywincmds.makedirs(os.path.dirname(online_paths[i]))
            if os.path.exists(offline_paths[i]):
                pywincmds.py_xcopy_file(offline_paths[i], online_paths[i])
        else:
            pywincmds.py_robocopy(offline_paths[i].rstrip("\\"), online_paths[i].rstrip("\\"), "", "")
    #压缩png文件
    for i in range(0,len(online_paths)):
        if online_paths[i].endswith('.png'):
            try:
                pywincmds.call_cmd(compress_png_path + " \"" + online_paths[i] + "\"")
            except:
                print(online_paths[i] +' error')
            atime = time.mktime(datetime.datetime(2000, 1, 1).utctimetuple())
            mtime = time.mktime(datetime.datetime(2000, 1, 1).utctimetuple())
            os.utime(online_paths[i], (atime, mtime))
            print(online_paths[i])
    #压缩js和css文件
    for compress_js_path in compress_js_paths:
        os.chdir(os.path.dirname(compress_js_path))
        pywincmds.call_cmd(compress_js_path)
        print(compress_js_path)
    #确认已更新,如何确认
    #发送邮件
    pyemail.send(["*****@*****.**"], content.strip() + "样式已更新", " ", [])
Пример #12
0
 def commit(self):
     title = self.full_site_name + "三段测试通过,请更新线上服务器,谢谢!"
     os.chdir(self.online_site_path)
     svn_log = pysvn.py_get_log_message(self.product_trunk_dir, self.product_username, self.product_password)
     pywincmds.py_write_svn_message_to_file(svn_log, self.py_log_file)
     release_notes_file = self.get_release_notes_path(self.release_notes_url, self.sourcecode_username, self.sourcecode_password, self.release_notes_local_path)
     commited_content = pysvn.commit_targets(self.online_site_path, self.temp_changelist, self.online_username, self.online_password, self.py_log_file)
     #如果提交内容为空,则不提交。
     if commited_content == "":
         print("提交内容为空")
         exit(1)
     #pyprocessemail.commit_to_online(site, to_list, commited_content, product_test["url"], svn_log, log_url)
     #print("邮件参数为:",site, to_list, commited_content, product_release_revision, svn_log, log_url, release_notes_path)
     content = "各位好:" + "\n" + "三段测试通过,请更新线上服务器,谢谢!" + "\n" + "提交内容为:" + "\n" + commited_content + "\n"
     content = content + "日志信息:\n" + svn_log
     content = content + "\n" + "详情见:" + "\n" + self.log_url
     if release_notes_file == None:
         pyemail.send(self.to_list, title, content, [])
     else:
         pyemail.send(self.to_list, title, content, [release_notes_file])
     st = pysvn.st(self.online_site_path)
     pyemail.send("*****@*****.**", self.full_site_name + "站点目录当前内容如下,便于检查", '\n'.join(st).strip())
Пример #13
0
 def revert(self):
     pysvn.clear_workingcopy_by_targets(self.online_site_path, self.temp_changelist)
     st = pysvn.st(self.online_site_path)
     title = self.full_site_name + "三段回滚成功,谢谢!"
     content = "三段站点状态:" + '\n' + '\n'.join(st).strip()
     pyemail.send(self.to_list, title, content)
Пример #14
0
def revert():
    pysvn.clear_workingcopy_by_targets(site_path, changelist)
    st = pysvn.st(site_path)
    title = site_name + "三段回滚成功,谢谢!"
    content = "三段站点状态:" + '\n' + '\n'.join(st).strip()
    pyemail.send(to_list, title, content, [])
Пример #15
0
def recycle_apppool():
    pywincmds.restart_app_pool(workspace + os.sep + "sbp", apppool)
    if pywincmds.web_check(sit_url, site_keyword, inteveral_time, web_decode):
        pyemail.send(to_list, site_name + "三段启动成功!", " ", [])
    else:
        exit(1)