示例#1
0
class FillTempTable(threading.Thread):


    

    def __init__(self, csvFilePath, clearTableFunction, insertRowFunction):
        super(FillTempTable, self).__init__()
        self.csvFilePath = csvFilePath
        self.clearTableFunction = clearTableFunction
        self.insertRowFunction = insertRowFunction
        conn = DbConnection().connection
        self.dbCore = Levy_Db(conn, None)
        self.lock = threading.Lock()

    def run(self):
        print "processing temp file: " + str(self.csvFilePath)
        if os.path.isfile(self.csvFilePath):
            self.dbCore.addLogRow("processing integration file: " + str(self.csvFilePath))
            self.clearTableFunction()

            with open(self.csvFilePath) as csvFile:
                reader = CSVUtils.parseCSVFile(csvFile)

                for row in reader:
                    try:
                        with self.lock:
                            print "Inserting Row"
                            self.insertRowFunction(row)
                    except:
                        tb = traceback.format_exc()
                        errorRow = self.dbCore.addLogRow(tb)
                 
        else:
            print "I can't find that file"            
示例#2
0
 def __init__(self, csvFilePath, clearTableFunction, insertRowFunction):
     super(FillTempTable, self).__init__()
     self.csvFilePath = csvFilePath
     self.clearTableFunction = clearTableFunction
     self.insertRowFunction = insertRowFunction
     conn = DbConnection().connection
     self.dbCore = Levy_Db(conn, None)
     self.lock = threading.Lock()
示例#3
0
import traceback
import gmail
import MailGun

from UCRSSDB import UCRSSDB
from Levy_DB import Levy_Db

from db_connection import DbConnection
import datetime
import pytz
import IntegrationTools

#create ourselves a nice little database connection
conn = DbConnection().connection
UCRSSDB = UCRSSDB(conn)
levy_db = Levy_Db(conn, None)

VENUE_UID = 201


def updateEvent(eventUid, newName, newSubtitle, newDescription, eventImageUrl):
    oldName, oldSubtitle, oldDescription = UCRSSDB.findEventsXVenue(
        eventUid)[0]

    eventXVenueUid = UCRSSDB.findEventXVenueUid(eventUid)

    print "Updating: " + str(eventUid)

    if oldName != newName:
        IntegrationTools.confirmUpdate(levy_db,
                                       VENUE_UID,
示例#4
0
import CSVUtils
import IntegrationTools
from db_connection import DbConnection
from Levy_DB import Levy_Db
import uuid

with open('dump/DATA_ITEM_MASTER.TXT', 'rb') as csvFile:

    #Menu Item Row:
    #0:item number, 1:package flag  2:item name  3:pos button 1 4:pos button 2 5:pos printer label  6:pos prod class id  7:pos product class  8:rev id  9:tax id
    reader = CSVUtils.parseCSVFile(csvFile)
    conn = DbConnection().connection
    levyDB = Levy_Db(conn)

    rowNumber = 0

    for row in reader:
        print row

        venues = levyDB.getAllLevyVenues()

        for venue in venues:
            venue_uid = venue[0]
            productClassId = row[6]

            matchingParametricCategoryUid = levyDB.getParametricCategory(
                row[2], venue_uid)

            if matchingParametricCategoryUid is None:
                print ""
            else:
from Levy_DB import Levy_Db
from db_connection import DbConnection
from Levy_ProcessPurgatory import LevyIntegrationWorker

from config import CheckMateConfig

import redis
import HipChat

checkmateconfig = CheckMateConfig()
host = checkmateconfig.REDIS_CACHE_HOST
port = checkmateconfig.REDIS_CACHE_PORT
db = checkmateconfig.REDIS_CACHE_DB
password = checkmateconfig.REDIS_CACHE_PASSWORD
redisInstance = redis.Redis(host, port, db, password)

conn = DbConnection().connection

levyDB = Levy_Db(conn, redisInstance)

rowsToApply = levyDB.countRowsToApply()

if rowsToApply != 0:

    HipChat.sendMessage(
        "Attempting to apply: " + str(rowsToApply) + " purgatory rows",
        "IntCron", 1066556, "green")
    liw = LevyIntegrationWorker(levyDB)
    liw.main()
import uuid
import sys
import traceback
import os
import gmail
import MailGun
from IntegrationEmailerDb import EmailerDb

try:

    DAILY_CUSTOMER_FILE_LOCATION = "/data/integration_files/daily_customer"

    print str(os.listdir(DAILY_CUSTOMER_FILE_LOCATION))

    conn = DbConnection().connection
    dbCore = Levy_Db(conn, None)

    successBody = ""

    for dailyCustomerFileName in os.listdir(DAILY_CUSTOMER_FILE_LOCATION):
        if os.path.isfile(DAILY_CUSTOMER_FILE_LOCATION + "/" + dailyCustomerFileName):
            
            if len( open( DAILY_CUSTOMER_FILE_LOCATION + "/" + dailyCustomerFileName ).readlines()) == 0: #read line should be ok here because the file is small
                os.remove(DAILY_CUSTOMER_FILE_LOCATION + "/" + dailyCustomerFileName) # the file is empty, just delete it and move on
                continue

            with open(DAILY_CUSTOMER_FILE_LOCATION + "/" + dailyCustomerFileName, "rb") as dailyCustomerFile:
                
                reader = CSVUtils.parseCSVFile(dailyCustomerFile)
            
                for row in reader:
from config import CheckMateConfig
import redis

import HipChat

INTEGRATION_HIPCHAT_ROOM = 1066556

checkmateconfig = CheckMateConfig()
host = checkmateconfig.REDIS_CACHE_HOST
port = checkmateconfig.REDIS_CACHE_PORT
db = checkmateconfig.REDIS_CACHE_DB
password = checkmateconfig.REDIS_CACHE_PASSWORD
redisInstance = redis.Redis(host, port, db, password)

conn = DbConnection().connection
dbCore = Levy_Db(conn, redisInstance)


def sendErrorEmail(body):
    recipients = ['*****@*****.**', '*****@*****.**']
    for to in recipients:
        #gmail.sendGmail('*****@*****.**', 'fkTUfbmv2YVy', '*****@*****.**', to, 'Daily Integration Crashed', 'Daily Integration Crashed: ' + body, 'enable html to read this')
        MailGun.sendEmail('*****@*****.**', to,
                          'Daily Integration Crashed',
                          'Daily Integration Crashed: ' + body)


def findIntegrationFile(dumpDir, fileNameRoot):
    for f in os.listdir(dumpDir):
        if f.startswith(fileNameRoot):
            return f