Created
May 5, 2012 12:32
-
-
Save eikeon/2602028 to your computer and use it in GitHub Desktop.
accept_batches.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cts.inventory import BagList, Bag | |
def accepted_on(bag): | |
accepted_on = None | |
for event in bag.events: | |
if event.type in ("BagAcceptedEvent",): #, "ReconEvent"): | |
accepted_on = event.end | |
if event.type=="BagRejectedEvent" or event.type=="BagCancelledEvent": | |
accepted_on = None # clear accepted_on if it's been later | |
# rejected or cancelled | |
return accepted_on | |
def accepted_bags(): | |
for bag in BagList.find_bags(projectId="ndnp"): | |
try: | |
bag = Bag.find_bag("ndnp", bag.id) # get full form of bag so | |
# that it has field like | |
# currentBagVersion | |
# populated | |
except Exception, e: | |
print e | |
continue | |
timestamp = accepted_on(bag) | |
if timestamp: | |
yield timestamp, bag | |
for date, bag in sorted(accepted_bags()): | |
try: | |
if not bag.isTest: | |
print "%s_ver%.02d" % (bag.id, bag.currentBagVersion) | |
except Exception, e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment