|
上周运行脚本还是碰到了不少问题,突然发现美国那边竟然也在同时调试上传build的脚本,生成了几个类似build_999_ent这样的测试build号码。于是从CuteFTP中下载最末尾build的方法失效了,只能另想出路。
一个办法是在脚本的开头设定下载范围,使用脚本循环读取判断FTP上处于下载范围内最大的build号,并下载。但这个方法有很多弊端,如下载范围需定时更新;build的循环判断较复杂等。尝试了一下发现可行性不高
另一个办法是循环点击当前FTP SRV上列出的所有build文件夹,判断里面是否有安装的文件,如果有则记录下这个build号,最后下载build号最大的文件夹。这个方法也同样存在问题,比如点击文件夹读取子文件列表时速度过慢,可能会出问题;build文件夹下文件上传尚不完全,但脚本判断后却认为是正确build...
最后还是采用了第二种办法。在脚本操作间加大了wait时间,并将循环点击build的操作提为一个函数。脚本如下:
#==========================================================================================================
#创建人:杨明华
#创建时间:2007.8
#内容描述:自动下载connect enterprise 6.0 build
#修改人:杨明华
#最后修改时间:2007.11.28
#修改内容:修改为适合Connect Enterprise 7.0 Build的自动下载脚本
#===========================================================================================================
#======变量设置=============================================================================================
#wait(25200);
Project_label = "General FTP Sites;Connect Enterprise 7.0 sap"; # The Connect Enterprise project label in list is "General FTP Sites;Connect Enterprise 6 build"
Current_Build = "connect_700_r531_ent";
public function getbuild()
{
static count, i, arr_num, builds[], div[], builds_label, current_build, subcount, lastest_build;
list_get_items_count("{class: list, MSW_id: 59648}", count);
if (count==0)
{
report_msg("There is no build on SRV.");
texit;
}
for (i=0; i<count;i++)
{
list_get_item("{class: list, MSW_id: 59648}",i,builds_label);
builds=builds_label;
report_msg("all builds on SRV are listed here: Num "&i&" = "&builds);
arr_num=split(builds, div, "_");
if (div[arr_num]=="ent")
{
current_build=builds;
set_window ("{ class: window, label: \"!Connect Enterprise 7.*\"}", 2);
list_activate_item ("{class: list, MSW_id: 59648}", current_build);
wait(30);
while(win_exists("{class: window, label: \"!File.*\"}",3)==E_OK)
{
win_close("{class: window, label: \"!File.*\"}",3);
report_msg("Close the message windows");
set_window ("{ class: window, label: \"!Connect Enterprise 7.*\"}", 2);
list_activate_item ("{class: list, MSW_id: 59648}", current_build);
wait(30);
}
report_msg("Into the sub folder");
list_get_items_count("{class: list, MSW_id: 59648}", subcount);
if (subcount!=0)
{
lastest_build=current_build;
}
obj_type("{class: list, MSW_id: 59648}", "<kBackSpace>");
wait(30);
}
}
report_msg("The lastest build is "&i&"="&lastest_build);
return lastest_build;
}
#============================================================================================================
#======监测FTP程序是否存在,如果存在则关闭程序,重新启动======================================================
if(win_exists("{class: window, label: \"!GlobalSCAPE - CuteFTP.*\"}",0)==E_OK)
{
report_msg("GlobalSEAPE is existing, it will be closed");
win_close("{class: window, label: \"!GlobalSCAPE - CuteFTP.*\"}");
}
wait(5);
if(invoke_application("C:\\Program Files\\GlobalSCAPE\\CuteFTP 7 Professional\\cuteftppro.exe","","",SW_SHOW)!=0)
{
report_msg("Start CUTEFTP error");
texit;
}
else
{
report_msg("Start CUTEFTP ok");
}
#============================================================================================================
#wait(3600);
#============================================================================================================
#======定位CuteFTP,点击build下载的FTP site==================================================================
# GlobalSCAPE - CuteFTP 7.2 Professional
set_window ("{class: window, label: \"!GlobalSCAPE - CuteFTP.*\"}", 2);
list_activate_item ("{class: list, MSW_id: 1079}", Project_label); # Notice! Replace the parameter "Project_label"
#============================================================================================================
wait(60);
#======刷新界面,选择下载====================================================================================
# wait(1800);
report_msg("waiting for build downloading, loop every 30 mins");
#======定位窗体,刷新界面====================================================================================
win_activate ("{ class: window, label: \"!Connect Enterprise 7.*\"}");
set_window ("{ class: window, label: \"!Connect Enterprise 7.*\"}", 2);
obj_type ("{class: list, MSW_id: 59648}","<kF5>");
wait(10);
##======循环选择当前所有的build,找到最近的一个和当前的build进行比较,如果与当前的build不一致则下载=============
download_build = getbuild();
#============================================================================================================
report_msg("The lastest build is "&i&"="&lastest_build);
# pause("stop");
#======下载最近的build=======================================================================================
list_select_item ("{class: list, MSW_id: 59648}",download_build, RIGHT);
menu_select_item ("{class: menu_item, parent: none, position: 0}");
#============================================================================================================
report_msg("The lastest build is "&download_build&", Copying");
#============================================================================================================
#======如果有重复的提示则选择替换所有========================================================================
if(win_exists("{class: window, label: \"Confirm Folder Replace\"}",5)==E_OK)
{
win_activate ("{class: window, label: \"Confirm Folder Replace\"}");
set_window ("{class: window, label: \"Confirm Folder Replace\"}", 2);
button_press ("{class: push_button, label: \"Yes to All\"}");
report_msg("Replace the build");
}
脚本还需经过一段时间的考验和调试,这里列出的方法希望能给大家一个参考 ^_^ |
|