def __init__(self, db): self.db = db # prepare a cursor object using cursor() method self.dbc = self.db.cursor() checkmateconfig = CheckMateConfig() # direct output to logfile day_of_week = datetime.datetime.today().strftime('%A') DAILY_BATCH = 'daily' WEEKLY_BATCH = 'weekly' MONTHLY_BATCH = 'monthly' YEARLY_BATCH = 'yearly' EVERY_EVENT_BATCH = 'every_event' ONCE_BATCH = 'once' self.GET_EVENTS_BY_DATE_RANGE = 'setup.get_events_by_date_range' self.batch_range_options = { DAILY_BATCH: 'dailyRange', WEEKLY_BATCH: 'weeklyRange', MONTHLY_BATCH: 'monthlyRange', YEARLY_BATCH: 'yearlyRange', EVERY_EVENT_BATCH: 'eventLockRange', ONCE_BATCH: 'onceRange' }
def __init__(self, db): """Initializes a new instance of a Levy_Db object params: db -- a mysqldb database connection object """ self.db = db self.checkmateconfig = CheckMateConfig()
def __init__(self, env=None): env_var = os.getenv('Chkm8WorkerServerType') checkmateconfig = CheckMateConfig() self.fort_knox_url = checkmateconfig.FORT_KNOX_URL if env == None: if env_var == "PROD": self.source = 'production' else: self.source = 'development' else: if env == "production" or env == "development": self.source = env else: self.source = 'development'
def sendEmail(sender, recipient, subject, html, userVars=None, files=None): checkmateConfig = CheckMateConfig() mailgunApiKey = checkmateConfig.MAILGUN_API_KEY mailgunHost = "https://api.mailgun.net/v3/{0}/messages".format( checkmateConfig.MAILGUN_PROD_RECEIPT_DOMAIN) data = {"from": sender, "to": recipient, "subject": subject, "html": html} if userVars is not None: for key, value in userVars.iteritems(): data['key'] = 'v:' + str(value) requests.post(mailgunHost, auth=("api", mailgunApiKey), files=files, data=data)
def __init__(self): checkmateconfig = CheckMateConfig() self.HOST = checkmateconfig.DB_HOST self.USER = checkmateconfig.DB_USER self.PASS = checkmateconfig.DB_PASS ''' env_var = os.getenv('Chkm8WorkerServerType') if env_var=='PROD': self.HOST = 'production.cgfo05y38ueo.us-east-1.rds.amazonaws.com' self.USER = '******' self.PASS = '******' else: self.HOST = 'development.cgfo05y38ueo.us-east-1.rds.amazonaws.com' self.USER = '******' self.PASS = '******' ''' # add singleton variables here #self.connection = MySQLdb.Connection(self.HOST, self.USER, self.PASS) self.connection = MySQLdb.connect(self.HOST, self.USER, self.PASS)
#Training Event Cron from db_connection import DbConnection from TrainingEventDB import TrainingEventDB import HipChat from config import CheckMateConfig import redis checkmateconfig = CheckMateConfig() host = checkmateconfig.REDIS_ORDERS_HOST port = checkmateconfig.REDIS_ORDERS_PORT db = checkmateconfig.REDIS_ORDERS_DB password = checkmateconfig.REDIS_ORDERS_PASSWORD redisInstance = redis.Redis(host, port, db, password) for key in redisInstance.keys('*:orders_by*'): redisInstance.delete(key) conn = DbConnection().connection dbCore = TrainingEventDB(conn) trainingEvents = dbCore.getTrainingEvents() HipChat.sendMessage("Moving " + str(len(trainingEvents)) + " training events", "Training", 447878, "purple") for eventUid, venueUid in trainingEvents: print "Event UID: " + str(eventUid) + " Venue UID: " + str(venueUid) #move the event to today dbCore.moveEventToToday(eventUid)
def hashString(string): checkmateconfig = CheckMateConfig() string = "{0}{1}".format(string, checkmateconfig.SALT_PATRONS) return hashlib.sha256(string).hexdigest()
def __init__(self, db): self.db = db self.dbc = self.db.cursor() self.checkmateconfig = CheckMateConfig()
def __init__(self, db): self.db = db # prepare a cursor object using cursor() method self.dbc = self.db.cursor() self.checkmateconfig = CheckMateConfig()
def __init__(self, db): self.db = db self.checkmateconfig = CheckMateConfig()