def main(): # postal_code = '68516' # country_code = 'US' # start_date = '2020-10-10' # end_date = '2020-10-20' # observations = Observations(postal_code, country_code, start_date, end_date) # # value_key1 = 'windSpeed' # title1 = stringcase.titlecase(value_key1) # metric1 = observations.get_values_by_key(value_key1) # label1 = title1 + " " + metric1["unit_code"] # # value_key2 = 'windChill' # title2 = stringcase.titlecase(value_key2) # metric2 = observations.get_values_by_key(value_key2) # label2 = title2 + " " + metric2["unit_code"] # # figure(num=None, figsize=(18, 6), dpi=80, facecolor='w', edgecolor='k') # # plt.plot(metric1['timestamps'], metric1['values'], label=label1) # plt.plot(metric2['timestamps'], metric2['values'], label=label2) # # plt.xlabel("Date") # plt.ylabel("Value") # plt.title(f"{title1} vs. {title2}\n{postal_code}, {country_code}\nFrom {start_date} to {end_date}") # # plt.legend() # plt.show() gui.start_gui()
def main(): import sys if getattr( sys, 'frozen', False ) : # running in a bundle , we exec the same module import bundle_main return bundle_main.main() else: import gui gui.start_gui()
def get_captcha(file): captcha = '' try: if "com.termux" in os.environ.get( "PREFIX", ""): # If device is running Termux (thanks crinny) path = f'/sdcard/{file}' gif.get_captcha(path) subprocess.run( [ "am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", f'file://{path}', "-t", "image/png", "--activity-clear-task" ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) captcha = input('Enter captcha(saved as "captcha.png"):\n') except FileNotFoundError: pass try: if not captcha: gif.get_captcha(file) import gui captcha = gui.start_gui(file) except: captcha = input(f'Enter captcha(saved as "{file}"):\n') return str(captcha)
def get_captcha(file): captcha = '' print('Processing...') result = gif.process_phantomjs(api_key) if result == 2: print('Enter your phantomjscloud api-key \n' 'Введи ключ(Читай faq):') key = input().strip() gif.process_phantomjs(key) save_api(key) try: if "com.termux" in os.environ.get("PREFIX", ""): # If device is running Termux (thanks crinny) path = f'/sdcard/{file}' gif.get_captcha(path) subprocess.run( ["am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", f'file://{path}', "-t", "image/png", "--activity-clear-task"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) captcha = input('Enter captcha(saved as "captcha.png"):\n') except FileNotFoundError: pass try: if not captcha: gif.get_captcha(file) import gui captcha = gui.start_gui(file) except: captcha = input(f'Enter captcha(saved as "{file}"):\n') return str(captcha)
def main(): if "YAFS" in sys.argv: sys.argv.remove("YAFS") try: import yas3fs return yas3fs.main() except Exception as e: error.show_exception("S3 Filesystem failure!", e) return try: import bundle_install install_location = os.path.dirname(bundle_install.get_location()) if install_location != os.getcwd(): if not bundle_install.check_installed(): with gui.splash("install"): bundle_install.install() gui.show_message( "S3 Drive", "Installation complete to {0} folder. S3Drive link is available on your desktop." .format(install_location)) else: if gui.show_prompt( "S3 Drive", "Existing installation is found. Do you want to update it?" ): with gui.splash("install"): bundle_install.install() gui.show_message( "S3 Drive", "Update complete in {0} folder. S3Drive link is available on your desktop." .format(install_location)) sys.exit(0) except Exception as e: error.show_exception("Failed to install!", e) return os.chdir(install_location) gui.start_gui()
def main_function(): conn = sql_handler.start_sql() c = conn.cursor() window = gui.start_gui(c) while True: #adding new opponents info_added_list, close_window = gui.event_loop(window, conn) if close_window or close_window == None: break ''' #Not in use yet sql_handler.add_data(conn, """INSERT INTO users VALUES (:username,:osu_id,:country, :badges, :pp, :rank_world,:rank_country, :date, :team_name, :win)""",{'username':,'osu_id':,'country' :,'badges':,'pp':,'rank_world':,'rank_country':, 'date':,'team_name':,'win':}) ''' gui.close_gui(window)
def start_curator(args): # We need a controller control = controller(verbose=(verbose_level>1)) # Lets create a set of sets if len(args)>0: for uri in args: control.add_set_by_uri(uri) # We have sets to deal with now if verbose: print "Project using %d photo sets" % (control.get_set_count()) cwd = os.getcwd() if os.path.dirname(sys.argv[0]) == cwd: bp=cwd+"/../" else: bp=cwd sys.path.append(bp+"/ui/"+gui_mode) from gui import start_gui gui = start_gui(verbose=(verbose_level>1), basepath=bp, controller=control) gui.run()
import gui gui.start_gui()
"""Main module.""" from gui import start_gui import logging from cache import Cache import argparse import os logging.basicConfig(format="%(asctime)s : %(levelname)s:%(message)s", filename="test.log", level=logging.INFO) parser = argparse.ArgumentParser() parser.add_argument("-c", "--cache-dir", help="Choose directory to store cache in") parser.add_argument("-n", "--no-cache", action="store_true", help="Disable caching of results") args = parser.parse_args() if not args.no_cache: if args.cache_dir: cache = Cache(cfile=os.path.join(args.cache_dir, 'studentinfo.json')) else: cache = Cache() else: cache = Cache(use_cache=False) start_gui(cache)
import matplotlib.pyplot as plt from automata import generate_population, next_generation, population, singles_left, happiness_per_gen from config import SKIP_TO_THE_END from gui import start_gui def plot_happiness_per_generation(): plt.title('Happiness Per Generation') plt.xlabel('Generation') plt.ylabel('Happiness') plt.plot(happiness_per_gen.keys(), happiness_per_gen.values()) plt.show() if __name__ == "__main__": generate_population() i = 0 while SKIP_TO_THE_END: i += 1 next_generation() if not singles_left(): break start_gui() print(len(population)) plot_happiness_per_generation()
def run_game_cycle(current_board, show_board, all_players): ''' Runs one complete game cycle where ai picks random move from list of available moves ''' total_start = time.time() round_count = 0 player_count = 0 num_players = len(all_players) players_with_no_moves = 0 round_time = 0 if show_board: gui.start_gui() for current_player in itertools.cycle(all_players): all_valid_moves = current_player.collect_moves( current_board, round_count) # change: passed in current_board if show_board: gui.display_board( current_board.board_contents, current_player, all_players, round_count) # I don't know why i need to put this here if len(list(all_valid_moves.keys()) ) > 0: # If no valid moves available for this player. players_with_no_moves = 0 # Reset to zero if at least one player can make a move if show_board: gui.display_board(current_board.board_contents, current_player, all_players, round_count) # Get all valid moves and ai decides on which one to make random_indexes = random.sample(all_valid_moves.items(), 1) piece_type = random_indexes[0][0] index = list(all_valid_moves[piece_type].keys())[0] orientation = all_valid_moves[piece_type][index][0] # ai chooses move current_board.update_board(current_player.player_color, piece_type, index, orientation, round_count, True) current_player.update_player(piece_type) # Updates ai if player_count == 0: # Stop ai game and look mechanism end = time.time() print("Time For AI Round ", round_count, ": ", round(round_time, 2), " seconds.", sep="") # x = input() # Stops each round to observe ai game visually. Disable by commenting out this line start = time.time() else: players_with_no_moves += 1 player_count += 1 if player_count == num_players: # Increment round count each time last player's turn is done. round_count += 1 end = time.time() round_time = end - start player_count = 0 if players_with_no_moves == 4: # If 4 players with no moves, end game break winner = current_board.calculate_winner(all_players, round_count) print("Winner(s):", winner) total_end = time.time() print("Game took:", round(total_end - total_start, 2), "seconds.")
m = None piece = self.b.next_move() for (r, c) in self.b.get_moves(): a = ScoreBoard(self.b, r, c, piece) offence, defense = a if offence >= 100: # we are about to we m = a, r, c break if m == None: m = a, r, c continue o, d = m[0] if defense >= 20: # that the way to go or we will loose m = a, r, c elif d < 20 and (offence > o or (offence == o and d < defense)): m = a, r, c return m[1:] def next_move(self, r, c, win_msg): piece = self.b.next_move() self.b.put(r, c) if self.b.check_if_won() == piece: return False, win_msg if self.b.is_full(): return False, "Draw!" return True, 0 if __name__ == '__main__': start_gui(Game())
model_checkpoint_callback = tf.keras.callbacks.ModelCheckpoint( filepath=CHECKPOINT_DIR, monitor='total_loss', mode='min', save_freq=5, save_best_only=True) # Get dataset train_dataset, test_dataset, shape = get_mnist() vae = VAE(shape, LATENT_SHAPE) tb_callback.set_model(vae) vae.load_weights(CHECKPOINT_DIR) vae.compile(optimizer="adam") vae.fit(train_dataset, epochs=20, callbacks=[tb_callback, model_checkpoint_callback]) # Validate vae.evaluate(test_dataset) # Save sampes in tensorboard predictions = vae.random_sample() file_writer = tf.summary.create_file_writer(LOG_DIR) with file_writer.as_default(): tf.summary.image("Images", predictions, max_outputs=10, step=0) # Visual experiment start_gui(vae)
serverthread.start() clientthread = Thread(target=sock_foward, name="ServerToClient", args=("s2c", serversocket, clientsocket, serverprops.comms.clientqueue, serverprops)) clientthread.setDaemon(True) clientthread.start() #wait for something bad to happen :( serverthread.join() clientthread.join() #thread.start_new_thread(sock_foward,("c2s", clientsocket, serversocket, clientqueue, serverqueue, serverprops)) #thread.start_new_thread(sock_foward,("s2c", serversocket, clientsocket, serverqueue, clientqueue, serverprops)) if __name__ == "__main__": #====================================================================================# # server <---------- serversocket | mcproxy | clientsocket ----------> minecraft.jar # #====================================================================================# sd = Thread(name="ServerDispatch", target=startNetworkSockets, args=(serverprops,)) sd.setDaemon(True) sd.start() shell = Thread(name="InteractiveShell", target=ishell, args=(serverprops,)) shell.setDaemon(True) shell.start() import gui gui.start_gui(serverprops) #app should exit here, and threads should terminate
import gui from candidatos import lista_candidatos if __name__ == '__main__': gui.start_gui()
machine = Machine(pi) machine.setup() md = MachineDriver(machine) server = OSCServer(md, ip=args.ip, port=args.port) server.serve_forever() if __name__ == '__main__': argsParser = argparse.ArgumentParser(prog='machine server') argsParser.add_argument('--ip', default='127.0.0.1', help='The ip to listen on. (default 127.0.0.1') argsParser.add_argument('--port', type=int, default=5005, help='The port to listen on. (default 5005)') argsParser.add_argument('--gui', type=bool, default=False) argsParser.add_argument('--debug', type=bool, default=False) args = argsParser.parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) if args.gui: start_gui(args.ip, args.port) else: start(args.ip, args.port)