2009/12/28 Nicolas Chauvat <nicolas.chau...@logilab.fr> > On Thu, Dec 24, 2009 at 08:12:42PM +0000, Daniel Harding wrote: > >> Could pylint.bat look for a command line parameter to determine which > >> behaviour is wanted? > > > > [...] > > > > I have attached an implementation of pylint.bat which calls exit only if > > Thank you Daniel, Pierre and Jonathan, > > This is tracked at http://www.logilab.org/ticket/19498 and will soon be > merged in the main tree. >
Unfortunately, the pylint.bat file as submitted by Daniel does not completely work (at least on XP SP3, and probably other versions as well). The problem lies in the fact that SHIFT does not remove the --exitcode from %* expansion but removes it from "%~f0", the reverse from what is wanted in the original intent of the code. Another problem with the submitted batch is the fact that endlocal is never called (but selocal is called twice). I created a new version of pylint.bat that solves the mentioned problems. It has a limitation of being able to support only 8 parameters when the --exitcode parameter is specified. I wish Ièd found a better way to handle the arguments but, as I said, SHIFT does not impact %* expansion. If anyone has a better idea, let me know. I inserted the text of the revised version of pylint.bat. I tested it under Windows XP/SP3: the pylint exitcode is returned when --exitcode is specified (but it also causes termination of the CMD shell). If --exitcode is not specified, the pylint.cmd exitcode is always 0 but the CMD shell is not terminated. BTW, aside from MSDN, http://ss64.com/nt/ contains a nice collection of information related to Microsoft CMD shell. Here's the file: @echo off rem = """-*-Python-*- script rem -------------------- DOS section -------------------- rem You could set PYTHONPATH or TK environment variables here setlocal set PYLINT_EXITCODE=FALSE set PYLINT_BATCH="%~f0" if not "%1" == "--exitcode" goto noexitcode REM exit code is required here. The SHIFT command does not impact %* REM So do it the long way. Unfortunately only 8 parameters are supported. python -x %PYLINT_BATCH% %2 %3 %4 %5 %6 %7 %8 %9 goto exit1 :noexitcode python -x %PYLINT_BATCH% %* goto exit """ # -------------------- Python section -------------------- import sys from pylint import lint lint.Run(sys.argv[1:]) DosExitLabel = """ :exit1 endlocal exit(ERRORLEVEL) :exit endlocal rem """
_______________________________________________ Python-Projects mailing list Python-Projects@lists.logilab.org http://lists.logilab.org/mailman/listinfo/python-projects