def execute(self): print(self.commands) if self.commands[1] == "ns": if self.commands[2] == "ls": if len(self.commands) > 3: h = hub.Hub() n = h.listServicesInNamespace(self.commands[3]) return io.BytesIO(n.encode("utf-8")) else: h = hub.Hub() n = h.listNamespaces() return io.BytesIO(n.encode("utf-8")) if self.commands[1] == "service": h = hub.Hub() n = h.findService(self.commands[2]) return io.BytesIO(n.encode("utf-8")) return None
def __init__(self, num_sensors, num_actions, show=True, agent_name='test_agent'): """ Configure the Agent num_sensors and num_actions are the only absolutely necessary arguments. They define the number of elements in the sensors and actions arrays that the agent and the world use to communicate with each other. """ self.BACKUP_PERIOD = 1e4 self.FORGETTING_RATE = 1e-3 self.show = show self.name = agent_name self.log_dir = os.path.normpath(os.path.join(mod_path, '..', 'log')) if not os.path.isdir(self.log_dir): os.makedirs(self.log_dir) self.pickle_filename = os.path.join(self.log_dir, '.'.join([agent_name, 'pickle'])) self.num_sensors = num_sensors self.num_actions = num_actions # Initialize agent infrastructure. # Choose min_cables to account for all sensors, actions, # and two reward sensors, at a minimum. min_cables = self.num_actions + self.num_sensors self.drivetrain = drivetrain.Drivetrain(min_cables) num_cables = self.drivetrain.cables_per_gearbox self.hub = hub.Hub(num_cables) self.spindle = spindle.Spindle(num_cables) self.mainspring = mainspring.Mainspring(num_cables) self.arborkey = arborkey.Arborkey() self.action = np.zeros((self.num_actions, 1)) self.cumulative_reward = 0 self.time_since_reward_log = 0 self.reward_history = [] self.reward_steps = [] self.reward_max = -tools.BIG self.timestep = 0 self.graphing = True
def run_game(): """ Main game structure that runs the whole program. """ # Initialize pygame pygame.init() # Set up the window game_hub = hub.Hub() pygame.display.set_caption(game_hub.WINDOW_TITLE) while True: """ Game loop, as long as this true the game will run. """ # Clear Screen game_hub.main_screen.fill(game_hub.BG_COLOR) # Decide what screen to display game_hub.displayscreen() # Display the screen onto the window pygame.display.flip() game_hub.CLOCK.tick(60)
from environment import env import visuals as vs import obstacle_grid as og import hub as hb env.grid = og.ObstacleGrid(env.t_simulation) for i in range(1): env.hubs.append(hb.Hub()) """ Run RRT* on each hub graph """ for t in range(env.t_expand): for hub in env.hubs: hub.graph.newIteration() if t % 10 == 0: vs.draw_scene(0, []) import visuals as vs import drone as dr import pickle # """Loading them back up again""" # with open('grid_file', 'rb') as grid_file: # env.grid = pickle.load(grid_file) # # # for b in range(env.n_hubs): # with open('hub_' + str(b), 'rb') as hub_file: # env.hubs.append(pickle.load(hub_file)) #
import hub as hb import sys from PyQt5 import QtWidgets app = QtWidgets.QApplication(sys.argv) x = hb.Hub() app.exec_()
# test passed from apscheduler.schedulers.background import BackgroundScheduler import time import hub def heart_beat(): print('发送心跳包 刷新keepalive') if __name__ == '__main__': timer = BackgroundScheduler(timezone='MST') # 函数这里只写名字 没有括号!!!!!!! timer.add_job(hub.Hub('scheduler').discoverRound, trigger='interval', id='discover', hours=8) timer.start() while(True): heart_beat() time.sleep(2)
# insert spacing newline exc.insert(0, "\n") f.write("".join(exc)) sys.__excepthook__(exctype, value, tb) self.traceback_sig.emit(exc) if __name__ == "__main__": ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(APPID) app = QtWidgets.QApplication(sys.argv) app.setWindowIcon( QtGui.QIcon(resource_path(Path("icons/icons_library.ico")))) app.setApplicationName(APP) app.setOrganizationName(ORG) path = Path( QtCore.QStandardPaths.writableLocation( QtCore.QStandardPaths.AppConfigLocation)) # save traceback to logfile if Exception is raised ex_handler = ExceptionHandler(path / "traceback.log") sys.excepthook = ex_handler.handler # create org and app folders path.mkdir(parents=True, exist_ok=True) settings = QtCore.QSettings(str(path / "config.ini"), QtCore.QSettings.IniFormat) ui = hub.Hub(settings, ex_handler) ui.startup() sys.exit(app.exec_())
def __init__(self): super().__init__() self.hub = hub.Hub(config.BIND_IP, config.HUB_PORT, config.MAX_CONCURRENT_CONNECTIONS) self.hub.daemon = True