def createDatabase(self, nameDB): try: if self.buscarDB(nameDB) != None: print("Base de datos existente") return 2 else: self.databases.append(Database(nameDB)) # print("Operación exitosa") return 0 except: print("Error en la operación") return 1
def createDatabase(nameDB): try: if buscarDB(nameDB) != None: # print("Base de datos existente") return 2 else: if nameDB.isdigit(): return 1 databases.append(Database(nameDB)) return 0 except: # print("Error en la operación") return 1
def check_today_lessons_update(): # Проверка на обновления расписания за день db_in_thread = Database('AGPU_Schedule_Bot_DB.db') while True: while ((datetime.now().hour >= 7) and (datetime.now().minute >= 30)) and (datetime.now().hour < 14): chats = db_in_thread.get_send_updates_all() for chat in chats: currentday = chat[3] if currentday != parser.today(group_link=chat[1]): currentday = parser.today(group_link=chat[1]) send_msg_by_peer_id("Расписание изменилась \n \n" + currentday, chat[0]) db_in_thread.set_last_lessons_by_peer_id(chat[0], currentday) time.sleep(1000) time_const= "7:30:00" FMT = "%H:%M:%S" delta_morning=datetime.strptime(time_const,FMT)- datetime.now() if delta_morning.days<0: delta_morning = timedelta(days=0,seconds=delta_morning.seconds) time.sleep(int(delta_morning.total_seconds())+60)
clist = [] with open(filename, "r") as fp: lines = fp.readlines()[5:] for line in lines: #Regular expression to read HTML table data. data = re.findall(r'(?i)<td.*?>([^<]+)</td.*?>', line) clist.append(data) return clist if __name__ == "__main__": at = AnnualTemperature() data = at.openfile('lab1\Temperature.html') dt = Database() dt.createTable() for items in data: if len(items) > 0 and int(items[0]) > 1959 and int(items[0]) < 2019): print(items) # dt.create(items[0],items[2]) graph = Graph() data = dt.get_all() x = [] y = [] for row in data: x.append(row[0]) y.append(row[1])
import AGPU_Schedule_Parser as parser import requests import urllib3 import vk_api from DataBase import Database from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType # Импорт API ключа(токена) # API_KEY = os.environ.get("API_KEY") API_KEY = "6d3e7800807862b42f09c5b0adeb32c71d8646aef4e70ec1db414dba89d328d2e48e49486f2fdae46333d" print("Бот работает...") group_id = '197937466' # Указываем id сообщества, изменять только здесь! error = 0 # обнуление счетчика ошибок threads = [] db = Database('AGPU_Schedule_Bot_DB.db') Start_thread = True q = True def main(): global error # Счетчик ошибок try: vk_session = vk_api.VkApi(token=API_KEY) # Авторизация под именем сообщества longpoll = VkBotLongPoll(vk_session, group_id) vk = vk_session.get_api() def send_msg(ms_g): vk.messages.send(peer_id=event.object.peer_id, random_id=0, message=ms_g) def send_msg_by_peer_id(ms_g, peer_id):
from tkinter import * from DataBase import Database from tkinter.font import Font import tkinter.messagebox import subprocess import os import pyttsx3 from PIL import Image, ImageTk db = Database() class Show_word(Frame): def __init__(self, master): super(Show_word, self).__init__(master) self.grid() ChangeFont = Font(size=10) self.master.geometry("630x450") self.master.title("Show a word") self.labeloption = Label(self, text="Choose your option:") self.labeloption.grid(row=0, column=0) self.unit = StringVar() self.unit.set("random") self.unit0 = Radiobutton(self, text="Random", variable=self.unit, value="random", command=self.ActivateRandom)
def __init__(self): self.Backend = Backend() self.database = Database() self.sorted_data = {}
def get_data(self): database = Database() data = database.get_all() for key, value in data: self.sorted_data[key] = value return self.sorted_data
country = [] explode = (0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0) for cntry, pnt in data.items(): if count < 10 and cntry != "European Union": percentage.append(pnt) country.append(cntry) count += 1 plt.pie( percentage, labels=country, wedgeprops={'edgecolor': 'white'}, # autopct=lambda percentage: f'{percentage:.2f}%', autopct='%1.1f%%', shadow=True, explode=explode ) plt.title("Top 10 Country by C02 Emission In 2017") plt.axis('equal') plt.show() if __name__ == '__main__': graph = PieChart() graph.send_data() database = Database() data = graph.get_data() final_sort = dict(sorted(data.items(), key=lambda item: item[1], reverse=True)) graph.pie_chart(final_sort) database.delete_all_rows()