Python Forum

Full Version: Cannot extract wranings/errors from ant script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have been learning python for about 4 months now and i'm stuck trying to extract errors/warnings after running an ant script.
I am running python 2.7 on a windows machine.
code snippet:
cmd = (r'{6} -f build.xml "-DthisInput={4}" "-Dargs.filter={2}"'
            ' "-DthisDoc={5}" "-Ddita.temp.dir={0}"'
            ' "-Dout={1}" {3} "-Dgenerate.outer.copy=3"'.format(
                tempDir, outDir, userFilter, ','.join(targets), file, filename, ant))
        pro = subprocess.Popen(
            cmd, shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
        )
    pro.wait()
    o, e = pro.communicate()
    print (e)
    print (o)
An equivalent powershell script displays errors such as:
[gen-list] [DOTX008E][ERROR] File '..\topic\xyz\xyz.dita' does not exist or cannot be loaded.
[move-meta] File C:\Users\xyz\docs\temp\topic\xyz\xyz.xml does not exist

But my python script simply completes running the script without showing any warnings/errors.
First, if you are just learning Python, why are you learning version 2.7 rather than the latest version (currently 3.6.2)?
Second, who cares about PowerShell, we're here to discuss Python
Third, does your Python script provide the output you are expecting? If not, what do you actually get versus what you expect to get?
Lastly, why do you have lines 5 -9 and10 - 13 indented (using different depths of indent at that)?