Ejemplo n.º 1
0
    def __init__(self, **kwargs):
        # Perhaps allow passing in a non-empty *mobjects parameter?
        Container.__init__(self, **kwargs)
        self.camera = self.camera_class(**self.camera_config)
        self.mobjects = []
        self.continual_animations = []
        self.foreground_mobjects = []
        self.num_plays = 0
        self.saved_frames = []
        self.shared_locals = {}
        self.frame_num = 0
        self.current_scene_time = 0
        self.original_skipping_status = self.skip_animations
        if self.name is None:
            self.name = self.__class__.__name__
        if self.random_seed is not None:
            random.seed(self.random_seed)
            np.random.seed(self.random_seed)

        self.setup()
        if self.write_to_movie:
            self.open_movie_pipe()
        try:
            self.construct(*self.construct_args)
        except EndSceneEarlyException:
            pass

        # Always tack on one last frame, so that scenes
        # with no play calls still display something
        self.skip_animations = False
        self.wait(self.frame_duration)

        if self.write_to_movie:
            self.close_movie_pipe()
        print("Played a total of %d animations" % self.num_plays)
Ejemplo n.º 2
0
 def __init__(self, *submobjects, **kwargs):
     Container.__init__(self, *submobjects, **kwargs)
     if not all(map(lambda m: isinstance(m, Mobject), submobjects)):
         raise Exception("All submobjects must be of type Mobject")
     self.submobjects = list(submobjects)
     self.color = Color(self.color)
     if self.name is None:
         self.name = self.__class__.__name__
     self.init_points()
     self.generate_points()
     self.init_colors()
Ejemplo n.º 3
0
 def __init__(self, *submobjects, **kwargs):
     Container.__init__(self, *submobjects, **kwargs)
     if not all(map(lambda m: isinstance(m, Mobject), submobjects)):
         raise Exception("All submobjects must be of type Mobject")
     self.submobjects = list(submobjects)
     self.color = Color(self.color)
     if self.name is None:
         self.name = self.__class__.__name__
     self.init_points()
     self.generate_points()
     self.init_colors()
Ejemplo n.º 4
0
 def __init__(self, *submobjects, **kwargs):
     Container.__init__(self, *submobjects, **kwargs)
     if not all([isinstance(m, Mobject) for m in submobjects]):
         raise Exception("All submobjects must be of type Mobject")
     self.submobjects = list(submobjects)
     self.color = Color(self.color)
     if self.name is None:
         self.name = self.__class__.__name__
     self.updaters = []
     self.reset_points()
     self.generate_points()
     self.init_colors()
Ejemplo n.º 5
0
    def get(self):
        self.handle = Handle()
        self.con = Container()
        """
	changed the runContainerid with getContainerTrucId
	"""
        """
        self.ret_con = self.con.runContainerId()
	"""
        self.ret_con = self.con.getContainerTrucId()
        self.write(json.dumps(self.ret_con))
Ejemplo n.º 6
0
    def test_get(self, tag, payload, expected_class, constructors):
        print("=====")
        container = Container()
        container.add(tag, payload)
        if constructors is not None:
            container.with_constructors(tag, constructors)

        object = container.get(tag)
        if expected_class is None:
            return False

        self.assertTrue(isinstance(object, expected_class))
Ejemplo n.º 7
0
 def get(self, id, name):
     self.handle = Handle()
     self.con = Container()
     for item in self.con.getContainerTrucId():
         if id == item:
             if name == "cpu":
                 ret = self.handle.getCpu()[id]
             if name == "mem":
                 ret = self.handle.getMem()[id]
             if name == "blkio":
                 ret = self.handle.getBlk()[id]
             if name == "net":
                 ret = self.handle.getNet()[id]
     self.write(json.dumps(ret))
Ejemplo n.º 8
0
def test_container():
    container = Container()
    item = 5
    item2 = 6

    assert container.is_empty()
    assert container.size() == 0

    container.push(item)
    assert container.size() == 1
    assert not container.is_empty()

    container.push(item2)
    assert container.size() == 2
    assert not container.is_empty()

    print('Container tested SUCCESSFULLY')
Ejemplo n.º 9
0
    def get(self, id):
        self.handle = Handle()
        self.con = Container()
        self.dt = {}
        """
	we have a another wonderful method to make
	things better.
        """
        """
        for item in self.con.runContainerId():
            self.ret = self.con.getContainerArg(item)
            self.dt[item]= self.ret
        self.write(json.dumps(self.dt))
	
	"""
        self.ret = self.con.getContainerArg(id)
        self.dt[id] = self.ret
        self.write(json.dumps(self.dt))
Ejemplo n.º 10
0
    def __init__(self, args, config):
        """ Function to manage qb container operations. """

        # Use the logger object created by Client.
        self.p = logging.getLogger('qb')

        # Pull out the relevant values from config.
        self.url = config['container']['lxd_api']['url']
        self.cert = config['container']['lxd_api']['cert']
        self.key = config['container']['lxd_api']['key']

        # Create a Container instance.
        self.container = Container(self.url, self.cert, self.key)

        # Invoke the required function based on the provided args.
        if args.list:
            self.list()

        elif args.create is not None:
            self.create(
                args.create[0],  # Name.
                args.create[1])  # Image.

        elif args.start is not None:
            self.start(args.start[0])

        elif args.stop is not None:
            self.stop(args.stop[0])

        elif args.remove is not None:
            self.remove(args.remove[0])

        else:
            self.p.error("Error invoking function.")
            sys.exit(1)

        return
Ejemplo n.º 11
0
Archivo: node.py Proyecto: 20ft/noodle
    def _spawn_container(self, msg):
        # checks
        description = msg.params['description']
        if description['Architecture'] != 'amd64' or description[
                'Os'] != 'linux':
            raise ValueError(
                "Does not appear to be a linux/amd64 container: " +
                description['uuid'])

        # check and strip trailing slashes
        if 'volumes' in msg.params and msg.params['volumes'] is not None:
            for vol in msg.params['volumes']:
                if len(vol[0]) != 22 or len(vol[1]) == 0:
                    raise ValueError("Volume specifications are wrong")
                if vol[1][-1:] == '/':
                    vol[1] = vol[1][:-1]

        # Have a look at the configuration, replace any missing bits with defaults
        try:
            config = description['Config']
        except KeyError:
            raise ValueError("Config node not in description")
        Node._ensure_docker_config(config, 'Cmd', [])
        Node._ensure_docker_config(config, 'Entrypoint', [])
        Node._ensure_docker_config(config, 'Env', [])
        Node._ensure_docker_config(config, 'WorkingDir', '/')
        if config['WorkingDir'] == '':
            config['WorkingDir'] = '/'

        # allocate the container and fetch an IP from laksa
        ctr = Container(self, self.network, msg, config)
        self.containers[ctr.uuid] = ctr
        self.stats.containers = len(self.containers)
        logging.info("Spawning a container: %s" % ctr.name)
        self.connection.send_cmd(b'allocate_ip', {'container': ctr.uuid},
                                 reply_callback=self._launch)
Ejemplo n.º 12
0
    def test_add(self, tag, payload, expected_class, constructors):

        container = Container()
        container.add(tag, payload)
        self.assertEqual(1, len(container.definitions))
        self.assertEqual(container.definitions[tag], payload)
Ejemplo n.º 13
0
#!/usr/bin/python2.7

import sys
from container.container import Container

if __name__ == "__main__":
    host_ip1 = sys.argv[1]
    host_ip2 = sys.argv[2]

    image = "zoidberg:latest"

    ksfile1 = "atv_bondi_02.ks"
    beaker_name1 = "dell-per515-01.lab.eng.pek2.redhat.com"

    # Set docker run
    dr = Container()
    dr.image = image
    dr.ksfile = ksfile1
    dr.host_ip = host_ip1
    dr.beaker_name = beaker_name1

    # Run test
    dr.run_test()
    print "Running test1 in background..."

    #
    # Run second test
    #
    ksfile2 = "atv_nfs_01.ks"
    beaker_name2 = "dguo-localhost.nay.redhat.com"
Ejemplo n.º 14
0
# Main method
if __name__ == '__main__':

    # Instantiate connection
    conn = DBsetup()

    # Instantiate view on DB
    initView(conn)

    # Get a list of available items
    for rule in range(1, 11):

        # Query data
        orderData = conn.execute(
            "SELECT * FROM PRODUCT_ORDERS WHERE ORDERID <= 25")
        rootContainer = Container()

        # Setup global container
        for row in orderData:
            rootContainer.addItem(Item(rule, row))

        # - - - - - - - - - - - - - - - - - - - - -
        # Actual start of algorithm

        # Initialise result array
        result = []

        # Split on Rule 1
        subContainers = splitOnRule([rootContainer], rule)

        subContainers.append(Container())