Python Forum
Cannot extract wranings/errors from ant script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot extract wranings/errors from ant script
#1
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.
Reply
#2
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)?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Need help for a python script to extract information from a list of files lephunghien 6 1,032 Jun-12-2023, 05:40 PM
Last Post: snippsat
  Need help with 3 errors when running script pythoncoder999 3 2,341 Dec-19-2020, 04:04 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020