简体   繁体   中英

How To Run Pylint From Ant

I need to run this command from ant:

pylint -f parseable src/apps/api | tee pylint.out

It outputs a pylint.out file.

I tried this:

<target name="pylint" description="Pylint">
    <exec executable="pylint">
        <arg line="-f parseable src/apps/api | tee ${basedir}/pylint.out"/>
    </exec>
</target>

But that doesn't produce the pylint.out file. Any ideas?

It seems that ant will treat your pipe ( | ) as an argument rather than a command to the shell.

One solution would be to extract your command to a script:

pylint.sh:

#!/bin/bash
pylint -f parseable src/apps/api | tee $1/pylint.out

and then run that script from the <exec> task:

build.xml:

<target name="pylint" description="Pylint">
    <exec executable="pylint.sh">
        <arg line="${basedir}"/>
    </exec>
</target>

That's obviously not cross-platform and there may be a better way that I haven't thought of, but you could have an equivalent .bat file and do OS-detection in ANT to make it work on Windows if needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM