import tkinter as tk from tkinter import messagebox from tkcalendar import * from datetime import datetime from db import Database import re # Instanciate databse object db = Database('ToDo') # Current time now = datetime.now() # Main Application/GUI class class Application(tk.Frame): def __init__(self, master): super().__init__(master) self.master = master master.title('To Do ') # tk.Width height master.geometry("900x500") # Create widgets/grid self.create_widgets() # Init selected item var self.selected_item = 0 # Populate initial list self.populate_list() def create_widgets(self):
from flask import Flask, json, Response, request, render_template from werkzeug.utils import secure_filename from os import path, getcwd from db import Database from face import Face import time from datetime import date import datetime app = Flask(__name__) app.config['file_allowed'] = ['image/png', 'image/jpeg'] app.config['storage'] = path.join(getcwd(), 'storage') app.db = Database() app.face = Face(app) def success_handle(output, status=200, mimetype='application/json'): return Response(output, status=status, mimetype=mimetype) def error_handle(error_message, status=500, mimetype='application/json'): return Response(json.dumps({"error": { "message": error_message }}), status=status, mimetype=mimetype) def get_user_by_id(user_id): print("user id is :")
from tkinter import * from tkinter import messagebox from db import Database db = Database('store.db') def populate_list(): parts_list.delete(0, END) for row in db.fetch(): parts_list.insert(END, row) def add_product(): if (part_text.get() == '' or customer_text.get() == '' or retailer_text.get() == '' or price_text.get() == ''): messagebox.showerror('Required Fields', 'Please enter all the details') return db.insert(part_text.get(), customer_text.get(), retailer_text.get(), price_text.get()) clear_text() populate_list() def select_item(event): global selected_item index = parts_list.curselection()[0] selected_item = parts_list.get(index)
import logging.config from telegram.ext import CommandHandler, ConversationHandler from telegram.ext import Updater from telegram.ext import MessageHandler, Filters import telegram from db import Database import configparser import time import smtplib import locale locale.setlocale(locale.LC_ALL, 'ru_RU.UTF-8') config = configparser.ConfigParser() config.read('/PATH/TO/BOT/config') db = Database(config['Database']['Path']) logging.config.fileConfig('/PATH/TO/BOT/log_bot.conf') log = logging.getLogger(__name__) FEEDBACK, FLASH, OFFER, POLITIC, ECONOMY, FINANCE, BUSINESS, TECH = range(8) # Все конопки # start politic_button = telegram.KeyboardButton(text="Политика") economy_button = telegram.KeyboardButton(text="Экономика") finance_button = telegram.KeyboardButton(text="Финансы") business_button = telegram.KeyboardButton(text="Бизнес") tech_button = telegram.KeyboardButton(text="Технологии и медиа") option_button = telegram.KeyboardButton(text='Настройки') # option source_button = telegram.KeyboardButton(text="Источники")
from discord import Intents from db import Database from typing import Tuple from math import sqrt # VARIABLES # my_last_message = "" dadude = "" bot = commands.Bot( command_prefix='>', intents=Intents.all(), activity=discord.Game(name="Beep boop startup process started")) TOKEN = os.getenv('DISCORD_TOKEN') guild = bot.get_guild(757144308204961833) DATABASE_URL = os.environ['DATABASE_URL'] bot.db = Database() workes = [ "You crush some tomatos", "You make some pancakes for your neighbor", "you work at papa johns", "you kill a couple of tomatos, integza is satisfied", "you open an onlyfans, but youre ugly", "you disrupt tomato lord Jr.'s workflow", "you slash tomatos with your katana, integza san is satisfied", "you milk some almonds" ] noxpchannels = [774312474987331627, 774669694648057866, 825541136399597609] # TRIGGERS # metalTriggers = ["3d print metal", "print metal", "metal printer"] printTriggers = [ "printer should", "good (3d|resin) printer", "what printer",
from db import Database db = Database("kopiernudeln") db.init_header() db.resume_search()
from tkinter import * from tkinter import messagebox from db import Database db = Database('inventory_db') def populate_list(): # reset previous list from 0 to end parts_list.delete(0, END) for row in db.fetch(): parts_list.insert(END, row) def add_item(): if '' in [ model_text.get(), brand_text.get(), size_text.get(), color_text.get(), gender_text.get(), type_text.get(), shape_text.get(), style_text.get() ] or 0 in [stock_text.get(), price_text.get()]: messagebox.showerror('Require Fields', 'Please fill in fields') return # item = [model_text.get(), brand_text.get(), size_text.get(), color_text.get(), stock_text.get( # ), price_text.get(), gender_text.get(), type_text.get(), shape_text.get(), style_text.get()] db.insert(model_text.get(), brand_text.get(), size_text.get(),
def add(name,dir,lib_type,skip_dir,skip_file,support_file): with Database() as db: return db.execute("insert into library(name,dir,status,version,lib_type,skip_dir,skip_file,support_file) values(%s,%s,%s,%s,%s,%s,%s,%s)",(name,dir,'unsync',0,lib_type,skip_dir,skip_file,support_file))
def changeName(library_id,name): with Database() as db: db.execute("update library set name=%s where id=%s",(name,library_id))
def __init__(self, client): self._client = client self.db = Database()
def walk(self): with Database() as db: self.new_version=self.version+1 version=self.new_version ''' 优化insert速度处理办法如下: 直接取出当前目录下所有目录、文件后转为字典,使用in逻辑判断 insert之后统一update version 这里保留CONFLICT以备后续处理 ''' def insert_directory(parentname,dirs): ''' 首先查询父目录id,如果未命中,则报错 然后根据父目录id入库 如果发现已经存在,则升级其版本id ''' rows=db.select("select id from item where library_id=%s and path=%s",(self.id,parentname)) if not rows: parent=0 else: parent=rows[0]['id'] rows=db.select("select name,id from item where parent=%s",(parent,)) names={row['name']:row['id'] for row in rows} for name in dirs: if name in ignore_dir or name in names: continue db.execute(f'''insert into item(name,cover,path,library_id,parent,version,item_type) values(%s,0,%s,{self.id},{parent},{version},'dir') ON CONFLICT (library_id,path) do update set version={version} ''',(name,parentname+os.path.sep+name)) db.execute("update item set version=%s where parent=%s ",(version,parent)) def insert_files(parentname,files): ''' 首先查询父目录id,如果未命中,则报错 然后根据父目录id入库 如果发现已经存在,则升级其版本id 注:当前仅考虑逐个insert,后续如果发现性能问题,另外考虑批量手段 ''' rows=db.select("select id from item where library_id=%s and path=%s",(self.id,parentname)) if not rows: parent=0 if parentname!=self.dir: # 只有已经跳过的文件夹才会有不存在库中的问题 return else: parent=rows[0]['id'] rows=db.select("select name,id from item where parent=%s",(parent,)) names={row['name']:row['id'] for row in rows} for name in files: if name in ignore_file: continue if name.startswith('.'): continue if name.split('.')[-1].lower() in ("jpg",'png','bmp','jpeg','gif','mp4','avi','mkv','webm','flv','mov','mp3','wav','flac'): if name in names: continue db.execute('''insert into item(name,path,parent,library_id,version,item_type) values(%s,%s,%s,%s,%s,'file') ON CONFLICT (library_id,path) do update set version=%s ''',(name,parentname+os.path.sep+name,parent,self.id,version,version)) if name.split('.')[-1].lower() in ("cbz",'cbr','zip','rar'): file_ex=name.split(".")[-1].lower() full_path=parentname+os.path.sep+name if name not in names: rows=db.select(f'''insert into item(name,cover,path,library_id,parent,version,item_type,file_type) values(%s,0,%s,{self.id},{parent},{version},'dir','compress') ON CONFLICT (library_id,path) do update set version={version} returning id ''',(name,full_path)) c_id=rows[0]['id'] db.execute("commit") else: c_id=names[name] if file_ex in ("zip",'cbz'): C_cls=zipfile.ZipFile elif file_ex in ("rar",'cbr'): C_cls=rarfile.RarFile else: # 对于后缀名不是指定的,不做处理 return None try: with C_cls(full_path) as zf: rows=db.select("select id,name from item where parent=%s",(c_id,)) fnames={row['name']:row['id'] for row in rows} for fname in zf.namelist(): if fname in fnames: continue # 处理压缩文件内部的路径问题 real_name=fname.split("/")[-1] if fname in ignore_file or real_name in ignore_file: continue if fname.startswith('.') or real_name.startswith('.'): continue if fname.startswith('__') or real_name.startswith('__'): continue if fname.split('.')[-1].lower() not in ("jpg",'png','bmp','jpeg','gif'):# 目前压缩文件内仅考虑图片 continue db.execute(f'''insert into item(name,cover,path,library_id,parent,version,item_type) values(%s,0,%s,{self.id},{c_id},{version},'file') ON CONFLICT (library_id,path) do update set version={version} ''',(fname,full_path+os.path.sep+fname)) db.execute("update item set version=%s where parent=%s ",(version,c_id)) db.execute("commit") except Exception as e: print("错误的压缩文件:",full_path,str(e)) db.execute("update item set version=%s where parent=%s ",(version,parent)) for root, dirs, files in os.walk(self.dir): import time if root.split(os.path.sep)[-1] in ignore_dir: continue insert_directory(root,dirs) insert_files(root,files) db.execute("commit") db.execute("delete from item where library_id=%s and version=%s",(self.id,self.version)) db.execute("commit")
from tkinter import * import tkinter.messagebox from tkinter import Tk from db import Database import os from db import * import functools # Instanciate database object db = Database(r'\\raspberrypi\share\jsj.db') # **** Functions **** def populate_list(): order_list.delete(0, END) for row in db.fetch(): order_list.insert(END, row) def populate_order(): order_list.delete(0, END) for row_o in db.getordero(orderid_entry.get(), orderid_entry.get(), orderid_entry.get(), orderid_entry.get()): order_list.insert(END, row_o) for row_a in db.getordera(orderid_entry.get(), orderid_entry.get(), orderid_entry.get(), orderid_entry.get()): order_list.insert(END, row_a) for row_b in db.getorderb(orderid_entry.get(), orderid_entry.get(), orderid_entry.get(), orderid_entry.get()): order_list.insert(END, row_b)
from bot108 import bot import schedule import constants from db import Database database = Database(constants.bot_database) #MONDAY #wake up def job_wed1(chat_id): bot.send_message(chat_id, '🌝Добрейшего утра!) \n' '\n' '🕺Время просыпаться, запускать сознание и тело для новых свершений!\n' '🦍Сегодня тебя ждет новый день. Определи ногу с которой ты встаешь и вперед на утренние процедуры.') # почистить зубы def job_wed2(chat_id): bot.send_message(chat_id, '👐Пожалуйста возьми зубную щетку в непривычную для тебя руку. \n ' '⚡️Пусть эта привычка запускает малоактивные части мозга с самого утра и заряжает день уверенностью для решения новых задач. \n' '\n' '👉😀Все также чистим зубы от корней к коронкам. Затем массаж десен.') # waterfasting def job_wed3(chat_id): bot.send_message(chat_id, '🥛➕🥛➕🍋➕👌Пьем стакан воды комнатной температуры натощак и за ним второй с 3 чайными ложками лимонного сока и микроскопической щепоткой пищевой соды.') def job_wed33(chat_id): bot.send_message(chat_id, '🥛➕🥛Если захочется есть, пьем еще воду, стараемся позавтракать первый раз вв 12.30') # warm up + food notice def job_wed4(chat_id): bot.send_message(chat_id, 'https://youtu.be/zVOPQXP587c') bot.send_message(chat_id, '🕙В 10.00 ты получишь нопоминание о режиме питания + рецепт завтрака')
def __init__(self, app): self.socketio = SocketIO(app, cors_allowed_origins="*") self.connections = list() self.socketio.on_event("join", self.on_join) self.db = Database() self.db.connect()
"status": "OK", "msg": "Note modified successfully", "note": note }, status=200 ) else: db.remove_token(token) return web.json_response( { "status": "error", "msg": "Authorization failed" }, status=401 ) db = Database("localhost", "root", "3dSynN3K", "pyNotes") handler = Handler() app = web.Application() app.add_routes([ web.put("/modifyNote", handler.handle_modify_note), web.post("/getNote", handler.handle_get_note), web.post("/createNote", handler.handle_create_note), web.post("/getNotesList", handler.handle_get_notes_list), web.delete("/removeNote", handler.handle_remove_note), web.post("/login", handler.handle_login), web.post("/register", handler.handle_register) ]) if __name__ == "__main__": web.run_app(app)
def drop(library_id): with Database() as db: db.execute("delete from item where library_id=%s",(library_id,)) db.execute("delete from library where id=%s",(library_id,))
from tkinter import * from tkinter import messagebox from db import Database db = Database("store.db") def populate_list(): component_list.delete(0, END) for row in db.fetch(): component_list.insert(END, row) def add_item(): if component_text.get() == "" or customer_text.get( ) == "" or retailer_text.get() == "" or price_text.get() == "": messagebox.showerror("Required Fields", "Please include all fields") return db.insert(component_text.get(), customer_text.get(), retailer_text.get(), price_text.get()) component_list.delete(0, END) component_list.insert(END, (component_text.get(), customer_text.get(), retailer_text.get(), price_text.get())) clear_text() populate_list() def select_item(event): try: global selected_item
def sync_end(self): with Database() as db: self.analysis() db.execute("update library set version=%s,status='synced' where id=%s",(self.new_version,self.id)) self.version=self.new_version
def __init__(self, Satellite_Window=None): '''This class configures and populates the toplevel window. Home_Window is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' font14 = "-family {Helvatica} -size 13 -weight normal -slant " \ "roman -underline 0 -overstrike 0" font9 = "-family {Segoe UI} -size 9 -weight normal -slant " \ "roman -underline 0 -overstrike 0" font10 = "-family {Helvetica} -size 15 -weight normal -slant " \ "roman -underline 0 -overstrike 0" font11 = "-family {Courier New} -size 13 -weight normal -slant " \ "roman -underline 0 -overstrike 0" Satellite_Window.geometry("1491x764+35+31") Satellite_Window.minsize(148, 1) Satellite_Window.maxsize(4112, 1055) Satellite_Window.resizable(1, 1) Satellite_Window.title("SATELLITE CENTRES") Satellite_Window.configure(background="#40b3a2") self.data = Database("dental.db") self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.map('.', background=[('selected', _compcolor), ('active', _ana2color)]) self.menubar = tk.Menu(Satellite_Window, font=font9, bg=_bgcolor, fg=_fgcolor) Satellite_Window.configure(menu=self.menubar) self.File = tk.Menu(Satellite_Window, tearoff=0) self.menubar.add_cascade( menu=self.File, activebackground="#ececec", activeforeground="#000000", background="#d9d9d9", font= ('-family {Segoe UI} -size 9 -weight normal -slant roman -underline 0 -overstrike 0' ), foreground="#000000", label="File") self.File.add_command( activebackground="#ececec", activeforeground="#000000", background="#d9d9d9", font= ('-family {Segoe UI} -size 9 -weight normal -slant roman -underline 0 -overstrike 0' ), foreground="#000000", label="Exit", command=satelite_window_support.destroy_window) self.Department_Label = tk.Label(Satellite_Window) self.Department_Label.place(relx=0.201, rely=0.027, relwidth=0.518, relheight=0.084) self.Department_Label.configure(activebackground="#f9f9f9") self.Department_Label.configure(activeforeground="black") self.Department_Label.configure(background="#d9d9d9") self.Department_Label.configure(disabledforeground="#a3a3a3") self.Department_Label.configure( font="-family {Helvatica} -size 18 -weight normal") self.Department_Label.configure(foreground="#000000") self.Department_Label.configure(highlightbackground="#d9d9d9") self.Department_Label.configure(highlightcolor="black") self.Department_Label.configure(relief="raised") self.Department_Label.configure( text='''Satellite Centre Out Patient''') self.Incharge_Label = tk.Label(Satellite_Window) self.Incharge_Label.place(relx=0.013, rely=0.189, relwidth=0.169, relheight=0.05) self.Incharge_Label.configure(activebackground="#f9f9f9") self.Incharge_Label.configure(activeforeground="black") self.Incharge_Label.configure(background="#d9d9d9") self.Incharge_Label.configure(disabledforeground="#a3a3a3") self.Incharge_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Incharge_Label.configure(foreground="#000000") self.Incharge_Label.configure(highlightbackground="#d9d9d9") self.Incharge_Label.configure(highlightcolor="black") self.Incharge_Label.configure(text='''Incharge''') self.Incharge_Entry = tk.Entry(Satellite_Window) self.Incharge_Entry.place(relx=0.188, rely=0.189, relheight=0.048, relwidth=0.137) self.Incharge_Entry.configure(background="white") self.Incharge_Entry.configure(disabledforeground="#a3a3a3") self.Incharge_Entry.configure(font="-family {Helvatica} -size 10") self.Incharge_Entry.configure(foreground="#000000") self.Incharge_Entry.configure(highlightbackground="#d9d9d9") self.Incharge_Entry.configure(highlightcolor="black") self.Incharge_Entry.configure(insertbackground="black") self.Incharge_Entry.configure(selectbackground="#c4c4c4") self.Incharge_Entry.configure(selectforeground="black") self.Phone_Label = tk.Label(Satellite_Window) self.Phone_Label.place(relx=0.335, rely=0.189, relwidth=0.162, relheight=0.05) self.Phone_Label.configure(activebackground="#f9f9f9") self.Phone_Label.configure(activeforeground="black") self.Phone_Label.configure(background="#d9d9d9") self.Phone_Label.configure(disabledforeground="#a3a3a3") self.Phone_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Phone_Label.configure(foreground="#000000") self.Phone_Label.configure(highlightbackground="#d9d9d9") self.Phone_Label.configure(highlightcolor="black") self.Phone_Label.configure(text='''Phone''') self.Phone_Entry = tk.Entry(Satellite_Window) self.Phone_Entry.place(relx=0.51, rely=0.189, relheight=0.048, relwidth=0.137) self.Phone_Entry.configure(background="white") self.Phone_Entry.configure(disabledforeground="#a3a3a3") self.Phone_Entry.configure(font="-family {Helvatica} -size 10") self.Phone_Entry.configure(foreground="#000000") self.Phone_Entry.configure(highlightbackground="#d9d9d9") self.Phone_Entry.configure(highlightcolor="black") self.Phone_Entry.configure(insertbackground="black") self.Phone_Entry.configure(selectbackground="#c4c4c4") self.Phone_Entry.configure(selectforeground="black") self.Date_Label = tk.Label(Satellite_Window) self.Date_Label.place(relx=0.664, rely=0.189, relwidth=0.122, relheight=0.05) self.Date_Label.configure(activebackground="#f9f9f9") self.Date_Label.configure(activeforeground="black") self.Date_Label.configure(background="#d9d9d9") self.Date_Label.configure(disabledforeground="#a3a3a3") self.Date_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Date_Label.configure(foreground="#000000") self.Date_Label.configure(highlightbackground="#d9d9d9") self.Date_Label.configure(highlightcolor="black") self.Date_Label.configure(text='''Date\nYYYY-MM-DD''') now = datetime.datetime.now() self.Date_Entry = DateEntry(Satellite_Window, year=now.year, month=now.month, day=now.day) self.Date_Entry.place(relx=0.791, rely=0.189, relheight=0.048, relwidth=0.137) self.Date_Entry.configure(background="white") self.Date_Entry.configure(date_pattern='y/mm/dd') self.Date_Entry.configure(font="-family {Helvetica} -size 10") self.Date_Entry.configure(foreground="#000000") self.Date_Entry.configure(borderwidth=2) self.Date_Entry.configure(width=12) # self.Date_Entry = tk.Entry(Satellite_Window) # self.Date_Entry.place(relx=0.791, rely=0.189, relheight=0.048, relwidth=0.137) # self.Date_Entry.configure(background="white") # self.Date_Entry.configure(disabledforeground="#a3a3a3") # self.Date_Entry.configure(font="-family {Helvatica} -size 10") # self.Date_Entry.configure(foreground="#000000") # self.Date_Entry.configure(highlightbackground="#d9d9d9") # self.Date_Entry.configure(highlightcolor="black") # self.Date_Entry.configure(insertbackground="black") # self.Date_Entry.configure(selectbackground="#c4c4c4") # self.Date_Entry.configure(selectforeground="black") self.From_Label = tk.Label(Satellite_Window) self.From_Label.place(relx=0.013, rely=0.311, relwidth=0.162, relheight=0.05) self.From_Label.configure(activebackground="#f9f9f9") self.From_Label.configure(activeforeground="black") self.From_Label.configure(background="#d9d9d9") self.From_Label.configure(disabledforeground="#a3a3a3") self.From_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.From_Label.configure(foreground="#000000") self.From_Label.configure(highlightbackground="#d9d9d9") self.From_Label.configure(highlightcolor="black") self.From_Label.configure(text='''ID From''') self.From_Entry = tk.Entry(Satellite_Window) self.From_Entry.place(relx=0.188, rely=0.311, relwidth=0.137, relheight=0.048) self.From_Entry.configure(background="white") self.From_Entry.configure(disabledforeground="#a3a3a3") self.From_Entry.configure(font="-family {Helvatica} -size 10") self.From_Entry.configure(foreground="#000000") self.From_Entry.configure(highlightbackground="#d9d9d9") self.From_Entry.configure(highlightcolor="black") self.From_Entry.configure(insertbackground="black") self.From_Entry.configure(selectbackground="#c4c4c4") self.From_Entry.configure(selectforeground="black") self.To_Label = tk.Label(Satellite_Window) self.To_Label.place(relx=0.335, rely=0.311, relwidth=0.162, relheight=0.05) self.To_Label.configure(activebackground="#f9f9f9") self.To_Label.configure(activeforeground="black") self.To_Label.configure(background="#d9d9d9") self.To_Label.configure(disabledforeground="#a3a3a3") self.To_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.To_Label.configure(foreground="#000000") self.To_Label.configure(highlightbackground="#d9d9d9") self.To_Label.configure(highlightcolor="black") self.To_Label.configure(text='''ID To''') self.To_Entry = tk.Entry(Satellite_Window) self.To_Entry.place(relx=0.51, rely=0.311, relwidth=0.137, relheight=0.048) self.To_Entry.configure(background="white") self.To_Entry.configure(disabledforeground="#a3a3a3") self.To_Entry.configure(font="-family {Helvatica} -size 10") self.To_Entry.configure(foreground="#000000") self.To_Entry.configure(highlightbackground="#d9d9d9") self.To_Entry.configure(highlightcolor="black") self.To_Entry.configure(insertbackground="black") self.To_Entry.configure(selectbackground="#c4c4c4") self.To_Entry.configure(selectforeground="black") self.Endodontics_Label = tk.Label(Satellite_Window) self.Endodontics_Label.place(relx=0.013, rely=0.379, relwidth=0.162, relheight=0.05) self.Endodontics_Label.configure(activebackground="#f9f9f9") self.Endodontics_Label.configure(activeforeground="black") self.Endodontics_Label.configure(background="#d9d9d9") self.Endodontics_Label.configure(disabledforeground="#a3a3a3") self.Endodontics_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Endodontics_Label.configure(foreground="#000000") self.Endodontics_Label.configure(highlightbackground="#d9d9d9") self.Endodontics_Label.configure(highlightcolor="black") self.Endodontics_Label.configure(text='''Endodontics''') self.Periodont_Label = tk.Label(Satellite_Window) self.Periodont_Label.place(relx=0.013, rely=0.447, relwidth=0.162, relheight=0.05) self.Periodont_Label.configure(activebackground="#f9f9f9") self.Periodont_Label.configure(activeforeground="black") self.Periodont_Label.configure(background="#d9d9d9") self.Periodont_Label.configure(disabledforeground="#a3a3a3") self.Periodont_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Periodont_Label.configure(foreground="#000000") self.Periodont_Label.configure(highlightbackground="#d9d9d9") self.Periodont_Label.configure(highlightcolor="black") self.Periodont_Label.configure(text='''Periodont''') self.Orthodontics_Label = tk.Label(Satellite_Window) self.Orthodontics_Label.place(relx=0.013, rely=0.514, relwidth=0.162, relheight=0.05) self.Orthodontics_Label.configure(activebackground="#f9f9f9") self.Orthodontics_Label.configure(activeforeground="black") self.Orthodontics_Label.configure(background="#d9d9d9") self.Orthodontics_Label.configure(disabledforeground="#a3a3a3") self.Orthodontics_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Orthodontics_Label.configure(foreground="#000000") self.Orthodontics_Label.configure(highlightbackground="#d9d9d9") self.Orthodontics_Label.configure(highlightcolor="black") self.Orthodontics_Label.configure(text='''Orthodontics''') self.Surgery_Label = tk.Label(Satellite_Window) self.Surgery_Label.place(relx=0.013, rely=0.582, relwidth=0.162, relheight=0.05) self.Surgery_Label.configure(activebackground="#f9f9f9") self.Surgery_Label.configure(activeforeground="black") self.Surgery_Label.configure(background="#d9d9d9") self.Surgery_Label.configure(disabledforeground="#a3a3a3") self.Surgery_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Surgery_Label.configure(foreground="#000000") self.Surgery_Label.configure(highlightbackground="#d9d9d9") self.Surgery_Label.configure(highlightcolor="black") self.Surgery_Label.configure(text='''Surgery''') self.Pedodont_Label = tk.Label(Satellite_Window) self.Pedodont_Label.place(relx=0.013, rely=0.65, relwidth=0.162, relheight=0.05) self.Pedodont_Label.configure(activebackground="#f9f9f9") self.Pedodont_Label.configure(activeforeground="black") self.Pedodont_Label.configure(background="#d9d9d9") self.Pedodont_Label.configure(disabledforeground="#a3a3a3") self.Pedodont_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Pedodont_Label.configure(foreground="#000000") self.Pedodont_Label.configure(highlightbackground="#d9d9d9") self.Pedodont_Label.configure(highlightcolor="black") self.Pedodont_Label.configure(text='''Pedodont''') self.Oralpatho_Label = tk.Label(Satellite_Window) self.Oralpatho_Label.place(relx=0.335, rely=0.379, relwidth=0.162, relheight=0.05) self.Oralpatho_Label.configure(activebackground="#f9f9f9") self.Oralpatho_Label.configure(activeforeground="black") self.Oralpatho_Label.configure(background="#d9d9d9") self.Oralpatho_Label.configure(disabledforeground="#a3a3a3") self.Oralpatho_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Oralpatho_Label.configure(foreground="#000000") self.Oralpatho_Label.configure(highlightbackground="#d9d9d9") self.Oralpatho_Label.configure(highlightcolor="black") self.Oralpatho_Label.configure(text='''Oralpatho''') self.Public_Health_Label = tk.Label(Satellite_Window) self.Public_Health_Label.place(relx=0.335, rely=0.447, relwidth=0.162, relheight=0.05) self.Public_Health_Label.configure(activebackground="#f9f9f9") self.Public_Health_Label.configure(activeforeground="black") self.Public_Health_Label.configure(background="#d9d9d9") self.Public_Health_Label.configure(disabledforeground="#a3a3a3") self.Public_Health_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Public_Health_Label.configure(foreground="#000000") self.Public_Health_Label.configure(highlightbackground="#d9d9d9") self.Public_Health_Label.configure(highlightcolor="black") self.Public_Health_Label.configure(text='''Public Health''') self.Oral_Mea_Label = tk.Label(Satellite_Window) self.Oral_Mea_Label.place(relx=0.335, rely=0.514, relwidth=0.162, relheight=0.05) self.Oral_Mea_Label.configure(activebackground="#f9f9f9") self.Oral_Mea_Label.configure(activeforeground="black") self.Oral_Mea_Label.configure(background="#d9d9d9") self.Oral_Mea_Label.configure(disabledforeground="#a3a3a3") self.Oral_Mea_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Oral_Mea_Label.configure(foreground="#000000") self.Oral_Mea_Label.configure(highlightbackground="#d9d9d9") self.Oral_Mea_Label.configure(highlightcolor="black") self.Oral_Mea_Label.configure(text='''Oral mea''') self.Prostho_Label = tk.Label(Satellite_Window) self.Prostho_Label.place(relx=0.335, rely=0.582, relwidth=0.162, relheight=0.05) self.Prostho_Label.configure(activebackground="#f9f9f9") self.Prostho_Label.configure(activeforeground="black") self.Prostho_Label.configure(background="#d9d9d9") self.Prostho_Label.configure(disabledforeground="#a3a3a3") self.Prostho_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Prostho_Label.configure(foreground="#000000") self.Prostho_Label.configure(highlightbackground="#d9d9d9") self.Prostho_Label.configure(highlightcolor="black") self.Prostho_Label.configure(text='''Prostho''') self.Grand_Total_Label = tk.Label(Satellite_Window) self.Grand_Total_Label.place(relx=0.335, rely=0.65, relwidth=0.162, relheight=0.05) self.Grand_Total_Label.configure(activebackground="#f9f9f9") self.Grand_Total_Label.configure(activeforeground="black") self.Grand_Total_Label.configure(background="#d9d9d9") self.Grand_Total_Label.configure(disabledforeground="#a3a3a3") self.Grand_Total_Label.configure( font="-family {Helvatica} -size 13 -weight normal") self.Grand_Total_Label.configure(foreground="#000000") self.Grand_Total_Label.configure(highlightbackground="#d9d9d9") self.Grand_Total_Label.configure(highlightcolor="black") self.Grand_Total_Label.configure(text='''Grand Total''') # Defining the entries self.Endodontics_Entry = tk.Entry(Satellite_Window) self.Endodontics_Entry.place(relx=0.188, rely=0.379, relwidth=0.137, relheight=0.048) self.Endodontics_Entry.configure(background="white") self.Endodontics_Entry.configure(disabledforeground="#a3a3a3") self.Endodontics_Entry.configure(font="-family {Helvatica} -size 10") self.Endodontics_Entry.configure(foreground="#000000") self.Endodontics_Entry.configure(highlightbackground="#d9d9d9") self.Endodontics_Entry.configure(highlightcolor="black") self.Endodontics_Entry.configure(insertbackground="black") self.Endodontics_Entry.configure(selectbackground="#c4c4c4") self.Endodontics_Entry.configure(selectforeground="black") self.Periodont_Entry = tk.Entry(Satellite_Window) self.Periodont_Entry.place(relx=0.188, rely=0.447, relwidth=0.137, relheight=0.048) self.Periodont_Entry.configure(background="white") self.Periodont_Entry.configure(disabledforeground="#a3a3a3") self.Periodont_Entry.configure(font="-family {Helvatica} -size 10") self.Periodont_Entry.configure(foreground="#000000") self.Periodont_Entry.configure(highlightbackground="#d9d9d9") self.Periodont_Entry.configure(highlightcolor="black") self.Periodont_Entry.configure(insertbackground="black") self.Periodont_Entry.configure(selectbackground="#c4c4c4") self.Periodont_Entry.configure(selectforeground="black") self.Orthodontics_Entry = tk.Entry(Satellite_Window) self.Orthodontics_Entry.place(relx=0.188, rely=0.514, relwidth=0.137, relheight=0.048) self.Orthodontics_Entry.configure(background="white") self.Orthodontics_Entry.configure(disabledforeground="#a3a3a3") self.Orthodontics_Entry.configure(font="-family {Helvatica} -size 10") self.Orthodontics_Entry.configure(foreground="#000000") self.Orthodontics_Entry.configure(highlightbackground="#d9d9d9") self.Orthodontics_Entry.configure(highlightcolor="black") self.Orthodontics_Entry.configure(insertbackground="black") self.Orthodontics_Entry.configure(selectbackground="#c4c4c4") self.Orthodontics_Entry.configure(selectforeground="black") self.Surgery_Entry = tk.Entry(Satellite_Window) self.Surgery_Entry.place(relx=0.188, rely=0.582, relwidth=0.137, relheight=0.048) self.Surgery_Entry.configure(background="white") self.Surgery_Entry.configure(disabledforeground="#a3a3a3") self.Surgery_Entry.configure(font="-family {Helvatica} -size 10") self.Surgery_Entry.configure(foreground="#000000") self.Surgery_Entry.configure(highlightbackground="#d9d9d9") self.Surgery_Entry.configure(highlightcolor="black") self.Surgery_Entry.configure(insertbackground="black") self.Surgery_Entry.configure(selectbackground="#c4c4c4") self.Surgery_Entry.configure(selectforeground="black") self.Pedodont_Entry = tk.Entry(Satellite_Window) self.Pedodont_Entry.place(relx=0.188, rely=0.65, relwidth=0.137, relheight=0.048) self.Pedodont_Entry.configure(background="white") self.Pedodont_Entry.configure(disabledforeground="#a3a3a3") self.Pedodont_Entry.configure(font="-family {Helvatica} -size 10") self.Pedodont_Entry.configure(foreground="#000000") self.Pedodont_Entry.configure(highlightbackground="#d9d9d9") self.Pedodont_Entry.configure(highlightcolor="black") self.Pedodont_Entry.configure(insertbackground="black") self.Pedodont_Entry.configure(selectbackground="#c4c4c4") self.Pedodont_Entry.configure(selectforeground="black") self.Oralpatho_Entry = tk.Entry(Satellite_Window) self.Oralpatho_Entry.place(relx=0.51, rely=0.379, relwidth=0.137, relheight=0.048) self.Oralpatho_Entry.configure(background="white") self.Oralpatho_Entry.configure(disabledforeground="#a3a3a3") self.Oralpatho_Entry.configure(font="-family {Helvatica} -size 10") self.Oralpatho_Entry.configure(foreground="#000000") self.Oralpatho_Entry.configure(highlightbackground="#d9d9d9") self.Oralpatho_Entry.configure(highlightcolor="black") self.Oralpatho_Entry.configure(insertbackground="black") self.Oralpatho_Entry.configure(selectbackground="#c4c4c4") self.Oralpatho_Entry.configure(selectforeground="black") self.Public_Health_Entry = tk.Entry(Satellite_Window) self.Public_Health_Entry.place(relx=0.51, rely=0.447, relwidth=0.137, relheight=0.048) self.Public_Health_Entry.configure(background="white") self.Public_Health_Entry.configure(disabledforeground="#a3a3a3") self.Public_Health_Entry.configure(font="-family {Helvatica} -size 10") self.Public_Health_Entry.configure(foreground="#000000") self.Public_Health_Entry.configure(highlightbackground="#d9d9d9") self.Public_Health_Entry.configure(highlightcolor="black") self.Public_Health_Entry.configure(insertbackground="black") self.Public_Health_Entry.configure(selectbackground="#c4c4c4") self.Public_Health_Entry.configure(selectforeground="black") self.Oral_Mea_Entry = tk.Entry(Satellite_Window) self.Oral_Mea_Entry.place(relx=0.51, rely=0.514, relwidth=0.137, relheight=0.048) self.Oral_Mea_Entry.configure(background="white") self.Oral_Mea_Entry.configure(disabledforeground="#a3a3a3") self.Oral_Mea_Entry.configure(font="-family {Helvatica} -size 10") self.Oral_Mea_Entry.configure(foreground="#000000") self.Oral_Mea_Entry.configure(highlightbackground="#d9d9d9") self.Oral_Mea_Entry.configure(highlightcolor="black") self.Oral_Mea_Entry.configure(insertbackground="black") self.Oral_Mea_Entry.configure(selectbackground="#c4c4c4") self.Oral_Mea_Entry.configure(selectforeground="black") self.Prostho_Entry = tk.Entry(Satellite_Window) self.Prostho_Entry.place(relx=0.51, rely=0.582, relwidth=0.137, relheight=0.048) self.Prostho_Entry.configure(background="white") self.Prostho_Entry.configure(disabledforeground="#a3a3a3") self.Prostho_Entry.configure(font="-family {Helvatica} -size 10") self.Prostho_Entry.configure(foreground="#000000") self.Prostho_Entry.configure(highlightbackground="#d9d9d9") self.Prostho_Entry.configure(highlightcolor="black") self.Prostho_Entry.configure(insertbackground="black") self.Prostho_Entry.configure(selectbackground="#c4c4c4") self.Prostho_Entry.configure(selectforeground="black") self.Grand_Total_Entry = tk.Entry(Satellite_Window) self.Grand_Total_Entry.place(relx=0.51, rely=0.65, relwidth=0.137, relheight=0.048) self.Grand_Total_Entry.configure(background="white") self.Grand_Total_Entry.configure(disabledforeground="#a3a3a3") self.Grand_Total_Entry.configure(font="-family {Helvatica} -size 10") self.Grand_Total_Entry.configure(foreground="#000000") self.Grand_Total_Entry.configure(highlightbackground="#d9d9d9") self.Grand_Total_Entry.configure(highlightcolor="black") self.Grand_Total_Entry.configure(insertbackground="black") self.Grand_Total_Entry.configure(selectbackground="#c4c4c4") self.Grand_Total_Entry.configure(selectforeground="black") self.Add_Button_ = tk.Button(Satellite_Window) self.Add_Button_.place(relx=0.798, rely=0.311, relwidth=0.078, relheight=0.06) self.Add_Button_.configure(activebackground="#ececec") self.Add_Button_.configure(activeforeground="#000000") self.Add_Button_.configure(background="#d9d9d9") self.Add_Button_.configure(disabledforeground="#a3a3a3") self.Add_Button_.configure( font="-family {Helvatica} -size 13 -weight normal") self.Add_Button_.configure(foreground="#000000") self.Add_Button_.configure(highlightbackground="#d9d9d9") self.Add_Button_.configure(highlightcolor="black") self.Add_Button_.configure(pady="0") self.Add_Button_.configure(text='''ADD''', command=self.add_item) self.Delete_Button = tk.Button(Satellite_Window) self.Delete_Button.place(relx=0.798, rely=0.392, relwidth=0.078, relheight=0.06) self.Delete_Button.configure(activebackground="#ececec") self.Delete_Button.configure(activeforeground="#000000") self.Delete_Button.configure(background="#d9d9d9") self.Delete_Button.configure(disabledforeground="#a3a3a3") self.Delete_Button.configure( font="-family {Helvatica} -size 13 -weight normal") self.Delete_Button.configure(foreground="#000000") self.Delete_Button.configure(highlightbackground="#d9d9d9") self.Delete_Button.configure(highlightcolor="black") self.Delete_Button.configure(pady="0") self.Delete_Button.configure(text='''DELETE''', command=self.remove_item) self.Update_Button = tk.Button(Satellite_Window) self.Update_Button.place(relx=0.798, rely=0.474, relwidth=0.078, relheight=0.06) self.Update_Button.configure(activebackground="#ececec") self.Update_Button.configure(activeforeground="#000000") self.Update_Button.configure(background="#d9d9d9") self.Update_Button.configure(disabledforeground="#a3a3a3") self.Update_Button.configure( font="-family {Helvatica} -size 13 -weight normal") self.Update_Button.configure(foreground="#000000") self.Update_Button.configure(highlightbackground="#d9d9d9") self.Update_Button.configure(highlightcolor="black") self.Update_Button.configure(pady="0") self.Update_Button.configure(text='''UPDATE''', command=self.update_item) self.Clear_Button = tk.Button(Satellite_Window) self.Clear_Button.place(relx=0.798, rely=0.555, relwidth=0.078, relheight=0.06) self.Clear_Button.configure(activebackground="#ececec") self.Clear_Button.configure(activeforeground="#000000") self.Clear_Button.configure(background="#d9d9d9") self.Clear_Button.configure(disabledforeground="#a3a3a3") self.Clear_Button.configure( font="-family {Helvatica} -size 13 -weight normal") self.Clear_Button.configure(foreground="#000000") self.Clear_Button.configure(highlightbackground="#d9d9d9") self.Clear_Button.configure(highlightcolor="black") self.Clear_Button.configure(pady="0") self.Clear_Button.configure(text='''CLEAR''', command=self.clear_text) self.Scrolledlistbox3 = ScrolledListBox(Satellite_Window) self.Scrolledlistbox3.place(relx=0.02, rely=0.717, relheight=0.253, relwidth=0.969) self.Scrolledlistbox3.configure(background="white") self.Scrolledlistbox3.configure(disabledforeground="#a3a3a3") self.Scrolledlistbox3.configure(font=font10) self.Scrolledlistbox3.configure(foreground="black") self.Scrolledlistbox3.configure(highlightbackground="#d9d9d9") self.Scrolledlistbox3.configure(highlightcolor="#d9d9d9") self.Scrolledlistbox3.configure(selectbackground="#c4c4c4") self.Scrolledlistbox3.configure(selectforeground="black") self.center_radio = tk.IntVar(None, 1) # self.center_radio = department_window_support.var self.Centre1_Radio = tk.Radiobutton(Satellite_Window) self.Centre1_Radio.place(relx=0.013, rely=0.135, relheight=0.042, relwidth=0.18) self.Centre1_Radio.configure(activebackground="#ececec") self.Centre1_Radio.configure(activeforeground="#000000") self.Centre1_Radio.configure(background="#d9d9d9") self.Centre1_Radio.configure(disabledforeground="#a3a3a3") self.Centre1_Radio.configure(font=font14) self.Centre1_Radio.configure(foreground="#000000") self.Centre1_Radio.configure(highlightbackground="#d9d9d9") self.Centre1_Radio.configure(highlightcolor="black") self.Centre1_Radio.configure(justify='left') self.Centre1_Radio.configure(text='''Centre1''') self.Centre1_Radio.configure(value=1) self.Centre1_Radio.configure(variable=self.center_radio) self.Centre2_Radio = tk.Radiobutton(Satellite_Window) self.Centre2_Radio.place(relx=0.208, rely=0.135, relheight=0.042, relwidth=0.18) self.Centre2_Radio.configure(activebackground="#ececec") self.Centre2_Radio.configure(activeforeground="#000000") self.Centre2_Radio.configure(background="#d9d9d9") self.Centre2_Radio.configure(disabledforeground="#a3a3a3") self.Centre2_Radio.configure( font="-family {Helvatica} -size 13 -weight normal") self.Centre2_Radio.configure(foreground="#000000") self.Centre2_Radio.configure(highlightbackground="#d9d9d9") self.Centre2_Radio.configure(highlightcolor="black") self.Centre2_Radio.configure(justify='left') self.Centre2_Radio.configure(text='''Centre2''') self.Centre2_Radio.configure(value=2) self.Centre2_Radio.configure(variable=self.center_radio) self.Centre3_Radio = tk.Radiobutton(Satellite_Window) self.Centre3_Radio.place(relx=0.402, rely=0.135, relheight=0.042, relwidth=0.18) self.Centre3_Radio.configure( activebackground="#ececec", activeforeground="#000000", background="#d9d9d9", disabledforeground="#a3a3a3", font="-family {Helvatica} -size 13 -weight normal", foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black", justify='left', text='''Centre3''', value=3, variable=self.center_radio) self.Centre4_Radio = tk.Radiobutton(Satellite_Window) self.Centre4_Radio.place(relx=0.597, rely=0.135, relheight=0.042, relwidth=0.18) self.Centre4_Radio.configure(activebackground="#ececec") self.Centre4_Radio.configure(activeforeground="#000000") self.Centre4_Radio.configure(background="#d9d9d9") self.Centre4_Radio.configure(disabledforeground="#a3a3a3") self.Centre4_Radio.configure( font="-family {Helvatica} -size 13 -weight normal") self.Centre4_Radio.configure(foreground="#000000") self.Centre4_Radio.configure(highlightbackground="#d9d9d9") self.Centre4_Radio.configure(highlightcolor="black") self.Centre4_Radio.configure(justify='left') self.Centre4_Radio.configure(text='''Centre4''') self.Centre4_Radio.configure(value=4) self.Centre4_Radio.configure(variable=self.center_radio) self.tr_radio = tk.IntVar(None, 1) self.Treated_Radio = tk.Radiobutton(Satellite_Window) self.Treated_Radio.place(relx=0.013, rely=0.257, relheight=0.042, relwidth=0.18) self.Treated_Radio.configure(activebackground="#ececec") self.Treated_Radio.configure(activeforeground="#000000") self.Treated_Radio.configure(background="#d9d9d9") self.Treated_Radio.configure(disabledforeground="#a3a3a3") self.Treated_Radio.configure(font=font14) self.Treated_Radio.configure(foreground="#000000") self.Treated_Radio.configure(highlightbackground="#d9d9d9") self.Treated_Radio.configure(highlightcolor="black") self.Treated_Radio.configure(justify='left') self.Treated_Radio.configure(text='''Treated''') self.Treated_Radio.configure(value=1) self.Treated_Radio.configure(variable=self.tr_radio) self.Reffered_Radio = tk.Radiobutton(Satellite_Window) self.Reffered_Radio.place(relx=0.208, rely=0.257, relheight=0.042, relwidth=0.18) self.Reffered_Radio.configure(activebackground="#ececec") self.Reffered_Radio.configure(activeforeground="#000000") self.Reffered_Radio.configure(background="#d9d9d9") self.Reffered_Radio.configure(disabledforeground="#a3a3a3") self.Reffered_Radio.configure(font=font14) self.Reffered_Radio.configure(foreground="#000000") self.Reffered_Radio.configure(highlightbackground="#d9d9d9") self.Reffered_Radio.configure(highlightcolor="black") self.Reffered_Radio.configure(justify='left') self.Reffered_Radio.configure(text='''Reffered''') self.Reffered_Radio.configure(value=2) self.Reffered_Radio.configure(variable=self.tr_radio) self.Screened_Radio = tk.Radiobutton(Satellite_Window) self.Screened_Radio.place(relx=0.408, rely=0.257, relheight=0.042, relwidth=0.18) self.Screened_Radio.configure(activebackground="#ececec") self.Screened_Radio.configure(activeforeground="#000000") self.Screened_Radio.configure(background="#d9d9d9") self.Screened_Radio.configure(disabledforeground="#a3a3a3") self.Screened_Radio.configure(font=font14) self.Screened_Radio.configure(foreground="#000000") self.Screened_Radio.configure(highlightbackground="#d9d9d9") self.Screened_Radio.configure(highlightcolor="black") self.Screened_Radio.configure(justify='left') self.Screened_Radio.configure(text='''Screened''') self.Screened_Radio.configure(value=3) self.Screened_Radio.configure(variable=self.tr_radio) self.populate_list()
import random import json from fake_useragent import UserAgent ua = UserAgent() session = requests_html.HTMLSession() # session = requests.session() session.keep_alive = False url = 'https://movie.douban.com/j/new_search_subjects?sort=T&range={},{}&tag={}&start={}' # fetcher = ProxyFetcher('https') with open('setting.json') as f: setting = json.load(f) db = Database('movie', setting['host'], 27017, setting['username'], setting['password']) tag = '' for rate in range(0, 2): start = 0 if rate == 0: start = 1240 while start < 5000: print(rate, start) while True: # proxy = session.get('http://api.ipify.org', proxies={'http': 'http://127.0.0.1:8081'}).text # proxies = session.get('http://localhost:8899/api/v1/proxies?anonymous').json()['proxies'] # proxy = random.choice(proxies) # proxy = proxy['ip'] + ':' + str(proxy['port']) # proxy = fetcher.get_proxy() # while not proxy:
from db import Database import emoji import json import time import random db = Database("emojipasta") def is_emoji(char): return char in emoji.UNICODE_EMOJI def handle_dual_emojis(string): i = 0 chars = [] while i < len(string): c = string[i] for e in emoji.UNICODE_EMOJI: #print((e,len(e))) if string[i:i + len(e)] == e: c = e chars.append(c) i+=len(c) return chars def extract_last_word(string, from_index): i = from_index-1 word = "" while i >= 0: #print((i, word, remove_emoji(word), is_blank_string(remove_emoji(word)))) if string[i] == " " and not is_blank_string(remove_emoji(word)):
def __init__(self, client): self._client = client self.db = Database() self.error = discord.Colour.red() # Цвет embed ошибки
import requests from datetime import date, datetime from db import Database db = Database('my_db.db') #настройка сервера и даты server = 'http://10.53.20.15:8042' today_raw = date.today() #today = today_raw.strftime("%Y%m%d") today = "20210226" def reverse_date(date): ''' получает строку в формате год месяц день, возвращает строку в формате день месяц год ''' if len(date) > 8: dateofbirth_raw = datetime.strptime(date, "%Y%m%d%H%M%S") return dateofbirth_raw.strftime('%d.%m.%Y %H:%M') else: dateofbirth_raw = datetime.strptime(date, "%Y%m%d") return dateofbirth_raw.strftime('%d.%m.%Y') def orthanc_connect(server, today): data = '{ "Level" : "Instance", "Query" : { "StudyDate" : "' + today + '" } }' r = requests.post(server + '/tools/find', auth=('orthanc', 'orthanc'),
def get_all(): db = Database() resp = db.dump() db.close() return jsonify(resp)
def __init__(self): self.db = Database(TEST_DB) self.session = sessionmaker(bind=self.db.engine) self.base = base
def get_id(id): db = Database() resp = db.get_by_field(field="id", param=id)[0] if id == 'does not exist': return jsonify(resp), 404 return jsonify(resp)
from coin import Coin from db import Database from user import User app = Flask(__name__) #Configure session, SECRET_KEY secure cookies by cipher them app.config['SESSION_TYPE'] = 'mongodb' app.config['SECRET_KEY'] = os.urandom(15) #Load flask login Class login_manager = LoginManager() #load app inside flask login login_manager.init_app(app) mongo = Database() selected_crypto = Coin() base_crypto = [[{ 'name': 'Bitcoin', 'trigramme': 'BTC' }], [{ 'name': 'Ethereum', 'trigramme': 'ETH' }], [{ 'name': 'Litecoin', 'trigramme': 'LTC' }], [{ 'name': 'Ripple', 'trigramme': 'XRP' }], [{ 'name': 'EOS',
def run(self): if keyboard.key_pressed("esc"): globals.PLAY_INIT = True globals.GAME_STATE = 0 self.window.delay(150) if keyboard.key_pressed("d") and keyboard.key_pressed("b"): self.alien.aliens = [] self.window.delay(150) if len(self.alien.aliens) <= 0: self.time = 0 self.level += 1 self.bullet.__init__(self.window) if self.level == 2: self.alien.__init__(self.window, (5, 3), self.bullet, self.multiplier) elif self.level == 3: self.alien.__init__(self.window, (6, 4), self.bullet, self.multiplier) self.multiplier += 0.5 elif self.level == 4: self.alien.__init__(self.window, (8, 5), self.bullet, self.multiplier) elif self.level == 5: self.alien.__init__(self.window, (9, 5), self.bullet, self.multiplier) self.multiplier += 0.5 elif self.level == 6: self.alien.__init__(self.window, (11, 5), self.bullet, self.multiplier) elif self.level == 7: self.alien.__init__(self.window, (13, 6), self.bullet, self.multiplier) self.multiplier += 0.5 elif 15 > self.level > 7: self.alien.__init__(self.window, (15, 6), self.bullet, self.multiplier) self.multiplier += 0.1 else: self.alien.__init__(self.window, (15, 6), self.bullet, self.multiplier) self.update_difficulty() self.spaceship.__init__(self.window, self.bullet, self.alien, self.multiplier) if self.alien.alien_killed == True: self.score += self.get_score(self.time) * self.multiplier self.alien.alien_killed = False if self.spaceship.player_was_shot == True: self.spaceship.__init__(self.window, self.bullet, self.alien, self.multiplier) self.lives -= 1 if self.lives < 0: self.window.draw_text_font("GAME OVER!", "./assets/fonts/pixelmix.ttf", 300, globals.HEIGHT / 3, font_size=36) self.window.update() print("\nGame over!") name = input("What's your name? ") while len(name) > 9 or len(name) < 3: print("Please, enter a name within 3 and 9 characters.\n") name = input("What's your name? ") Database().save_score(name, self.score) globals.GAME_STATE = 0 globals.PLAY_INIT = True self.window.draw_text_font( "SCORE: {0:.2f}".format(self.score), "./assets/fonts/pixelmix.ttf", globals.SCREEN_BORDER, self.window.height - globals.SCREEN_BORDER, ) self.window.draw_text_font( "DIFFICULTY: {}".format(self.difficulty), "./assets/fonts/pixelmix.ttf", globals.SCREEN_BORDER + 200, self.window.height - globals.SCREEN_BORDER, ) self.window.draw_text_font( "LIVES: {}".format(self.lives), "./assets/fonts/pixelmix.ttf", globals.SCREEN_BORDER + 700, self.window.height - globals.SCREEN_BORDER, ) self.window.draw_text_font( "LEVEL: {}".format(self.level), "./assets/fonts/pixelmix.ttf", globals.SCREEN_BORDER + 900, self.window.height - globals.SCREEN_BORDER, ) self.spaceship.update() self.bullet.update() self.alien.update() self.time += self.window.delta_time()
from db import Database from query import Query from random import choice, randint, sample, seed db = Database() db.open('~/ECS165') # Student Id and 4 grades grades_table = db.create_table('Grades', 5, 0) query = Query(grades_table) records = {} seed(3562901) for i in range(0, 1000): key = 92106429 + i records[key] = [ key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20) ] query.insert(*records[key]) keys = sorted(list(records.keys())) print("Insert finished") grades_table.create_index(1) grades_table.create_index(2) grades_table.create_index(3) grades_table.create_index(4)
def service_inputs(): cmd = raw_input("> ").strip() import interpretor import optimizer import ops import db import parse_expr import parse_sql from interpretor import PullBasedInterpretor, PushBasedInterpretor from optimizer import Optimizer from ops import Print from db import Database from parse_expr import parse as _parse_expr from parse_sql import parse as _parse_sql _db = Database() if cmd == "q": return elif cmd == "": pass elif cmd.startswith("help"): print(HELPTEXT) elif cmd.lower() == "reload": reload(parse_expr) reload(db) reload(ops) reload(parse_sql) reload(optimizer) reload(interpretor) from parse_expr import parse as _parse_expr from db import Database from ops import Print from parse_sql import parse as _parse_sql from optimizer import Optimizer from interpretor import PullBasedInterpretor, PushBasedInterpretor elif cmd.upper().startswith("TRACE"): traceback.print_exc() elif cmd.upper().startswith("PARSE"): q = cmd[len("PARSE"):] ast = None try: ast = _parse_expr(q) except Exception as err_expr: try: ast = _parse_sql(q) except Exception as err: print("ERROR:", err) if ast: print(ast) elif cmd.upper().startswith("SHOW TABLES"): for tablename in _db.tablenames: print tablename elif cmd.upper().startswith("SHOW "): tname = cmd[len("SHOW "):].strip() if tname in _db: print "Schema for %s" % tname t = _db[tname] for field in t.fields: if t.rows: typ = type(t.rows[0][field]) else: typ = "?" print field, "\t", typ else: print "%s not in database" % tname else: try: plan = _parse_sql(cmd) opt = Optimizer(_db) interp = PullBasedInterpretor(_db) #interp = PushBasedInterpretor(_db) plan = opt(plan) print(plan) for row in interp(plan): print row except Exception as err: print("ERROR:", err) del _db service_inputs()