#!/opt/python-2.7/bin/python # # A script to process the UPS electronic bill - it will extract the trackingnumber and invoice number from the csv # import logging import optparse import suds # Filename, Tracking Number Field, Invoice Field def readRecord(client): por = client.factory.create('{http://mionegroup.com/services}ProcessOrdersRequest') print por por.profileNote0.note = 'Nevada Ship Verification process' por.profileNote0.noteType = 'Internal' print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' print por print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' mop = client.factory.create('{http://mionegroup.com/services}ProcessOrdersRequest.MarkOrdersPacked') print mop cDSeq = [] cDSeq.append(createCarrierDetails(client, '100', '123456', '2010-10-22', 'Carrier1', 'N')) mop.carrierDetails = cDSeq #por.profileNote0 = prof por.MarkOrdersPacked = mop print 'POR:', por try: result = client.service.ProcessOrders(por) except suds.WebFault, e: print 'Error:', e else: print 'Result:', result def setupCSI(): logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.DEBUG) logging.getLogger('suds.transport').setLevel(logging.DEBUG) #logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) url = 'http://10.10.0.150:8080/OneSite/services/DespatchService.wsdl' client = suds.client.Client(url) cache = client.options.cache cache.setduration(seconds=60) client.set_options(cache=None) security = suds.wsse.Security() token = suds.wsse.UsernameToken('anonymous', 'anonymous') security.tokens.append(token) client.set_options(wsse=security) return client def createCarrierDetails(client, invoice, tracking, date, courier, residentialflag): cD = client.factory.create('{http://mionegroup.com/services}ProcessOrdersRequest.MarkOrdersPacked.carrierDetails') cD.orderId = invoice cD.carrier = courier cD.conNote = tracking return cD def main(): opts = optparse.OptionParser() opts.add_option("--file", "-f", type="string", help="a csv containing the shipping information from NDS.") file = '' options, arguments = opts.parse_args() if options.file: file = options.file wsClient = setupCSI() readRecord(wsClient) main()