How can I debug silent failure - print no output

Sayth Renshaw flebber.crue at gmail.com
Fri May 27 22:41:29 EDT 2016


Afternoon

I am looking for help with this excerpt of code. The issue is that it completes with no error and with other code in I can see it connects to postgres however it is not picking up or parsing file, also no error though so I am not sure of the exact problem.

I use prints to try and see what it is picking up from terminal however they also print nothing.

How can i find the error to troubleshoot.

This is my terminal and directory structure.

sayth at localhost pyXML]$ ls -a
.  ..  data  .git  racemeeting.py  README.md


sayth at localhost data]$ ls -a
.  ..  20160528RAND0.xml


I execute the file as such

[sayth at localhost pyXML]$ python3 racemeeting.py data/*.xml
[sayth at localhost pyXML]$ 

As you can see no output or failure.


from pyquery import PyQuery as pq
import psycopg2
import argparse
import os
import glob


def GetArgs():
    '''parse XML from command line'''
    parser = argparse.ArgumentParser()

    parser.add_argument("path", nargs="+")
    parser.add_argument('-e', '--extension', default='',
                        help='File extension to filter by.')
    args = parser.parse_args()

    files = set()
    name_pattern = "*" + args.extension
    for path in args.path:
        files.update(glob.glob(os.path.join(path, name_pattern)))
    return files



    # Now walk the tree and insert data.
    for filename in sorted(GetArgs()):
        for meeting in pq(filename=filename):
            print(filename)
            print(meeting)
            meetdata = [meeting.get(attr) for attr in meetattrs]
            cur.execute("insert into meetings valueme in GetArgs():s (" +
                        ",".join(["%s"]*len(meetattrs)) + ")", meetdata)
            for race in meeting.findall("race"):
                race.set("meeting_id", meeting.get("id"))
                racedata = [race.get(attr) for attr in raceattrs]
                cur.execute("insert into races values (" +
                            ",".join(["%s"]*len(raceattrs)) + ")", racedata)
                for horse in race.findall("nomination"):
                    horse.set("race_id", race.get("id"))
                    horsedata = [horse.get(attr) for attr in horseattrs]
                    cur.execute("insert into horses values (" +
                                ",".join(["%s"]*len(horseattrs)) + ")", horsedata)


Thanks in advance

Sayth



More information about the Python-list mailing list