def write(amazonProvider, strCSVFileName): if amazonProvider.getPaymentResults() == None: log.writeInfo('[AMAZON] There are no payments.') return False try: writer = csv.writer(open(strCSVFileName, 'w'), quoting=csv.QUOTE_ALL) writer.writerow(["key","datetime","fps_operation", "sender_key", "sender_name", "description", "fees", "status", "amount"]) for transaction in amazonProvider.getPaymentResults(): row = list() row.append(str(transaction.TransactionId)) try: row.append(str(transaction.DateCompleted)) except: row.append("") try: row.append(str(transaction.FPSOperation)) except: row.append("") try: row.append(str(transaction.SenderTokenId)) except: row.append("") try: row.append(transaction.SenderName.encode("ascii", "ignore")) except: row.append("") if "Description:" in str(transaction.TransactionPart[0]).split('(')[1].split(',')[0]: row.append(str(transaction.TransactionPart[0]).split('(')[1].split(',')[0].split("'")[1]) else: row.append("") try: row.append(str(transaction.FPSFees)) except: row.append("") try: row.append(str(transaction.TransactionStatus)) except: row.append("") try: row.append(str(transaction.TransactionAmount)) except: row.append("") writer.writerow(row) return True except Exception, e: log.writeError(e) return False
def main(): logging.basicConfig(filename='/home/jleto/AmazonMeetupConnector/log/novalabs-data-import.log', level=logging.INFO) projectProperties = properties.get('data-import.properties') meetupProperties = properties.get('meetup.properties') amazonProperties = properties.get('amazon.properties') squareupProperties = properties.get('squareup.properties') try: log.writeInfo(' [GENERAL] Generating batches.') result = jobProcessor.generate() except Exception, e: log.writeError(e)
def process(job, amazonProperties): amazonProvider = amazon.amazon(amazonProperties['AWS_ACCESS_KEY'], amazonProperties['AWS_SECRET_KEY']) amazonProvider.getPayments(dtDate(job['batch_key'])-timedelta(days=1), dtDate(job['batch_key'])) if amazonProvider.getTransactionCount() > 0: try: path = amazonProperties['datafile_path'] strCSVFilePath = path + "/amazon-payment-" + strDate(job['batch_key']) + ".csv" log.writeInfo(' [AMAZON] Writing '+strCSVFilePath+' to disk.') payment.write(amazonProvider, strCSVFilePath) payment.load(str(job['job_id']), strCSVFilePath) #logging.info('['+getTimeStamp()+'] [AMAZON] Transactions processed: ('+str(amazonProvider.getTransactionCount())+') | JobId: ('+job['job_id']+') | BatchId: ('+job['batch_id']+') | Date: ('+strDate+').') except Exception, e: log.writeError(e)
def process(job, squareupProperties): squareupProvider = squareup.squareup(squareupProperties['PERSONAL_ACCESS_TOKEN']) squareupProvider.getPaymentData(strDate(job['batch_key'])) if squareupProvider.getPaymentCount() > 0: try: path = squareupProperties['datafile_path'] strCSVFilePath = path + "/squareup-payment-" + strDate(job['batch_key']) + ".csv" log.writeInfo('[SQUARE UP] Writing '+strCSVFilePath+' to disk.') squareupProvider.writePayments(strCSVFilePath) squareupProvider.loadPayments(str(job['job_id']), strCSVFilePath) log.writeInfo('[SQUARE UP] Transactions processed: ('+str(squareupProvider.getPaymentCount())+') | JobId: ('+str(job['job_id'])+') | BatchId: ('+str(job['batch_id'])+') | Date: ('+strDate(job['batch_key'])+').') except Exception, e: log.writeError(e)
def process(job, meetupProperties): try: meetupProvider = meetup.meetup(meetupProperties['apiKey'], meetupProperties['groupName']) meetupProvider.getPaymentData(dtDate(job['batch_key']), dtDate(job['batch_key'])) if meetupProvider.getPaymentCount() > 0: strCSVFilePath = meetupProperties['datafile_path'] + '/meetup-payment-' + strDate(job['batch_key']) + '.csv' log.writeInfo(' [MEETUP] Writing '+strCSVFilePath+' to disk.') meetupProvider.writePayments(strCSVFilePath) meetupProvider.loadPayments(job['job_id'], strCSVFilePath) log.writeInfo(' [MEETUP] Transactions processed: ('+str(meetupProvider.getPaymentCount())+') | JobId: ('+job['job_id']+') | BatchId: ('+job['batch_id']+') | Date: ('+strDate(job['batch_key'])+').') else: skip(job) except Exception, e: log.writeError(e)
def main(): logging.basicConfig(filename='/home/jleto/AmazonMeetupConnector/log/novalabs-data-import.log', level=logging.INFO) projectProperties = properties.get('data-import.properties') meetupProperties = properties.get('meetup.properties') amazonProperties = properties.get('amazon.properties') squareupProperties = properties.get('squareup.properties') try: log.writeInfo(' [GENERAL] Generating batches.') result = jobProcessor.generate() except Exception, e: log.writeError(e) job_cursor = jobProcessor.getReadyJobs() log.writeInfo(' [GENERAL] Jobs to process: ('+str(job_cursor.rowcount)+').') for job in job_cursor: time.sleep(1) jobDict = {} jobDict['job_id'] = str(job[0]) jobDict['batch_id'] = str(job[1]) jobDict['batch_key'] = str(job[2]) jobDict['product_key'] = str(job[3]) if jobDict['product_key'] == 'meetup_payments': MeetupHandler.process(jobDict, meetupProperties) elif jobDict['product_key'] == 'amazon_payments': AmazonHandler.process(jobDict, amazonProperties) elif jobDict['product_key'] == 'squareup_payments': SquareupHandler.process(jobDict, squareupProperties)
def skip(job): jobProcessor.complete(job['job_id']); log.writeInfo('[MEETUP] No transactions for JobId: ('+str(job['job_id'])+') | BatchId: ('+str(job['batch_id'])+') | Date: ('+strDate(job['batch_key'])+'). Skipping.')
def skip(job): jobProcessor.complete(job['job_id']); log.writeInfo('[AMAZON] No transactions for JobId: ('+str(job['job_id'])+') | BatchId: ('+str(job['batch_id'])+') | Date: ('+strDate(job['batch_key'])+'). Skipping and marking job complete.')