def test_is_running_in_cloud(monkeypatch): from app import Main monkeypatch.setenv("LIGHTNING_CLOUD_APP_ID", "anything") app = Main() assert app.running_in_cloud monkeypatch.delenv("LIGHTNING_CLOUD_APP_ID", raising=False) app = Main() assert not app.running_in_cloud
def start(): path_env = sep.join([getcwd(), 'app', 'config', '.env']) load_dotenv(path_env) params = { 'port': int(getenv('PORT', 5000)), } Main().run(**params)
def solve_functions(dp): global function_object, data_function data_function = dp _, function_object = Main.find_function_by_id(int(data_function['problem'])) function_object.set_n_dimension(int(data_function['dimension'])) isHybrid = data_function['isHybrid'] j = json.loads(open(os.path.dirname(__file__) + "/../JSON/functions-methods.json", 'r').read()) callable_method = j[data_function['firstMethod']['name-method']]['callable-method'] initial_time = time.time() result_first = globals()[callable_method](data_function['firstMethod'], None) result_first_done = {'decimal-best': {}, 'value-best': str(result_first[3]), 'time': str(time.time() - initial_time)} PLOTS = PLots() pl_3d, pl_contour = PLOTS.plot_function3d(function_object) j = 1 for i in result_first[2]: result_first_done['decimal-best'][j] = str(i) j += 1 if not isHybrid: err1 = PLOTS.plot_err(result_first[1]) return { 'problem':function_object.name, 'problem-description':str(function_object), 'isHybrid':isHybrid, 'result-first':result_first_done, '3d':pl_3d, 'contour':pl_contour, 'err1':err1 } initial_time = time.time() result_second = globals()[callable_method](data_function['firstMethod'], result_first[0]) result_second_done = {'decimal-best': {}, 'value-best': str(result_second[3]), 'time': str(time.time() - initial_time)} j = 1 for i in result_second[2]: result_second_done['decimal-best'][j] = str(i) j += 1 err1, err2, err3 = PLOTS.plot_err(result_first[1], result_second[1]) return { 'problem':function_object.name, 'problem-description':str(function_object), 'isHybrid':isHybrid, 'result-first':result_first_done, 'result-second':result_second_done, '3d': pl_3d, 'contour': pl_contour, 'err1':err1, 'err2':err2, 'err3':err3, 'hibridization-analysis':str('The FIRST hit the value SOMEVALUE in TIME seconds.\nStarting on the best found value, the SECOND *CONDITION got a improve DIFFERENCE in the solution, in TIME seconds. Hybridization reached a value of FINAL-VALUE in a total of FINAL-TIME seconds, considered a effective result, because one method support the other.') }
async def sync(values, cash_monitor): global translate loop = asyncio.get_event_loop() the_choice = await loop.run_in_executor(None, input, 'Пополнить или снять деньги? yes/no\n') if the_choice.upper() == 'YES': list_values = ['RUB'] + values a = '\n'.join(list_values) the_choice = await loop.run_in_executor(None, input, f'Какую валюту хотите выбрать?\n{a}\n') for value in list_values: cash_monitor[value] = 0 if the_choice.upper() == value: theChoice = await loop.run_in_executor(None, input, 'Какую операцию хотите провести?\nПополнить, ' 'снять, перевести или поменять валюту\n') translate = Main.translate(Main, theChoice.lower()) loop.close() task = asyncio.create_task(treatmentt(translate)) await task else: pass
def simule_functions(dp, repetitions): global function_object, data_function data_function = dp _, function_object = Main.find_function_by_id(int(data_function['problem'])) function_object.set_n_dimension(int(data_function['dimension'])) isHybrid = data_function['isHybrid'] j = json.loads(open(os.path.dirname(__file__) + "/../JSON/functions-methods.json", 'r').read()) callable_method = j[data_function['firstMethod']['name-method']]['callable-method'] vec_times = [] vec_costs = [] for i in range(repetitions): initial_time = time.time() result_first = globals()[callable_method](data_function['firstMethod'], None) if isHybrid: result_second = globals()[callable_method](data_function['secondMethod'], result_first[0]) vec_costs.append(result_second[3]) else: vec_costs.append(result_first[3]) vec_times.append(time.time() - initial_time) PLOTS = PLots() pl_3d, pl_contour = PLOTS.plot_function3d(function_object) box_times, box_costs, scatter = PLOTS.plot_simulation(vec_times, vec_costs) return { 'problem':function_object.name, 'problem-description':str(function_object), 'isHybrid':isHybrid, 'times':vec_times, 'costs':vec_costs, '3d':pl_3d, 'contour':pl_contour, 'box_times':box_times, 'box_costs':box_costs, 'scatter':scatter }
def __init__(self, values, cash_monitor): self.cash = {} self.currency = Main.__init__(Main, values)
await task else: pass async def treatmentt(translate): if True: print(123) async def main(values, N, cash_monitor): while True: wallet.__init__(wallet, values, cash_monitor) await asyncio.sleep(N) if __name__ == '__main__': Main.__init__(Main, 'USD') i = 0 values = [] cash_monitor = {} while i == 0: Bool = (input('Добавить валюту? y/f\n')).upper() if Bool == 'Y': valute = ((input('Какую валюту?\nExample: usd\n')).upper()) if valute in Main.valute: values.append(valute) else: print('Неправильно название!') elif Bool == 'F': i = i + 1 while i == 1: N = input('Частота обновления курса (period)\n')
def __init_app(parameters: Parameters) -> None: Main(parameters).start()
def on_starting(server): main = Main() main.runServer()
from app import Main, Music, SongList, Queues from dataQueries import ManageDB, ManagePostgreDB from aiohttp import web import json # import logging # logger = logging.getLogger('discord') # logger.setLevel(logging.DEBUG) # handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w') # handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) # logger.addHandler(handler) intents = discord.Intents.all() bot = Main("/", settings.TOKEN, intents) bot.insert_cogs(Music(bot)) bot.insert_cogs(SongList(bot)) bot.insert_cogs(Queues(bot)) class VkBot(commands.Cog): def __init__(self, bot): self.bot = bot self.ctx = None if settings.DATABASE_TYPE: self.database = ManagePostgreDB() else: self.database = ManageDB() self.music = Music(bot) self.music2 = Music(self.bot)
from app import Main main = Main() main.start() main.exit()
from app import Main if __name__ == "__main__": Main()
""" Функция создает главное окно программы, задает размер, цвет фона Получает: - Возвращает: - Автор: Демидов И.Д., Матвеев В.Е., Будин А.М. """ import tkinter as tk import os, sys sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from app import Main if __name__ == "__main__": ROOT = tk.Tk() ROOT["bg"] = "#B0C7E4" ROOT.state("zoomed") ROOT.title("База данных смартфонов") W, H = ROOT.winfo_screenwidth() - 100, ROOT.winfo_screenheight() - 100 ROOT.geometry("%dx%d+0+0" % (W, H)) ROOT.resizable(True, True) Main(ROOT) ROOT.mainloop()