Example #1
0
class JobFactory:
    creator = ObjectFactory().create

    def create(self, context_lib_name, payload):
        context = self.creator(kind='context',
                               lib_name=context_lib_name,
                               name='Context',
                               payload=payload)
        kwargs = {'context': context}
        logging.info(
            f'create new job for {context.name}, event {context.event}')
        try:
            with open(JOB_CONFIG) as f:
                kwargs.update(json.load(f)[context.name][context.event])
        except:
            logging.info(f'use default job')
            pass

        job = Job(**kwargs)

        runner = self.creator(kind='runner',
                              lib_name=job.runner_lib,
                              name='Runner')
        job.set_runner(runner)

        payload_provider = self.creator(kind='job_payload',
                                        lib_name=job.payload_lib,
                                        name='JobPayloadProvider')
        job.set_payload_provider(payload_provider)

        return job
Example #2
0
 def __init__(self, host, user, passwd, group=None):
   super(Driver, self).__init__(host, user, passwd, group)
   self.object_factory = ObjectFactory(self)
Example #3
0
	def __init__(self):
		"""Initialized the game system."""
		
		# Checks if the game is currently active.
		self.is_active = True
		
		# The current time elapsed in milliseconds.
		self.delta_time = 0.0
		
		# The pygame clock for limiting the framerate.
		self.pygame_clock = None
		
		# The backbuffer being rendered to.
		self.backbuffer = None
		
		# The input manager for managing keyboard and mouse input.
		self.input_manager = InputManager(self)
		
		# The game object factory for creating the game objects.
		self.object_factory = None
		
		# The settings object for managing the gameplay code.
		self.settings = None
		
		# The game objects for the game. Keys are the game object ids.
		self.game_objects = {}
		
		# The test object references.
		self.test_objects = {}
		
		# The GUI tile objects.
		self.gui_tile_objects = {}
		
		# The GUI text objects.
		self.gui_text_objects = {}
		
		# The tetronimos falling. This is updated every frame from objects gathered from 
		# the game_objects dictionary.
		self.tetronimos_falling = {}
		
		# The tetronimo blocks created by the tetronimos falling. Also includes blocks 
		# that have already landed.
		self.tetronimo_blocks = {}
		
		# The tetronimo displays.
		self.tetronimo_displays = {}
		
		# The pygame sprite images.
		self.pygame_sprites = {}
		
		# The fonts for the text boxes.
		self.fonts = {}
		
		# Create the settings object.
		self.settings = Settings()
		
		# Create the game object factory.
		self.object_factory = ObjectFactory(self.game_objects, self.pygame_sprites, 
				self.fonts)
				
		# Attach all the objects to each other.
		self.settings.object_factory = self.object_factory
		self.settings.tetronimos_falling = self.tetronimos_falling
		self.settings.tetronimo_blocks = self.tetronimo_blocks
		self.settings.input_manager = self.input_manager
		self.settings.game_system = self
		
		self.object_factory.settings = self.settings
		self.object_factory.input_manager = self.input_manager
Example #4
0
from object_factory import ObjectFactory

factory = ObjectFactory()

for obj_name in "Esx", "Vm", "Ds":

    obj = factory.create_instance(obj_name)
    obj.start()
    obj.shutdown()