async def process_callback_button1(callback_query: types.CallbackQuery): if Services.GetUserPersonage(callback_query.from_user.id) == "NotRegistered": await NotRegistered(callback_query.from_user.id) return 0 await callback_query.message.edit_text(Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id)), reply_markup=menuKb)
def main(): ################################################################################# # Perform tests ################################################################################# # Check if test mode enabled if not 'ATTENDANCE_TRACKER_TEST' in ENV or \ not int(ENV['ATTENDANCE_TRACKER_TEST']) == 1: print "Attendance Tracker Test Mode DISABLED" else: print "Attendance Tracker Test Mode ENABLED" # run all lib tests print("MAIN: Started up! Running tests.") # TODOB: run tests here # TODOB: check if each test passed and proceed if so ################################################################################# # Perform initializations ################################################################################# LEDQueue = PriorityQueue() # thread-safe queue PiezoQueue = PriorityQueue() # thread-safe queue MembersQueue = PriorityQueue() # thread-safe queue services = [ Services.LEDIndicatorService(LEDQueue), Services.PiezoService(PiezoQueue), Services.LabStatusService( 'xoxp-6044688833-126852609376-152389424672-d7934b0e899443e22b0d23051863c5cf', 'C0Q6A61K7', MembersQueue) ] # services = [Services.AsyncPeriodicSyncWithDropbox(20,["time_in_entries.csv", "time_out_entries.csv", "time_entries.csv"])] eventListeners = [ EventListener.TimerEventListener(5.0), EventListeners.CardReadEventListener("MY_CARD_READER"), EventListeners.ShutdownEventListener() ] stateHandlers = [ StateHandlers.InitStateHandler, StateHandlers.TempStateHandler ] enabledLibs = [LocalStorage(LEDQueue)] # common params are passed to every state handler commonArgs = { "LEDQueue": LEDQueue, "PiezoQueue": PiezoQueue, "MembersQueue": MembersQueue } # enabledLibs = [ LocalStorage(ENV["AT_LOCAL_STORAGE_PATH"]), # DropboxStorage(ENV["AT_DROPBOX_AUTH_TOKEN"], ENV["AT_LOCAL_STORAGE_PATH"])] ################################################################################# # Begin the main FSM runloop ################################################################################# pyfsm = Pyfsm(services, eventListeners, stateHandlers, enabledLibs, commonArgs) error_message = pyfsm.start() # error'd out..print the message print("ERROR: " + error_message)
async def process_start_command(message: types.Message): Msg = await bot.send_message(message.chat.id,"Начинаю регистрацию...") await bot.send_chat_action(message.chat.id, types.ChatActions.TYPING) Services.RegisterNewUser(message.from_user.id, message.from_user.username, message.from_user.first_name, message.from_user.last_name) await Msg.edit_text('Зарегестрирован!') await asyncio.sleep(3) JsonR = Services.GetUserPersonage(message.chat.id) await bot.send_message(message.chat.id, Services.FormatUserToBeautifullMsg(JsonR), reply_markup=menuKb)
def get(self, threshold): scanner = Services.DirectoryScanner(config.DIRECTORIES_TO_SCAN) interesting_service = Services.InterestingService(config.DEFAULT_INTERESTING_WEIGHT) document_parser = Services.DocumentParser() repo = Repositories.TxtRepository() counting_service = Services.WordCountingService(document_parser, interesting_service, threshold) for file in scanner.scan_files(): for line in repo.read_file(file): for sentence in document_parser.split_to_sentences(line): counting_service.populate(sentence, file) return counting_service.get_word_count()
def service(self,setup,unsetup,layout): Services.check() #Service check if len(Services.service) != 0: setup() Services.service[0]() Services.service.remove(Services.service[0]) unsetup() layout() global prev if prev < len(Services.notif): gpio.output(17,1) time.sleep(1) gpio.output(17,0) prev = len(Services.notif)
def link(self, key, proxy, current=None): if key in self.proxies: raise Services.AlreadyExists(key) self.proxies[key] = proxy print("{} ha sido agregado".format(key))
def Meteo(conf, TextPAPIRUS, Units): #Fonction Météo (OpenWeatherMap) SV.SVMeteo(conf) TextPAPIRUS.AddText("Météo:", 10, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Température: " + str(SV.DataMeteo["main"]["temp"]) + "°C", 10, 40, size=25, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Temp. Min: " + str(SV.DataMeteo["main"]["temp_min"]) + "°C" + " Temp. Max: " + str(SV.DataMeteo["main"]["temp_max"]) + Units, 10, 65, size=12, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Temps: " + SV.DataMeteo["weather"][0]["description"].capitalize(), 10, 85, size=25, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()), 200, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.WriteAll(True) time.sleep(10) TextPAPIRUS.Clear()
def unlink(self, key, current=None): if not key in self.proxies: raise Services.NoSuchKey(key) del self.proxies[key] print("{} ha sido eliminado".format(key))
def Twitter(conf, TextPAPIRUS, BearerAUTH): #Fonction Twitter SV.SVTwitter(conf, BearerAUTH) TextPAPIRUS.AddText("Twitter:", 10, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Compte: " + SV.DataTwitter["name"], 10, 40, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(str(SV.DataTwitter["followers_count"]) + " abonnés", 10, 65, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Dernier tweet:", 10, 85, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(SV.DataTwitter["status"]["text"], 10, 105, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()), 200, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.WriteAll(True) time.sleep(10) TextPAPIRUS.Clear()
def initial_config(self): """ update the variables after initial questions :return: bool """ success = [] # workgroup workgroup = Questions.Workgroup() success.append(workgroup.name()) self.workgroup_name = workgroup.workgroup_name # voice recording voice_recording = Questions.VoiceRecording() success.append(voice_recording.voice_recording()) self.using_voice_recording = voice_recording.using_voice_recording # VNC vnc = Questions.Vnc() success.append(vnc.vnc_password()) self.vnc_password = vnc.password # CTI cti = Questions.Cti() success.append(cti.cti_server()) self.cti_server = cti.server # services services = Services.Services() self.service_list = services.running_services(self.machine_name) return success
def login(username=None, password=None): printLog('info', username+" "+password) try: if service.validateUser(username=username, password=password): printLog('info', "user validated") return render_template('home.html') except Exception as e: printLog('error', e)
def main(): #main module r = UI.repoUI() op = r.option() if op == 1: s = Services.Service(Student_Inventory(students), Assignment_Inventory(assignments), Grade_Inventory(grades)) elif op == 2: s = Services.Service(Student_Inventory_Txt(), Assignment_Inventory_Txt(), Grade_Inventory_Txt()) elif op == 3: s = Services.Service(Student_Inventory_Pickle(students), Assignment_Inventory_Pickle(assignments), Grade_Inventory_Pickle(grades)) u = UI.UI(s) u.menu()
def update_strength(total_strength, route): extra_strength = round(total_strength / len(route)) i = 0 for i in range(len(route) - 1): direction = Services.step_direction(route[i], route[i + 1]) strength[route[i][0]][route[i][1]][route[i][2]][direction[0]][direction[1]] += extra_strength if not only_show_round_statistics: print("----Strength updated: +" + str(extra_strength) + " to path----")
def RATP(conf, TextPAPIRUS): SV.SVRATP(conf) TextPAPIRUS.AddText("RATP:", 10, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Station: " + conf["RATP"]["stationA"] + " - " + conf["RATP"]["lineA"], 10, 40, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Prochain: " + SV.OutputA["result"]["schedules"][0]["message"], 10, 55, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Direction: " + SV.OutputA["result"]["schedules"][0]["destination"], 10, 70, size=15, fontPath="Ubuntu.ttf") if conf["RATP"]["typetransB"] != "" and conf["RATP"][ "lineB"] != "" and conf["RATP"]["stationB"] != "": TextPAPIRUS.AddText("Station: " + conf["RATP"]["stationB"] + " - " + conf["RATP"]["lineB"], 10, 115, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("Prochain: " + SV.OutputB["result"]["schedules"][0]["message"], 10, 130, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText( "Direction: " + SV.OutputB["result"]["schedules"][0]["destination"], 10, 145, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()), 200, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.WriteAll(True) time.sleep(10) TextPAPIRUS.Clear()
async def process_callback_button1(callback_query: types.CallbackQuery): if Services.GetUserPersonage(callback_query.from_user.id) == "NotRegistered": await NotRegistered(callback_query.from_user.id) return 0 executeResult = await Services.ExecuteEatActivity(eatId=callback_query.data.replace('eat_',''), userId=callback_query.from_user.id) if executeResult == 'NotHaveMoney': await bot.answer_callback_query(callback_query.id, text="Тебе не хватает денег на это))", show_alert=True) elif executeResult == 'Eat_die': await bot.answer_callback_query(callback_query.id, text="Ты помер с голоду)))", show_alert=True) await Вeath(callback_query.from_user.id) elif executeResult == 'Health_die': await bot.answer_callback_query(callback_query.id, text="Ты помер)))", show_alert=True) await Вeath(callback_query.from_user.id) elif executeResult == 'Happy_die': await bot.answer_callback_query(callback_query.id, text="Ты повесился))))", show_alert=True) await Вeath(callback_query.from_user.id) else: await callback_query.message.edit_text(Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id)), reply_markup=CreateEatMurkup())
def CreateHealthMurkup(): HappyJson = Services.GetHealth() resultJson = {"inline_keyboard": []} healthbtnsList=[] for eat_activity in HappyJson['health']: healthbtnsList.append({"text": f"{eat_activity['name']}\n{str(eat_activity['price'])}₽", "callback_data": f"{'health_'+str(eat_activity['id'])}"}) resultJson['inline_keyboard'] = (lol(healthbtnsList, 2)) resultJson['inline_keyboard'].append([{"text":"Назад","callback_data":"Menu"}]) return resultJson
def CreateEatMurkup(): EatJson = Services.GetEat() resultJson = {"inline_keyboard": []} eatbtnsList=[] for eat_activity in EatJson['eat']: eatbtnsList.append({"text": f"{eat_activity['name']}\n{str(eat_activity['price'])}₽", "callback_data": f"{'eat_'+str(eat_activity['id'])}"}) resultJson['inline_keyboard'] = (lol(eatbtnsList, 2)) resultJson['inline_keyboard'].append([{"text":"Назад","callback_data":"Menu"}]) return resultJson
def Crypto(conf, TextPAPIRUS): #Fonction Crypto (CryproCompare) SV.SVCrypto(conf) PCTC1 = list( str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin1"]][ conf["CRYPTO"]["Currency"]]["CHANGEPCT24HOUR"])) del PCTC1[-14:-1] PCTC2 = list( str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin2"]][ conf["CRYPTO"]["Currency"]]["CHANGEPCT24HOUR"])) del PCTC2[-14:-1] TextPAPIRUS.AddText("Crypto:", 10, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(conf["CRYPTO"]["Coin1"] + ": " + conf["CRYPTO"]["Currency"] + " " + str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin1"]][ conf["CRYPTO"]["Currency"]]["PRICE"]), 10, 44, size=25, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(conf["CRYPTO"]["Coin2"] + ": " + conf["CRYPTO"]["Currency"] + " " + str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin2"]][ conf["CRYPTO"]["Currency"]]["PRICE"]), 10, 114, size=25, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("".join(PCTC1) + "%", 10, 74, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText("".join(PCTC2) + "%", 10, 144, size=15, fontPath="Ubuntu.ttf") TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()), 200, 10, size=20, fontPath="Ubuntu.ttf") TextPAPIRUS.WriteAll(True) time.sleep(10) TextPAPIRUS.Clear()
def main(): scanner = Services.DirectoryScanner(config.DIRECTORIES_TO_SCAN, Services.CompanyRegistry()) repo = Repositories.CsvRepository() file_validator = Services.FileValidator() new_files = [] for new_file in scanner.scan_new_files(): file, company = new_file metadata = repo.get_metadata(file) headers = repo.get_headers(file) statement_type = file_validator.get_statement_type(metadata) is_file_structure_valid = file_validator.is_file_structure_valid(headers) is_file_in_good_dir = file_validator.is_file_in_good_dir(statement_type[0], file) new_files.append(Entities.ScannedFileResult(file, statement_type, company, is_file_in_good_dir, is_file_structure_valid)) print(f'new files of unseen companies: {len(new_files)}') for new_file in new_files: print(f'\n' f'company: {new_file.company}\n' f'file path: {new_file.path}\n' f'statement type: {new_file.statement_type[1]}\n' f'is file in good dir: {new_file.is_file_in_good_dir}\n' f'is file valid: {new_file.is_valid}')
def start_services(self, service_name): """ start the named service :param service_name: string :return: bool """ from Services import Services result = Services.start_service(service_name, self.machine_name) if result is None: return None elif result: return True else: return False
async def process_callback_button1(callback_query: types.CallbackQuery): if Services.GetUserPersonage(callback_query.from_user.id) == "NotRegistered": await NotRegistered(callback_query.from_user.id) return 0 if callback_query.data == 'btnM_Profile': await callback_query.message.edit_text( Services.FormatUserProfileToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id))) elif callback_query.data == 'btnM_Eat': resultJson = CreateEatMurkup() await callback_query.message.edit_text(Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id)), reply_markup=resultJson) elif callback_query.data == 'btnM_Happy': await callback_query.message.edit_text(Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id)), reply_markup=CreateHappyMurkup()) elif callback_query.data == 'btnM_Health': resultJson = CreateHealthMurkup() await callback_query.message.edit_text(Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(callback_query.from_user.id)), reply_markup=resultJson)
def unlink(self, key, current=None): if not key in self.proxies: raise Services.NoSuchKey(key) print("unlink: {0}".format(self.type, key)) del self.proxies[key]
def link(self, key, proxy, current=None): if key in self.proxies: raise Services.AlreadyExists(key) print("link: {0} -> {1}".format(key, proxy)) self.proxies[key] = proxy
from datetime import * from Services import * schedule = [{ "end_time": "05/06/2017 20:00", "guest_id": "0", "guest_name": "a", "start_time": "05/06/2017 19:00", "time_of_reserving": "04/26/2017 13:27" }, { "end_time": "05/06/2017 17:00", "guest_id": "0", "guest_name": "a", "start_time": "05/06/2017 16:00", "time_of_reserving": "04/26/2017 13:28" }] service = Services('massage_shiatsu', 4, 3.0, [30, 60], schedule) def test_check_schecule(): assert service.check_service_schedule(datetime(2017, 5, 6, 17), datetime(2017, 5, 6, 18)) == True assert service.check_service_schedule(datetime(2017, 5, 6, 16), datetime(2017, 5, 6, 17)) == True assert service.check_service_schedule(datetime(2017, 5, 6, 19), datetime(2017, 5, 6, 20)) == True
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 12 16:50:40 2019 @author: learner """ import Services as services import Messaging as messaging import time print("STARTING DEEP LEARNING APPLICATION") learningService = services.LearningService() predictionService = services.PredictionService(learningService) messenger = messaging.Messenger(learningService, predictionService) print("DEEP LEARNING APPLICATION INITIALIZED") while messenger.isRunning(): time.sleep(1) print("CLOSING MESSENGER") messenger.close() print("FINISHED")
def unlink(self, key, current=None): if not key in self.proxies: raise Services.NoSuchKey(key) del self.proxies[key]
import sys sys.path.append("/home/leonardo/Leonardo/GIT/Flyer/Flyer/jogo") from pgzero.actor import Actor import pygame import Services WIDTH = 905 HEIGHT = 450 play = False botaoPlay = Actor("botao_play", pos=(WIDTH / 2, HEIGHT / 2)) services = Services.Services() points = 0 highpoints = 0 actualPoints = 0 savedPoints = False world = None paused = False def draw(): global play, points, world, highpoints, actualPoints, savedPoints if pygame.mouse.get_pressed()[0] == 1: # LEFT BUTTON CLICKED if pygame.mouse.get_pos( )[0] >= botaoPlay.left and pygame.mouse.get_pos( )[0] <= botaoPlay.right: if pygame.mouse.get_pos( )[1] >= botaoPlay.top and pygame.mouse.get_pos( )[1] <= botaoPlay.bottom:
async def echo_message(msg: types.Message): if Services.GetUserPersonage(msg.from_user.id) == "NotRegistered": await NotRegistered(msg.from_user.id) return 0 await bot.send_message(msg.chat.id, Services.FormatUserToBeautifullMsg(Services.GetUserPersonage(msg.chat.id)), reply_markup=menuKb)
canGo[route[-1 * reactivate_after][0]][route[-1 * reactivate_after][1]][ route[-1 * reactivate_after][2]] = True route.append(new_Position) if debugging_view: test_print() else: new_Position = [] return new_Position # Initalisierung maze_id = Services.generate_id(version_for_file_format, "_", maxX, maxY, maxZ, starting_position, goal_position) print("Started " + str(rounds_to_run) + " rounds - Distance: " + str(distance) + " steps - ID: " + maze_id + "\n") strength = Setup_Maze.setupDefaultMazeS(maxX, maxY, maxZ, defaultValue=100) if save_open_s_matrix_to_file: strength = Services.open_s_matrix(maze_id, strength) for i in range(rounds_to_run): if not only_show_round_statistics: Services.round_header(i) round_init("Round initialization") canGo = Setup_Maze.setupDefaultMazeCG(maxX + 1, maxY + 1, maxZ + 1, defaultValue=True) # max +1 to give room for 3 boundary planes set to false set_borders()
facial_list = [['facial_normal', 'facial_collagen'], [3, 2.0, [30, 60]]] specialty_treatment_list = [[ 'specialty_treatment_hot_stone', 'specialty_treatment_sugar_scrub', 'specialty_treatment_herbal_body_wrap', 'specialty_treatment_botanical_mud_wrap' ], [2, 3.5, [60, 90]]] services_list = [ mineral_bath_list, massage_list, facial_list, specialty_treatment_list ] services = {} for service in services_list: for kind in service[0]: if not os.path.isfile('services_schedules/' + kind + '.txt'): services[kind] = Services(kind, service[1][0], service[1][1], service[1][2], []) json.dump(services[kind].schedule, open('services_schedules/' + kind + '.txt', 'w')) else: services[kind] = Services( kind, service[1][0], service[1][1], service[1][2], json.load(open('services_schedules/' + kind + '.txt', 'r'))) # rooms rooms = {} for i in range(36): if i < 16: size = 'single' elif 16 <= i < 32: size = 'double' else: size = 'quadruple'
rc = threadCreate(&t, (ThreadFunc) &threadfunc, NULL, 0x4000, 0x28, 1); if (rc) fatalSimple(rc); rc = threadStart(&t); if (rc) fatalSimple(rc); svcExitThread(); } void threadfunc(void) { Handle tmp_handle; Result rc; ''')) srv = Services.Services() code.append(srv) ### ipcDuplicateSession for i in range(64): idx, idx_obf = srv.get_index('pm:shell') code.append(idx_obf) code.append( ScrambledIpcCommand.IpcCommand(srv.get_handle(idx), 2, cmd_type=5, raw=[0], ignore_error=True)) srv = Services.Services() code.append(srv)
import datetime #Button Setup import RPi.GPIO as gpio button = 23 #GPIO pin for button gpio.setmode(gpio.BCM) gpio.setup(button,gpio.IN,pull_up_down=gpio.PUD_UP) #Buzzer Setup (disable I2C pins) gpio.setup(17,gpio.OUT) from PitftGraphicLib import * initdis() import App import Services Services.setup() prev = len(Services.notif) back = 0 page = 0 class Menu: def __init__(self): pass # Slot Configuration def slotconf(self,slot, app): def rm(): disinitdis() app[3]() Services.notif.remove(app) initdis() if slot == 1: