def start_gui(): if (flg_closePush == 1): start = time.time() #×ボタンが押された際の動作 eel.init("GUI/web") #eel.start("開きたい上記のフォルダ下のファイル名",~ eel.start( "html/index.html", port=0, mode='chrome', size=(400, 200), #サイズ指定(横, 縦) position=(width, height), #位置指定(left, top) block=False) eel.sleep(0.01) print("【通知】index.html再起動") #×ボタンのフラグの初期化 close_switch_py(0) return flg_end else: try: #正常動作 eel.sleep(0.01) #eel.set_posegauge(name_pose) except SystemExit: traceback.print_exc() print("【通知】SystemExit発生") finally: return flg_end
def on_websocket_close(page, sockets): global should_quit eel.sleep(3.0) # We might have just refreshed. Give the websocket a moment to reconnect. if not len(eel._websockets): # At this point we think the browser window has been closed. should_quit = True shut_down()
def callPort(pt, baud, timeout=1): try: if (ser.is_open): ser.close() ser.port = pt ser.baudrate = baud ser.timeout = timeout ser.open() while ser.is_open: try: dataPort = ser.readline() data['temp'] = float(dataPort) # data['temp'] = random.randint(0, 1000) dataPort = ser.readline() data['humid'] = float(dataPort) # data['humid'] = random.randint(1, 500) dataPort = ser.readline() data['pressure'] = float(dataPort) dataPort = ser.readline() data['intensity'] = float(dataPort) eel.valid() except ValueError: eel.invalid("<b>Data Invalid</b>: Wrong Port or Poor Signal") eel.sleep(0.1) except (serial.SerialException, ValueError): eel.invalid("Port is Invalid or already Opened <b>Port: </b>" + pt + "<b> Baudrate: </b>" + str(baud))
def main(): # Starts the main.html on server 127.0.0.1:8000 with the size of the window. eel.start('main.html', size=(768, 850), block=False) # Keeps the app running after start up. while True: eel.sleep(10)
def main(): global current_slide cap = cv.VideoCapture(0) # EeLフォルダ設定、および起動 ################################################## eel.init('webslides') eel.start( 'index.html', mode='chrome', cmdline_args=['--start-fullscreen'], block=False) eel.sleep(2.0) # モデルロード ################################################################ sess = graph_load('model/frozen_inference_graph.pb') eel.go_nextslide() while True: eel.sleep(0.01) # カメラキャプチャ ######################################################## ret, frame = cap.read() if not ret: continue # スライド頁に応じた処理 ################################################### draw_image = image_processing(current_slide, frame, sess) # UI側へ転送 ############################################################## _, imencode_image = cv.imencode('.jpg', draw_image) base64_image = base64.b64encode(imencode_image) eel.set_base64image("data:image/jpg;base64," + base64_image.decode("ascii"))
def loadData(): while True: disk = psutil.disk_usage('/') disk = (disk[1] / disk[0]) * 100 eel.loadDataGraphs(int(psutil.cpu_percent()), int(psutil.virtual_memory()[2]), int(disk)) eel.sleep(1)
def getFiles(ip): client = Client(ip, 5003) eel.sleep(.5) try: return client.getFileList() except: return []
def reminder(): remind = ToastNotifier() if "set reminder" in userinputglobal: remind_text = userinputglobal.replace('set reminder', "") elif "reminder" in userinputglobal: remind_text = userinputglobal.replace('reminder', "") elif "remind" in userinputglobal: remind_text = userinputglobal.replace("remind", "") timefactor = 0 for infactor in remind_text.split(): if infactor.isdigit(): timefactor = int(infactor) #print (timefactor) [For Devt Only] if timefactor == 0: eel.sleep(2) return "Please set a duration." remind_text = remind_text.replace(infactor, "") remind_text = remind_text.replace("after", "") eel.sleep(timefactor) retvalue = remind.show_toast("Reminder", remind_text, icon_path='fav.ico', duration=20) return remind_text return retvalue
def main(): # Starts the app. eel.start("main.html", size=(768, 713), block=False) # Keeps the app running. while True: eel.sleep(10)
def login_google(): global login_time, driver if driver is None: return driver.get(login_url) TIME_OUT = 5 eel.show_log('Apply Google ID') WebDriverWait(driver, TIME_OUT).until( EC.presence_of_element_located( (By.XPATH, '//*[@id="identifierId"]'))).send_keys(login_id + Keys.ENTER) eel.show_log('Apply Google Password') while True: try: WebDriverWait(driver, TIME_OUT).until( EC.presence_of_element_located( (By.XPATH, '//*[@id="password"]/div[1]/div/div[1]/input' ))).send_keys(login_pw + Keys.ENTER) break except Exception: continue eel.sleep(5) eel.show_log('Success Google Login<br>Wait Login at ' + login_time.strftime('%Y/%m/%d %H:%M'))
def main(): global current_slide cap = cv.VideoCapture(0) # EeLフォルダ設定、および起動 ######################################################### eel.init('webslides') eel.start('index.html', mode='chrome', cmdline_args=['--start-fullscreen'], block=False) while True: eel.sleep(0.01) # カメラキャプチャ ######################################################## ret, frame = cap.read() if not ret: continue print(current_slide) # UI側へ転送 ############################################################## _, imencode_image = cv.imencode('.jpg', frame) base64_image = base64.b64encode(imencode_image) eel.set_base64image("data:image/jpg;base64," + base64_image.decode("ascii")) key = cv.waitKey(1) if key == 27: # ESC break
def final_chaser_thread(): timedout = False i = 0 while game.state == GameState.FINAL_CHASER and not timedout and not game.current_round.chaserFinalWon and game.final_chaser_thread: if i % 10 == 0: seconds_played = game.current_round.timePassed.seconds timedout = seconds_played >= SECONDS_PER_FINALROUND seconds_remaining = SECONDS_PER_FINALROUND - seconds_played eel.all_final_tick(seconds_played, seconds_remaining) i += 1 eel.sleep(0.1) if not game.final_chaser_thread and game.state == GameState.FINAL_CHASER: eel.all_final_pause(seconds_played, seconds_remaining) game.state = GameState.FINAL_CHASER_WRONG elif game.current_round.chaserFinalWon: game.state = GameState.FINAL_END elif timedout: eel.all_final_timeout() game.current_round.won = True game.state = GameState.FINAL_END game.current_round.finalTime[-1]['end'] = datetime.datetime.now() resend_gamestate()
def main(): # Setup eel.init("web") # Functions @eel.expose def helloWorld(): print("Hello world!") @eel.expose def btPlay(): print("Play") @eel.expose def btPause(): print("Pause") # Start eel.start("index.html", mode="chrome", lock=False, size=(800, 480), port=2804) # Run Once # Main Loop while True: eel.sleep(2)
def FiveAccounts(): eel.sendLog('Ads will continue to be posted as long as window is open.\n') while True: #use first account RandomTitle() account_one.subreddit('discordservers').submit(title, url=invite) eel.sendLog("Posted to r/discordservers using: " + account_one_username + " with ad: " + title) eel.sleep(delay) #use second account RandomTitle() account_two.subreddit('discordservers').submit(title, url=invite) eel.sendLog("Posted to r/discordservers using: " + account_two_username + " with ad: " + title) eel.sleep(delay) #use third account RandomTitle() account_three.subreddit('discordservers').submit(title, url=invite) eel.sendLog("Posted to r/discordservers using: " + account_three_username + " with ad: " + title) eel.sleep(delay) #use fourth account RandomTitle() account_four.subreddit('discordservers').submit(title, url=invite) eel.sendLog("Posted to r/discordservers using: " + account_four_username + " with ad: " + title) eel.sleep(delay) #use fifth account RandomTitle() account_five.subreddit('discordservers').submit(title, url=invite) eel.sendLog("Posted to r/discordservers using: " + account_five_username + " with ad: " + title) eel.sleep(delay)
def auto_login(steamid, name, lock): eel.info("使用快取登入", "使用者名稱:" + name + "\nsteamid:" + steamid, "console") key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\Valve\Steam", 0, winreg.KEY_ALL_ACCESS) winreg.SetValueEx(key, "AutoLoginUser", 0, winreg.REG_SZ, name) winreg.SetValueEx(key, "RememberPassword", 0, winreg.REG_DWORD, 0x00000001) exe, t = winreg.QueryValueEx(key, "SteamExe") winreg.CloseKey(key) si = subprocess.STARTUPINFO() si.dwFlags |= subprocess.STARTF_USESHOWWINDOW eel.info("關閉Steam", "", "console") close_steam(exe, si) eel.info("啟動steam", "", "console") app = APP().start(exe) login_gui = app.window(title_re='Steam [^Guard].*', class_name='vguiPopupWindow') eel.info("等待 '主頁面'", "", "console") wait_time = app_setting("wait_steam_start") eel.info("容許等待時間" + wait_time, "", "console") eel.sleep(int(wait_time)) try: login_gui.wait_not("ready", wait_time) #等待介面 except: eel.info("注意!", "無法使用快取登入\n將使用模擬登入", "console") login(steamid, lock, app, True) else: del app lock.release() eel.info("登入成功", "", "console")
def start(): gui_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'gui') eel.init(gui_folder) # Ultra rare port, unlikely to conflict with other programs. # options = {'port': 51993} options = {'port': 51993} if not is_chrome_installed(): options = { 'mode': 'system-default' } # Use the system default browser if the user doesn't have chrome. # This disable_cache thing only works if you have tare's fork of eel # https://github.com/tarehart/Eel/commit/98395ccc268e1a7a5137da2515b472fcc03db5c5 # installed to pip locally using this technique https://stackoverflow.com/a/49684835 eel.start('main.html', size=(1000, 800), block=False, callback=on_websocket_close, options=options, disable_cache=True) while not should_quit: do_infinite_loop_content() eel.sleep(1.0)
def loop(): global cap, stream, current, capturing, capture_image, capture_number global cam_pos, movie_saving, movie_saving_count while True: frame = cap.read() if (stream == True): frame = cv2.flip(frame, 1) if (len(cam_pos) > 0): frame = frame[cam_pos[1]:cam_pos[1] + cam_pos[3], cam_pos[0]:cam_pos[0] + cam_pos[2]] if (capturing == True): capture_image[capture_number] = frame addCaptureNumber() capturing = False #print("move_saving:::",movie_saving) #print("movie_saving_count:::",movie_saving_count) if (movie_saving == True): if (movie_saving_count % int(current["movie_fps"]) == 0): capture_movie[capture_number].append(frame) movie_saving_count += 1 ret, jpeg = cv2.imencode('.jpg', frame) jpeg_b64 = base64.b64encode(jpeg.tobytes()) jpeg_str = jpeg_b64.decode() eel.js_imshow(jpeg_str) eel.sleep(0.03)
def track_copy_progress(copyop): # Start with the original file structure, in case it has already updated by the time this thread executes o = copyop.original while (any([f['done'] == False for f in o])): try: n = copyop.read() d = [{ 'id': b['id'], 'dest': b['dest'], 'renamed': b['renamed'] } for a, b in zip(o, n) if a['dest'] != b['dest']] p = [{ 'id': b['id'], 'progress': file_progress(b) } for b in n if b['done'] == False] f = [b for a, b in zip(o, n) if a['done'] != b['done']] #send updates to javascript/GUI eel.update_progress({ 'destinations': d, 'progress': p, 'finalized': f }) #copy new values to old to track what needs updating still o = n except Exception as e: print('Exception in track_copy_progress:', e) #rate limit this progress reporting eel.sleep(0.03) # ii+=1 print('Finished tracking progress')
def start(): webbrowser.open( "steam://rungameid/252950") # Open rocket league if not already opened gui_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'gui') eel.init(gui_folder) packet_reader = GameTickReader() options = {"chromeFlags": ["--autoplay-policy=no-user-gesture-required"]} if not is_chrome_installed(): options = { 'mode': 'system-default' } # Use the system default browser if the user doesn't have chrome. # This disable_cache thing only works if you have tare's fork of eel # https://github.com/tarehart/Eel/commit/98395ccc268e1a7a5137da2515b472fcc03db5c5 # installed to pip locally using this technique https://stackoverflow.com/a/49684835 eel.start('main.html', size=(1000, 800), block=False, callback=on_websocket_close, options=options, disable_cache=True) while not should_quit: global game_tick_packet game_tick_packet = packet_reader.get_packet() do_infinite_loop_content() eel.sleep(1.0)
def main(): eel.start('index.html', block=False) video_feed() while True: eel.sleep(1.0)
def fade(self, colors): currentColor = [0, 0, 0] while self.running: for c in colors: toWrite = list(currentColor) goto = list(hexToRgb(c)) for i in range(3): goto[i] = goto[i] - toWrite[i] steps = goto for i in range(3): steps[i] /= 255 #put steps in decimal form toWrite[i] /= 255 #put toWrite in decimal form steps[i] /= 255 #break steps into 255 steps pulseIncrementor = 0 increasing = True while (increasing == True): for i in range(3): toWrite[i] += steps[i] if toWrite[i] > 1: toWrite[i] = 1 elif toWrite[i] < 0: toWrite[i] = 0 pulseIncrementor += 1 if self.name < loopIncrementor: self.running = False if self.running == True: writeRgb(toWrite[0], toWrite[1], toWrite[2]) eel.sleep(0.02) else: pass if pulseIncrementor >= 255: eel.sleep(1.0) increasing = False currentColor = list(hexToRgb(c))
def manage_game_state(challenge: dict, upgrades: dict, setup_manager: SetupManager) -> Tuple[bool, dict]: """ Continuously track the game and adjust state to respect challenge rules and upgrades. At the end of the game, calculate results and the challenge completion and return that """ early_failure = False, {} expected_player_count = challenge["humanTeamSize"] + len( challenge["opponentBots"]) # Wait for everything to be initialized packet = wait_till_cars_spawned(setup_manager, expected_player_count) if packet.num_cars == 0: print("The game was initialized with no cars") return early_failure stats_tracker = ManualStatsTracker(challenge) while True: try: eel.sleep(0) # yield to allow other gui threads to operate. packet = GameTickPacket() setup_manager.game_interface.fresh_live_data_packet( packet, 1000, WITNESS_ID) if packet.num_cars == 0: # User seems to have ended the match print("User ended the match") return early_failure stats_tracker.updateStats(packet) results = packet_to_game_results(packet) if has_user_perma_failed(challenge, stats_tracker.stats): time.sleep(1) setup_failure_freeplay(setup_manager, "You failed the challenge!") return early_failure if end_by_mercy(challenge, stats_tracker.stats, results): time.sleep(3) setup_failure_freeplay(setup_manager, "Challenge completed by mercy rule!", "green") return True, results if packet.game_info.is_match_ended: break except KeyError: traceback.print_exc() # it means that the game was interrupted by the user print("Looks like the game is in a bad state") setup_failure_freeplay(setup_manager, "The game was interrupted.") return early_failure return calculate_completion(challenge, stats_tracker.stats, results), results
def main(): cap = cv.VideoCapture(0) # Eelフォルダ設定、および起動 ############################################### eel.init('web') eel.start('index.html', mode='chrome', cmdline_args=['--start-fullscreen'], block=False) while True: start_time = time.time() eel.sleep(0.01) # カメラキャプチャ ##################################################### ret, frame = cap.read() if not ret: continue # UI側へ転送(画像) ##################################################### _, imencode_image = cv.imencode('.jpg', frame) base64_image = base64.b64encode(imencode_image) eel.set_base64image("data:image/jpg;base64," + base64_image.decode("ascii")) key = cv.waitKey(1) if key == 27: # ESC break # UI側へ転送(処理時間) ################################################# elapsed_time = round((time.time() - start_time), 3) eel.set_elapsedtime(elapsed_time)
def display(self): if started: return False webdir = os.path.join(os.path.dirname(__file__), '../web/') start(web_dir=webdir) while not stopped: eel.sleep(1)
def __init__(self): print('Basic-v0 environment') dir_path = os.path.dirname(os.path.realpath(__file__)) # ------------ load data ------------------ # self.data = pd.read_csv(dir_path+'/data/notifications.csv' ) self.contexts = self.data[['postedDayOfWeek', 'postedTimeOfDay', 'contactSignificantContext']] self.notifications = self.data[['appPackage', 'category', 'priority', 'numberUpdates']] self.engagements = self.data[['action', 'response']] self.action_space = spaces.Discrete(2) self.observation_space = spaces.Discrete(len(self.data)) self.epoch = 0 self.openedNotifications = [] self.openedActions = [] self.openedContexts = [] self.dismissedNotifications = [] self.dismissedActions = [] self.dismissedContexts = [] self.correctlyOpened = 0 self.correctlyDismissed = 0 # ------------ prep ui ------------------ # eel.init(dir_path+'/web') eel.start('main.html', mode='chrome', block=False) eel.sleep(3) eel.initial_state(dumps({'notification': self.notifications.iloc[self.epoch].to_dict(), 'context':self.contexts.iloc[self.epoch].to_dict(), 'size':len(self.data)}))
def loop(): global tracking_first while True: ret, frame = cap.read() if mouse_on_move == True and streaming == True: frame = cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 255), 2) if streaming == True: if tracking == True: if tracking_first == True: tracking_first = False term_crit = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 1) xmin, xmax = min(x1, x2), max(x1, x2) ymin, ymax = min(y1, y2), max(y1, y2) track_window = (xmin, ymin, xmax - xmin, ymax - ymin) roi = frame[ymin:ymax, xmin:xmax] roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) roi_hist = cv2.calcHist([roi], [0], None, [180], [0, 180]) cv2.normalize(roi_hist, roi_hist, 0, 255, cv2.NORM_MINMAX) hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) dst = cv2.calcBackProject([hsv], [0], roi_hist, [0, 180], 1) ret, track_window = cv2.CamShift(dst, track_window, term_crit) pts = cv2.boxPoints(ret) pts = np.int0(pts) cv2.polylines(frame, [pts], True, (0, 255, 0), 2) imshow(frame) eel.sleep(0.03)
def watch(self): print("Starting EAGLE EYES....") try: # initially send the all log files print("Initial Loading of Logs...") self.logs = self.get_logs_info() for log_name in self.logs.keys(): self.send(self.logs[log_name]) print("Finished Initial Loading of Logs...") while self.running: print("Watching....") eel.sleep(0.5) logs_info = self.get_logs_info() for log_key in logs_info: if (self.running and logs_info[log_key]['size'] != 0 and (logs_info[log_key]['size'] != self.logs[log_key]['size'] or logs_info[log_key]['date'] != self.logs[log_key]['date'])): # the remote file has changed, send the log self.send(logs_info[log_key]) # update the cached log info self.logs[log_key] = logs_info[log_key] except Exception as e: print(e) print("Disconnecting") self.running = False self.close() sys.exit()
def detector(): a = sys._MEIPASS defaultdict = {} defaultdict["Rohit"] = 0 defaultdict["Argh"] = 0 defaultdict["Antima"] = 0 defaultdict["Rakesh"] = 0 defaultdict["unknown"] = 0 lastSeen = datetime.now() faceDetector = cv2.CascadeClassifier( a + "\\haarcascade_frontalface_default.xml") cam = cv2.VideoCapture(0) recog = cv2.face.LBPHFaceRecognizer_create() recog.read(a + "\\trainingData.yml") id = 0 label = "" font = cv2.FONT_HERSHEY_SIMPLEX while True: ret, img = cam.read() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = faceDetector.detectMultiScale(gray, 1.15, 3, minSize=(50, 50)) for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) id, conf = recog.predict(gray[y:y + h, x:x + w]) if id == 1: label = "Sumit" elif id == 2: label = "Rohit" elif id == 3: label = "Rakesh" elif id == 4: label = "Antima" else: label = "unknown" cv2.putText(img, label, (x, y + h), font, 2, (0, 255, 0), 3) defaultdict[label] = defaultdict[label] + 1 # asyncio.run(notify(v, label+" is at the door")) currentSeen = datetime.now() if (currentSeen - lastSeen).seconds > 30: print("Intruder alert", defaultdict) lastSeen = currentSeen threading.Thread(target=notify, args=(a, defaultdict)).start() defaultdict = dict.fromkeys(defaultdict, 0) eel.sleep(10) cv2.imshow("Face", img) if cv2.waitKey(1) == ord("q"): break cam.release() cv2.destroyAllWindows()
def loop(): while True: ret, frame = cap.read() if mouse_on_down == True & streaming == True: frame = cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 255), 2) if streaming == True: imshow(frame) eel.sleep(0.03)
def display(self): if started: return False webdir = os.path.join(os.path.dirname(__file__), '../web/') filedir = os.path.abspath(settings.get("output.base_dir")) start(web_dir=webdir, file_dir=filedir, rmd_version=self.rmd_version) while not stopped: eel.sleep(1)
for p in procs: print("Killing ", p.pid) p.terminate() gone, alive = psutil.wait_procs(procs, timeout=timeout, callback=on_terminate) if alive: # send SIGKILL for p in alive: print("process {} survived SIGTERM; trying SIGKILL" % p.pid) p.kill() gone, alive = psutil.wait_procs(alive, timeout=timeout, callback=on_terminate) if alive: # give up for p in alive: print("process {} survived SIGKILL; giving up" % p.pid) @eel.expose def stop_manager(): print("Shutting manager down.") player_plain.reap(psutil.Process()) procs = psutil.Process().kill() print("=== Ready! ===") print("To play games open http://localhost:6147/run.html in your browser on Mac/Linux/WindowsPro, or http://192.168.99.100:6147/run.html on Windows10Home.") lock = threading.Lock() eel.start('run.html', options=options, block=False) while True: eel.sleep(1.0)