def on_init(self) -> None: display.set_caption(LOCALIZATION.game_title) self.__display_surf = display.set_mode(CONFIG.get_screen_size(), CONFIG.get_screen_flags()) self.activeScreen().on_init()
def on_init(self) -> None: "Safely initializes pygame modules and game dependencies." pygame.init() self.__clock = pygame.time.Clock() CONFIG.on_init() LOCALIZATION.on_init() FONT.on_init() SCREEN_MANAGER.on_init() self.__running = True
def main(): if application.development: logging.debug("Detected dev environment") if not CONFIG.has_section(CONFIG_SECTION): CONFIG.add_section(CONFIG_SECTION) config = CONFIG[CONFIG_SECTION] window = impl_glfw_init(config) asyncio.run(async_main(window, config)) glfw.terminate() CONFIG.save()
def on_init(self) -> None: """Load image upon initialization.""" _image = image.load(self.path) _rect = _image.get_rect() self.image = transform.scale( _image, (_rect.width * CONFIG.get_texture_factor(), _rect.height * CONFIG.get_texture_factor())) if all(self.flippable): self.image_flipped_xy = transform.flip(self.image, True, True) if self.flippable[0]: self.image_flipped_x = transform.flip(self.image, True, False) if self.flippable[1]: self.image_flipped_y = transform.flip(self.image, False, True)
def on_init(self) -> None: """Run on_init hook on all entities.""" if not self.__init: self.__display_surf = Surface(CONFIG.get_screen_size()) for entity in self.entities: if hasattr(entity, "on_init"): entity.on_init() self.__init = True
def execute_lex_scheduled_action(event, context): logging.info('execute_lex_scheduled_action event: %s' % event) result = list_for_scheduling() for action in result: if not CONFIG.get('local'): run(schedule_lex_actions, [action, {}], {}, service='sns') else: schedule_lex_actions(action, {}) logging.info('execute_lex_scheduled_action list_for_scheduling: %s' % str(result)) return result
def __init__(self, root_path, name, uuid, bin_path=CONFIG.stratovirt_microvm_bin, vmconfig=CONFIG.get_default_microvm_vmconfig(), vmlinux=CONFIG.stratovirt_vmlinux, rootfs=CONFIG.stratovirt_rootfs, initrd=CONFIG.stratovirt_initrd, vcpus=4, memsize=2048, socktype="unix", loglevel="info"): self._args = list() self._console_address = None self._popen = None self.full_command = None self.name = name self.vmid = uuid if "unix" in socktype: sock_path = os.path.join(root_path, self.name + "_" + self.vmid + ".sock") else: sock_path = ("127.0.0.1", 32542) self.vmconfig_template_file = vmconfig self.vm_json_file = None self.vmlinux = vmlinux self.vhost_type = None self.rootfs = rootfs self.pid = None self.initrd = initrd self.vcpus = vcpus self.memsize = memsize self.inited = False self.init_vmjson(root_path) super(MicroVM, self).__init__(root_path=root_path, name=name, uuid=uuid, args=self._args, bin_path=bin_path, mon_sock=sock_path, daemon=True, config=self.vm_json_file) self.add_env("RUST_BACKTRACE", "1") if CONFIG.rust_san_check: self.add_env("RUSTFLAGS", "-Zsanitizer=address") self.add_env("STRATOVIRT_LOG_LEVEL", loglevel) if CONFIG.memory_usage_check: self.memory_check = MemoryUsageExceededInfo(0) self.memory_check.disable() self.memory_check.start()
def __init__(self, root_path, name, uuid, bin_path=CONFIG.stratovirt_standvm_bin, machine=None, vmconfig=CONFIG.get_default_standvm_vmconfig(), vmlinux=CONFIG.stratovirt_stand_vmlinux, rootfs=CONFIG.stratovirt_stand_rootfs, initrd=CONFIG.stratovirt_initrd, vcpus=4, memsize=2048, socktype="unix", loglevel="info"): self._args = list() self._console_address = None self._popen = None self.full_command = None self.name = name self.vmid = uuid if "unix" in socktype: sock_path = os.path.join(root_path, self.name + "_" + self.vmid + ".sock") else: sock_path = ("127.0.0.1", 32542) self.vmconfig_template_file = vmconfig self.vm_json_file = None self.vmlinux = vmlinux self.rootfs = rootfs self.initrd = initrd self.vcpus = vcpus self.vhost_type = None self.memsize = memsize self.multifunction = {"net": False, "console": False, "vsock": False, "balloon": False, "rng": False, "pcie_root_port": False, "vfio": False} self.code_storage_file = CONFIG.code_storage_file self.code_storage_readonly = True self.data_storage_file = None self.inited = False self.pcie_root_port_num = 0 self.pcie_root_port_remain = 0 self.pcie_root_port = {"net": False, "console": False, "vsock": False, "balloon": False, "rng": False, "block": False, "vfio": False} self.pid = None self.vfio = False self.bdf = None self.init_vmjson(root_path) self.bus_slot = dict() self.bus_slot_init() super(StandVM, self).__init__(root_path=root_path, name=name, uuid=uuid, args=self._args, bin_path=bin_path, mon_sock=sock_path, machine=machine, daemon=True, config=self.vm_json_file) self.add_env("RUST_BACKTRACE", "1") if CONFIG.rust_san_check: self.add_env("RUSTFLAGS", "-Zsanitizer=address") self.add_env("STRATOVIRT_LOG_LEVEL", loglevel)
def microvms(test_session_root_path): """Init multi microvms""" # pylint: disable=redefined-outer-name # The pytest.fixture triggers a pylint rule. micro_vms = [] for index in range(CONFIG.concurrent_quantity): tempvm = init_microvm_with_json(test_session_root_path, CONFIG.get_microvm_by_tag('initrd'), "initrd%d" % index) micro_vms.append(tempvm) yield micro_vms for tempvm in micro_vms: tempvm.kill()
def __init__(self, state: GUIState): if not CONFIG.has_section(self.CONFIG_SECTION): CONFIG.add_section(self.CONFIG_SECTION) self.config = CONFIG[self.CONFIG_SECTION] self.io = imgui.get_io() self.state: GUIState = state
for index in range(CONFIG.concurrent_quantity): tempvm = init_microvm_with_json(test_session_root_path, CONFIG.get_microvm_by_tag('initrd'), "initrd%d" % index) micro_vms.append(tempvm) yield micro_vms for tempvm in micro_vms: tempvm.kill() @pytest.fixture() def directvm(request): """Get vm fixture value""" return request.getfixturevalue(request.param) TEST_MICROVM_CAP_FIXTURE_TEMPLATE = ( "@pytest.fixture()\n" "def test_microvm_with_CAP(test_session_root_path):\n" " microvm = init_microvm_with_json(test_session_root_path,\n" " CONFIG.get_microvm_by_tag(\"CAP\"), \"CAP\")\n" " yield microvm\n" " microvm.kill()") for capability in CONFIG.list_microvm_tags(): test_microvm_cap_fixture = (TEST_MICROVM_CAP_FIXTURE_TEMPLATE.replace( 'CAP', capability)) exec(test_microvm_cap_fixture)