def __init__(self, video_player, controls, config, server_ip=None, server_port=None): QtGui.QDialog.__init__(self) self.config = config self.server_ip = server_ip self.server_port = server_port self.sock = None self.msg_q = asyncio.Queue() if server_ip else None self.timer = None self.video_player = video_player self.controls = controls self.guide = Guide() self.remote_vals = self.load_remote_vals() self.remote = None self.setup_ui() self.prev_volume = 100 self.muted = False self.setFixedSize(self.size()) if server_ip: self.sock = WebsocketServer(self.server_port, host=self.server_ip) self.sock.set_fn_new_client(self.on_open) self.sock.set_fn_message_received(self.on_message) self.sock_thread = threading.Thread(target=self.sock.run_forever, daemon=True) self.sock_thread.start()
def load(database): """ Load a database """ global guide guide = Guide(database) return guide
def createGuides(self): prevGuide = None for i in range(self.nJnt): guide = Guide(shader = self.shader,name=self.name + '_guide_' + (str(i)).zfill(2),moduleParent = self.name) guide.drawGuide() pos = [0,0,i*10] if i == 0: self.moduleCtrl ,self.moduleCtrlGrp = utils.buildBoxController(guide.name,self.name + '_ctrl',2) pm.parent(self.moduleCtrlGrp,self.moduleGrp) pm.parent(self.moduleGuidesGrp,self.moduleCtrl) guide.setPos(pos) self.guidesList.append(guide.name) pm.parent(guide.guideGrp,self.moduleGuidesGrp) attrName = 'guide_' + (str(i)).zfill(2) pm.addAttr(self.moduleCtrl,ln=attrName,at='message') guide.transform.message.connect( self.moduleCtrl.attr(attrName)) if i > 0: connectionGrp = prevGuide.drawConnectionTo(guide) pm.parent(connectionGrp,self.moduleConnectionsGrp) prevGuide = guide self.moduleRebuildInfo['guidesList'] = self.guidesList self.moduleCtrlGrp.setTranslation(self.position,space='world')
def refresh(self): '''Refetch instance data from the API. ''' response = requests.get('%s/categories/%s' % (API_BASE_URL, self.name)) attributes = response.json() self.ancestors = [Category(name) for name in attributes['ancestors']] self.contents = WikiText(attributes['contents_raw'], attributes['contents_rendered']) self.description = attributes['description'] self.guides = [] for guide in attributes['guides']: self.guides.append(Guide(guide['guideid'])) # Unlike guides, categories return flags as a dict, keyed by flagid. # *Except* when it's empty, in which case we get an empty list due to # PHP's json_encode() not knowing the difference between an empty array # and an empty dict. flags = dict(attributes['flags']).values() self.flags = [Flag.from_id(flag['flagid']) for flag in flags] self.image = Image( attributes['image']['id']) if attributes['image'] else None self.locale = attributes['locale'] #self.parts = attributes['parts'] #self.solutions = attributes['solutions'] self.title = attributes['display_title']
def exampleA(mirror=False, showWindow=False): '''Built a basic and a chain system. Set the basic to be dynamic and connect the chain to it. Args: mirror (bool): True to duplicate the systems on the right side showWindow (bool): True to popup Brigks Main Window ''' # Building Matrix for guide positions basicMatrices = dict( Part1=Transformation.fromParts(translation=Vector3([2, 2, 0])), Part2=Transformation.fromParts(translation=Vector3([4, 2, 0])), ) chainMatrices = dict( Part1=Transformation.fromParts(translation=Vector3([2, 3, 0])), Part2=Transformation.fromParts(translation=Vector3([4, 4, 0])), Part3=Transformation.fromParts(translation=Vector3([6, 3, 0])), ) # Create Guide, add a layer and a couple Systems guide = Guide() guide.setSettings(hideRig=False) guide.setSettings(hideJoints=False) layer = guide.addLayer("MyFirstLayer") basic = layer.addSystem("basic", "L", "Basic", basicMatrices) chain = layer.addSystem("chain", "L", "Chain", chainMatrices) # System Settings basic.setSettings(dynamic=True, dynamicAnimatable=True, strap=True) # Connections chain.addConnection("Root", "slotParent", key=basic.key(), slot="Part1") if mirror: for system in layer.systems().values(): system.duplicate(mirror=True) # Save edit guide.commit() # Build all rig guide.build() if showWindow: showWindow() return guide
def __init__(self, verbose=VERBOSE, checker=None): self.myverbose = verbose # now unused self.checker = checker self.base = None self.links = {} self.runtime = None self.channel = None self.title = None self.titleid = None self.svcid = None self.start_time = None self.starting_time = None self.event_time = None self.event_hour = None self.event_date = None self.starting_point = 973728000.0 self.starting_point = 973728000.0 + (4 * 60 * 60) self.prime_start_time = 0 self.guide = Guide() sgmllib.SGMLParser.__init__(self)
def game_loop(args, clock): global hud, controller, world, display # attack_performed = 0 pygame.init() pygame.font.init() guide_me = Guide() try: client = carla.Client(args.host, args.port) client.set_timeout(2.0) # timeout in case the client loses connection log = create_logfile(args) display = pygame.display.set_mode((args.width, args.height), pygame.HWSURFACE | pygame.DOUBLEBUF) hud = HUD(args, log, __doc__) world = World(client.get_world(), hud, args.filter) controller = DualControl(world, args) if args.cyberattack: thread.start_new_thread(controller.attack_trigger, ()) time.sleep(1.5) thread.start_new_thread(hud.write_driving_data, (True, )) while True: clock.tick_busy_loop(40) # max fps in client if controller.parse_events(world, clock): return world.tick(clock) world.render() guide.render(guide_me) pygame.display.flip() finally: time.sleep(1) # delay to allow threads to finish first controller.video.stop_recording() if world is not None: world.destroy() pygame.quit()
def create_guide(self): self.guide = Guide() return