from db_connection import DbConnection import TabletStatusMailer import requests import traceback from config import CheckMateConfig try: conn = DbConnection().connection cursor = conn.cursor() # get all of the venues that have tablets cursor.execute("SELECT DISTINCT venue_uid FROM tablets.venues_x_tablet") for venueRow in cursor.fetchall(): venueUid = venueRow[0] #for each venue find the events between where the current time is within the 'seconds_before_event' interval. #I.E. are we within 12 hours of the event cursor.execute( "SELECT events.id AS event_id FROM setup.events \ JOIN setup.tablet_report_controls ON events.venue_uid = tablet_report_controls.venue_uid \ WHERE events.venue_uid = %s \ AND event_date BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL seconds_before_event SECOND) \ AND tablet_alert_sent = 0 \ ORDER BY event_date ASC", (str(venueUid))) #for each of these events send a tablet status alert email for eventRow in cursor.fetchall(): eventUid = eventRow[0] if TabletStatusMailer.sendStatusEmail(venueUid, eventUid) == True:
from db_connection import DbConnection import os.path import hashlib MENU_ITEM_IMAGE_PATH = "/data/media/202/images/menu_items/" db = DbConnection().connection menuItemCursor = db.cursor() menuItemCursor.execute("SELECT * FROM menus.menu_items WHERE show_image =1"); menuItems = menuItemCursor.fetchall() for menuItem in menuItems: image = MENU_ITEM_IMAGE_PATH + str(menuItem[0]) + ".png"; if os.path.isfile(image): fileHash = hashlib.md5(open(image).read()).hexdigest() cursor = db.cursor() cursor.execute("INSERT INTO media.images(pointer_uid, image_type, image_hash, created_at)\ VALUES ({0}, 'menu_items', '{1}', NOW())".format(menuItem[0], fileHash)) db.commit() else: print "Can't find it: " + image
#Avnet Data Export import sys from db_connection import DbConnection import HipChat import csv import traceback import paramiko try: EXPORT_FILE_PATH = "/data/Avnet_Export/" conn = DbConnection().connection venueUid = sys.argv[1] cursor = conn.cursor() cursor.execute("SELECT DATE(CONVERT_TZ(NOW(), 'UTC', (SELECT local_timezone_long FROM setup.venues WHERE id = %s)))", (venueUid)) date = cursor.fetchone()[0] formattedDate = date.strftime("%Y%m%d") ########## # ORDERS # ########## orderFilename = "order_" + formattedDate + ".csv" orderCursor = conn.cursor() orderCursor.execute('''SELECT orders.event_uid, events_x_venues.event_name, orders.id AS 'order_uid', orders.unit_uid, units.name AS 'suite',
from db_connection import DbConnection import sys import HipChat import traceback try: conn = DbConnection().connection cursor = conn.cursor() cursor.execute(''' SELECT venue_uid FROM integrations.venues_levy WHERE is_active = 1 ''') venueUids = cursor.fetchall() for venueUid in venueUids: venueUid = venueUid[0] print "Autolocking events for: " + str(venueUid) cursor.execute( '''SELECT events.id FROM setup.events LEFT JOIN setup.event_controls ON event_controls.event_uid = events.id WHERE venue_uid = %s AND event_date BETWEEN date_sub(NOW(), INTERVAL 24 HOUR) AND NOW() AND (is_locked = 0 OR is_locked is null) AND event_type_uid != 11;''', (venueUid)) unlockedEvents = cursor.fetchall() if len(unlockedEvents) == 0: