from configReader import read_config table_name = read_config("tableName") def generate_query(intent, entities_list, extremum, comparator, order_by, order, limit): try: if (order_by != ''): query_template = u"SELECT {function}({column_name}) FROM {table_name} {where_expression} {order_expression}" else: query_template = u"SELECT DISTINCT {function}({column_name}) FROM {table_name} {where_expression} {order_expression}" select = intent.lower() # joining the queries where_part = build_where_template(entities_list, comparator) order_part = build_order_template(order, order_by) final_query = query_template.format(function=extremum, column_name=select, table_name=table_name, where_expression=where_part, order_expression=order_part) return final_query except: print "Error" return "NULL" def build_where_template(entities_list, comparator):
def run(ini_path): func_name = "Blur Detector" config = read_config(ini_path) vis_input = config["Vis input"] thresh = config["Threshold"] blur_score_txt_path = config["Blur Score txt path"] debug = config["Debug mode"] output_path = config["Output path"] output_edge = config["Output edge path"] log = Logger(config["Logger path"], func_name) # loop over the input images i = 1 log.info("\n") log.info(' | Vis tested : "{}"'.format(vis_input)) log.info(" | Threshold : {} \n".format(thresh)) paths = glob.glob(os.path.join(vis_input, "*.jp*")) with open(os.path.join(blur_score_txt_path, "blur_score_txt.txt"), 'a') as f: f.write( "\n _________________________________________________________________________________" ) f.write('\n | Vis tested : "{}" \n'.format(vis_input)) f.write(" | Threshold : {} \n".format(thresh)) f.write( " | Camera Number | Blur score | Blurry or not \n" ) f.write( " _________________________________________________________________________________\n" ) for imagePath in paths: # load the image, convert it to gray scale, and computes the Variance of Laplacian image = cv2.imread(imagePath) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if not debug: var_of_lap = variance_of_laplacian(gray) else: var_of_lap = variance_of_laplacian( gray, os.path.join(output_edge, "%04d.jpg" % i)) text = "Not Blurry" # if the focus measure is less than the supplied threshold, # then the image should be considered "blurry" with open(os.path.join(blur_score_txt_path, "blur_score_txt2.txt"), 'a') as f: if i < 10: if var_of_lap < thresh: text = "Blurry" f.write( " | Camera {} | Blur Score: {:.3f} | {}\n". format(i, var_of_lap, text)) else: f.write( " | Camera {} | Blur Score: {:.3f} | {}\n". format(i, var_of_lap, text)) else: if var_of_lap < thresh: text = "Blurry" f.write( " | Camera {} | Blur Score: {:.3f} | {}\n". format(i, var_of_lap, text)) else: f.write( " | Camera {} | Blur Score: {:.3f} | {}\n". format(i, var_of_lap, text)) if var_of_lap < thresh: text = "Blurry" log.info("| Camera {} is {} Blur Score: {:.3f}".format( i, text, var_of_lap)) else: log.info("| Camera {} is {} Blur Score: {:.3f}".format( i, text, var_of_lap)) if debug == 1: cv2.putText( image, "Camera {} is {} , Blur Score: {:.3f}".format( i, text, var_of_lap), (160, 160), cv2.FONT_HERSHEY_SIMPLEX, 3.5, (255, 0, 255), 15) cv2.imwrite(os.path.join(output_path, "%04d.jpg" % i), image) i += 1 end = time.time() log.info("| ________________________________________________________") log.info( "| Finished Successfully | Total time : {:.2f} Seconds |\n\n\n". format(end - start))
import json import urllib import requests as requests from configReader import read_config access_token = read_config("witaiToken") def load_entity(entity, values): url = 'https://api.wit.ai/entities?v=20160526' headers = { 'Authorization': 'Bearer ' + access_token, 'Content-Type': 'application/json' } payload = {'id': entity, 'values': values} r = requests.post(url, data=json.dumps(payload), headers=headers) if r.status_code == 200: print 'entity uploaded successfully ' + entity else: print 'something went wrong when uploading ' + entity + ': error code ' + str( r.status_code) print r.content def load_intent(intents): values = [] for intent in intents: value = {'value': intent, 'expressions': []} values.append(value)
import sys import glob import math import os from xml.dom import minidom import replayLogger import configReader config = configReader.read_config(".\\folderPath.ini") if config is None: raise Exception("Cannot parse config file") received_path = config["Path"] appPath = ".\\" logZ = replayLogger.Logger(appPath, "pcdMeta") def get_real_path(r_fgc, path): return os.path.join('\\\\', r_fgc, 'D$\events', path) master_list = [] # received_path = "C:\Users\mikeyt\Desktop\ProjectMeta" DYNAMIC_INIS_BACKUP_PATH = os.path.join(received_path, 'DynamicINIsBackup') XGEN_MAIN_FILTERED_PCD_PATH = os.path.join(received_path, 'XGEN_MAIN_FILTERED_PCD') XGEN_MAIN_PCD_PATH = os.path.join(received_path, 'XGEN_MAIN_PCD') XGEN_OUTSIDE_FILTERED_PCD_PATH = os.path.join(received_path, 'XGEN_OUTSIDE_FILTERED_PCD') XGEN_OUTSIDE_PCD_PATH = os.path.join(received_path, 'XGEN_OUTSIDE_PCD') XGEN_SEED_ZONE_A_PATH = os.path.join(received_path, 'XGEN_SEED_ZONE_A')
def run(): if read_config("init") == "true": init()