def get_user_info_by_global_id(self, global_id=None): with self.run_cursor() as cursor: if global_id is not None: query = f""" SELECT * FROM users WHERE id = {global_id}; """ cursor.execute(query) users_fetch = cursor.fetchone() if users_fetch is None: return None column_desc = self.get_columns_info() if len(users_fetch) != len(column_desc): logger.log("user_db_manip", f"Каким-то чудом длины не совпадают!") return ans_dict = {} for it in range(len(users_fetch)): if column_desc[it][1] == "subs": ans_dict[column_desc[it][1]] = jl(users_fetch[it]) else: ans_dict[column_desc[it][1]] = users_fetch[it] return ans_dict
def get_class_groups(self, class_id): with self.run_cursor() as cursor: query = f""" SELECT groups FROM classes WHERE id = {class_id} """ cursor.execute(query) fetch = cursor.fetchone() return jl(fetch[0])
def __init__(self, schedule_params): self.list_of_adds = [0, 1, 2] self.add_teacher = 0 self.add_room = 0 if schedule_params is not None: params = jl(schedule_params) self.list_of_adds = params['list_of_adds'] self.add_teacher = params['add_teacher'] self.add_room = params['add_room']
def get_user_info(self, user_id, src): vk_id = None tg_id = None alice_id = None if src == "vk": vk_id = user_id if src == "tg": tg_id = user_id if src == "alice": alice_id = user_id with self.run_cursor() as cursor: query = None if vk_id is not None: query = f""" SELECT * FROM users WHERE vk_id = {vk_id}; """ elif tg_id is not None: query = f""" SELECT * FROM users WHERE tg_id = {tg_id}; """ elif alice_id is not None: query = f""" SELECT * FROM users WHERE alice_id = '{alice_id}'; """ cursor.execute(query) users_fetch = cursor.fetchone() if users_fetch is None: return None column_desc = self.get_columns_info() if len(users_fetch) != len(column_desc): logger.log("user_db_manip", f"Каким-то чудом длины не совпадают!") return ans_dict = {} for it in range(len(users_fetch)): if column_desc[it][1] == "subs": ans_dict[column_desc[it][1]] = jl(users_fetch[it]) else: ans_dict[column_desc[it][1]] = users_fetch[it] logger.log("users_db_parser", f"returning info: {ans_dict}") return ans_dict
def load(self): fop = Path.home() / Path("COE_Report/configs") / self.fname with open(fop,"r") as f: return jl(f)
plt.close("all") def onclick(event): print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (event.button, event.x, event.y, event.xdata, event.ydata)) spotNumbers = range(1, 23) from json import load as jl config_fname = '../../cfg/cam_config.json' # Read config file with open(config_fname) as f: cams = jl(f) camera = cams['cam3'] _plot = True fname = camera['im_full_path'] im = cv2.imread(fname) #im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) edges = cv2.Canny(im, 100, 200) if _plot is True: #plt.ion()
#!C:/Python27/python.exe print("Content-Type: text/html\n") from json import loads as jl from time import gmtime as gm import datetime print("<h3>list of all call Received today : </h3>") k = "buffer/call-" + str(gm().tm_mday).zfill(2) + str( gm().tm_mon).zfill(2) + str(gm().tm_year) + ".json" with open(k) as f: data = jl(f.read()) for i in data[len(data):0:-1]: print("//**********************" + "<br/>") print("Number : " + i['number'] + "<br/>") print("Time : " + str(datetime.datetime.fromtimestamp(i['times'])) + "<br/>")
import numpy as np plot_spots = range(1,23) tmin = -24 tmax = 0 #fdir = os.path.expanduser('~/work/ggp/bpark/catch_output/spot_logs/') fdir = os.path.expanduser('~/work/ggp/bpark/archive/0316/spot_logs/') config_fname = '../../cfg/cam_config.json' spots = get_spot_data(fdir,plot_spots) # Read config file with open(config_fname) as f: camConfig = jl(f) spot_edges = {} for c,cam in camConfig.iteritems(): sl = cam['spots'] for s in sl: sn = s['number'] spot_edges[sn] = s['base_nEdges'] i = 1 for s in spots: if 'plot_spots' in locals(): if s['num'] not in plot_spots:
# 2: Создать модуль music_deserialize.py. В этом модуле открыть файлы group.json и group.pickle, # прочитать из них информацию. И получить объект: словарь из предыдущего задания. import music_serialize as ms from json import load as jl from pickle import load as pl ms.js() ms.pk() with open('group.json', 'r', encoding='utf-8') as file: print(jl(file)) with open('group.pickle', 'rb') as file: print(pl(file))
from json import loads as jl a = jl('["foo", {"bar":["baz", null, 1.0, 2]}]') print a b = jl('{"a.b.c" : 2}') print b[u'a.b.c'] c = """ mainwindow.title = "test" mainwindow.position.z = 100 mainwindow.position.y = 200""" d = '[{' + c.replace('=', '":').replace('\n', '\n"').strip().replace('\n', ',') + '}]' print d print jl(d)
site_dir = '/var/www/html/bpark/' os.environ['TZ'] = 'US/Eastern' ########################################## ########################################## ########################################## time.tzset() # Create the spots spots = {num: Spot(num) for num in spotNumbers} # Read config file with open(config_fname) as f: camConfig = jl(f) # Initialize the cameras (and spot info) from config cams = {} for c, cam in camConfig.iteritems(): tc = Camera(spots, cam) cams[cam['number']] = tc # Read api config, pass to Payment for initialization payLog = os.path.join(data_dir, 'pmAPI.log') apiConfigFname = '../cfg/apiConfig.json' with open(apiConfigFname) as f: apiConfig = jl(f) payment = Payment(payLog, apiConfig, toErr) # When getting the latest image, move it to a directory