windows скрипт создает отчетный отчет Beyond Compare, но теперь перестал работать - PullRequest
2 голосов
/ 12 февраля 2020

У меня есть скрипт, который сравнивает две папки в Beyond Compare и генерирует отчет html, который можно кликнуть. Этот сценарий вызывает сценарий perl и Beyond Compare для генерации отчета. Теперь, после долгого времени работы, он больше не работает. Выходные данные сценария говорят, что сценарий не может найти файл. Я включил сценарий оболочки Windows, сценарий perl и вывод здесь. Это все работает в IBM Build Forge.

Может кто-нибудь помочь мне выяснить, почему теперь сценарий не может найти файл. html? Кроме того, почему код выхода Beyond Compare "1", если раньше он был "13"?

Сначала вывод с ошибкой:

start [E:\RBF\EPCOH_Maintenance\EPCOH-20.1.3.0@CHHSSVWR2602]
DEBUG fullpath "E:\RBF\EPCOH_Maintenance\EPCOH-20.1.3.0\prodConfig\config\processes.properties"
DEBUG cwd "E:\RBF\EPCOH_Maintenance\EPCOH-20.1.3.0"
DEBUG base1 "prodConfig"
DEBUG base2 "devConfig"
DEBUG Directory_results_dequoted "diff-PROD-DEV-EPCOH-20.1.3.0"
DEBUG file [config\processes.properties]
DEBUG script ["diff-PROD-DEV-EPCOH-20.1.3.0\config\processes.properties.bc_script"]
+ mkdir "diff-PROD-DEV-EPCOH-20.1.3.0\config\processes.properties.bc_script"
script is "diff-PROD-DEV-EPCOH-20.1.3.0\config\processes.properties.bc_script"

load "ACS Folder Compare2"
criteria rules-based
expand all
file-report &
layout:side-by-side &
 options:display-mismatches,line-numbers &
title:"config\processes.properties" &
output-to:"diff-PROD-DEV-EPCOH-20.1.3.0\config\processes.properties.html" &
output-options:html-color,wrap-word &
"prodConfig\config\processes.properties" "devConfig\config\processes.properties"
Beyond Compare exit code was 1
Could Not Find E:\RBF\EPCOH_Maintenance\EPCOH-20.1.3.0\diff-PROD-DEV-EPCOH-20.1.3.0\config\processes.properties.html

Теперь скрипт Windows:

setlocal EnableDelayedExpansion

(set BC_CLICKABLE_SCRIPT="E:\RBF\internal\bin\make_BC_all_clickable.pl")
(set BC_SESSION="ACS Folder Compare2")

(set cwd=%cd%)
(set Directory_1_dequoted=%Directory_1%)
call :DeQuote Directory_1_dequoted
(set Directory_2_dequoted=%Directory_2%)
call :DeQuote Directory_2_dequoted
(set Directory_results_dequoted=%Directory_results%)
call :DeQuote Directory_results_dequoted
if not defined All_html (set All_html=all.html)
(set All_html_dequoted=%All_html%)
call :DeQuote All_html_dequoted
if not defined Summary_html (set Summary_html=summary.html)
(set Summary_html_dequoted=%Summary_html%)
call :DeQuote Summary_html_dequoted

if not defined Directory_1_dequoted (echo ERROR - Directory_1 must be set& exit /b 1)
if not defined Directory_2_dequoted (echo ERROR - Directory_2 must be set& exit /b 1)
if not defined Directory_results_dequoted (echo ERROR - Directory_results must be set& exit /b 1)

mkdir "%Directory_results_dequoted%"

(set cwd=%cd%)
(set display_option=display-mismatches)
(set del_if_equal=1)
(set base1=%Directory_1_dequoted%)
(set base2=%Directory_2_dequoted%)
for /r %Directory_1% %%g in (*) do set fullpath=%%g&call :compare_a_file
(set base1=%Directory_2_dequoted%)
(set base2=%Directory_1_dequoted%)
for /r %Directory_2% %%g in (*) do set fullpath=%%g&call :compare_a_file
(set del_if_equal=)

(set Summary_temp="summary.tmp")
for /r "%Directory_results_dequoted%" %%g in (*.html) do set fullpath=%%g& call :concat_a_file & del %%g

move %Summary_temp% "%Directory_results_dequoted%\%Summary_html_dequoted%"
if %ERRORLEVEL% neq 0 (echo ERROR - move failed& exit /b 1)

dir /b/s "%Directory_results_dequoted%"

(set folder_report_script="%Directory_results_dequoted%\all.bc_script")
(set folder_report_html="%Directory_results_dequoted%\%All_html_dequoted%")
(set folder_report_html_tmp="%Directory_results_dequoted%\%All_html_dequoted%.tmp")

verify >nul:
if %ERRORLEVEL% neq 0 (echo ERROR - cannot create %folder_report_script%& exit /b 1)

"%BEYOND_COMPARE%" /silent @%folder_report_script%
if %ERRORLEVEL% geq 100 (echo ERROR - Beyond Compare "%BEYOND_COMPARE%" exited with exit code %ERRORLEVEL%& exit /b 1)

type %folder_report_script%
del %folder_report_script%
%CYGWIN_HOME%\bin\perl.exe %BC_CLICKABLE_SCRIPT% %folder_report_html% > %folder_report_html_tmp%
if %ERRORLEVEL% neq 0 (echo ERROR - cannot execute %BC_CLICKABLE_SCRIPT%& exit /b 1)
move /Y %folder_report_html_tmp% %folder_report_html%
if %ERRORLEVEL% neq 0 (echo ERROR - cannot move %folder_report_html_tmp% to %folder_report_html%& exit /b 1)

(set cwd=%cd%)
(set display_option=display-all)
(set base1=%Directory_1_dequoted%)
(set base2=%Directory_2_dequoted%)
for /r %Directory_1% %%g in (*) do set fullpath=%%g&call :compare_a_file
(set base1=%Directory_2_dequoted%)
(set base2=%Directory_1_dequoted%)
for /r %Directory_2% %%g in (*) do set fullpath=%%g&call :compare_a_file

exit /b 0

:compare_a_file
    setlocal EnableDelayedExpansion

    (call set file=%%fullpath:%cwd%\%base1%\=%%)

    (set script="%Directory_results_dequoted%\%file%.bc_script")

    mkdir %script%
    if %ERRORLEVEL% neq 0 (echo ERROR - cannot mkdir %script%& exit /b 1)
    rmdir %script%
    if %ERRORLEVEL% neq 0 (echo ERROR - cannot rmdir %script%& exit /b 1)
    (set html="%Directory_results_dequoted%\%file%.html")
    if exist %html% goto :end_of_compare_a_file

    (set lhs="%base1%\%file%")
    (set rhs="%base2%\%file%")

    (set nuke_rhs=)
    if exist %rhs% goto :do_not_make_nulled_rhs
        (set nuke_rhs=1)
        (set rhs="%Directory_results_dequoted%\%file%.nulled")
        copy nul: %rhs%
    :do_not_make_nulled_rhs

    verify >nul:

    if %ERRORLEVEL% neq 0 (echo ERROR - cannot write to %script%& exit /b 1)

    type %script%
    "%BEYOND_COMPARE%" /silent @%script%
    (set rc=%ERRORLEVEL%)
    if %rc% geq 100 (echo ERROR - Beyond Compare "%BEYOND_COMPARE%" exited with error exit code %rc%& exit /b 1)

    if not defined del_if_equal goto :skip_del_checks

        "%BEYOND_COMPARE%" /silent /quickcompare /ignoreunimportant %lhs% %rhs%
        (set rc=%ERRORLEVEL%)

        if %rc% geq 100 (echo ERROR - Beyond Compare "%BEYOND_COMPARE%" exited with error exit code %rc%& exit /b 1)
        if %rc% equ  1 del %html%
        if %rc% equ  2 del %html%
        if %rc% equ 12 del %html%
    :skip_del_checks
    del %script%
    if defined nuke_rhs (set nuke_rhs=&del %rhs%)

    goto :end_of_compare_a_file

    :nothing_to_compare
    verify >nul:
    echo ^<^!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"^>>%html%
    if %ERRORLEVEL% neq 0 (echo ERROR - cannot write to %html%& exit /b 1)
    goto :end_of_compare_a_file

    :end_of_compare_a_file
    endlocal
goto :end_of_script

:concat_a_file
    setlocal

    (set concat_file="%fullpath%")

    if exist %Summary_temp% goto not_first_time

        %CYGWIN_HOME%\bin\sed.exe "/<\/body>/d; /<\/html>/d" %concat_file% >%Summary_temp%
        goto :end_of_concat_a_file

    :not_first_time


        %CYGWIN_HOME%\bin\sed.exe "1,/<body>/d; /<\/body>/,$d" %concat_file% >>%Summary_temp%

    :end_of_concat_a_file
    endlocal
goto :end_of_script

:DeQuote
SET _DeQuoteVar=%1
CALL SET _DeQuoteString=%%!_DeQuoteVar!%%
IF [!_DeQuoteString:~0^,1!]==[^"] (
IF [!_DeQuoteString:~-1!]==[^"] (
SET _DeQuoteString=!_DeQuoteString:~1,-1!
) ELSE (GOTO :END_OF_SCRIPT)
) ELSE (GOTO :END_OF_SCRIPT)
SET !_DeQuoteVar!=!_DeQuoteString!
SET _DeQuoteVar=
SET _DeQuoteString=
GOTO :END_OF_SCRIPT

:end_of_script

А теперь скрипт perl:

#! /usr/bin/perl -w

my @dir_stack = ();
while (<>) {
    chomp;
    s/\r+$//;
    next unless m!src="BcImages!; # "!;
    next if /<td class="AlignLeft">/;
    my @name = m!align="middle"> ?([^>]+)</td>$!;
    my $name = $name[0];
    # depth: top level is 0.
    my @depth = m!alt="[ \\+|]"!g;
    my $depth = scalar @depth;
    if (0) {
        # Debug.
        print(('____' x $depth), $name, "\n");
        next;
    }
    my $is_dir = 0;
        splice (@dir_stack, $depth);
    if (/alt="<DIR>"/) {

        splice (@dir_stack, $depth, 1, $name);
        $name = '';
        $is_dir = 1;
    }
    my $fullpath = join('/', @dir_stack, $name);
    if (0) {

        print($fullpath, "\n");
    }
    if (! $is_dir) {
        s!align="middle"> ?([^>]+)</td>$!align="middle"><a href="$fullpath.html">$name</a></td>!;
    }
} continue {
    print $_, "\n";
}
exit 0;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...