Richard Knop
Richard Knop

Reputation: 83697

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?

Upvotes: 1

Views: 460

Answers (1)

bcoughlan
bcoughlan

Reputation: 26627

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.

Upvotes: 2

Related Questions