def main(paramStr): uname, passw = utils.get_username_password() connection = AmazonAIM(uname, passw) if paramStr == "": output = connection.generate_open_listings_lite_report() print "created report, now rerun this command with a 'reports' parameter" else: # check to see if we're still waiting for a report... # (note: this is inefficient for example purposes. WD-rpw 09-13-2009) is_one_running, rid = connection.there_is_a_report_processing() if is_one_running: print "A report is still running, the RID is %s" % rid else: print "all done with the report requested" # now get all the current reports # and sort them so that the oldest report is first reports = Report.get_all_reports(connection) for report in reports: print "%s: started: on %s, ended on %s" % (report.report_id, report.start.ctime(), report.end.ctime()) reports.sort(key=operator.attrgetter("start")) # sort will sort ASCENDING. Which, with dates, means that the oldest is at the top # which is GREAT for our purposes! print "the oldest report was..." report = reports[0] print "%s: started: on %s, ended on %s" % (report.report_id, report.start.ctime(), report.end.ctime())