예제 #1
0
파일: area.py 프로젝트: arunpillaii/Team
    def __init__(self,
                 label=None,
                 image=None,
                 value=None,
                 **params):  #TODO label= could conflict with the module label
        #param image: an imagez.Image object (optional)
        #param text: a string object
        params.setdefault('cls', 'list.item')
        button._button.__init__(self, **params)
        self.group = None
        self.value = value  #(self, value)
        self.widget = None

        if type(label) == str:
            label = basic.Label(label, cls=self.cls + ".label")

        if image and label:
            self.widget = container.Container()
            self.widget.add(image, 0, 0)
            #HACK: improper use of .resize()
            image.rect.w, image.rect.h = image.resize()
            self.widget.add(label, image.rect.w, 0)
        elif image:
            self.widget = image
        elif label:
            self.widget = label

        self.pcls = ""
예제 #2
0
    def runContainer(self,
                     imgName="ubuntu:14.04",
                     cmdName="sh",
                     networkName=None,
                     serviceName=None,
                     cntName=""):
        netSrt = ""
        if networkName != None:
            netSrt = "--net=" + networkName
            if serviceName != None:
                netSrt = "--net=" + serviceName + "." + networkName
        cntStr = ""
        if cntName != "":
            cntStr = "--name=" + cntName

        # docker command
        dkrCmd = "docker run -itd " + netSrt + " " + cntStr + " " + imgName + " " + cmdName
        out, err, exitCode = self.runCmd(dkrCmd)
        if exitCode != 0:
            print "Error running container: " + dkrCmd + " on " + self.addr
            print "Exit status: " + str(exitCode) + "\nError:"
            print err
            exit("docker run failed")

        # Container id is in the first line
        cid = out[0].split('\n')[0]

        # Return a container object
        return container.Container(self, cid, cntName="")
예제 #3
0
def clone():
    flask = container.Container('flask', __file__)
    flask.set_description(
        'clear flask',
        'This is a clear glass flask. It is slightly warm to the touch.')
    flask.add_adjectives('warm', 'clear', 'glass')
    flask.liquid = True
    return flask
def clone():
    pot = container.Container('pot', __file__)
    pot.set_description(
        'central pot',
        'This pot stands in the center of the room, over a hot fire.',
        unlisted=True)
    pot.fix_in_place("You can't move the pot, as it is far to heavy.")
    return pot
예제 #5
0
def clone():
    pot = container.Container('oven', __file__)
    pot.set_description(
        'clay oven',
        'This clay oven is set into the wall, and is very hot.',
        unlisted=True)
    pot.fix_in_place("The clay oven is set into the wall.")
    return pot
예제 #6
0
def clone():
    glass_bottle = container.Container('bottle', __file__)
    glass_bottle.set_description(
        "normal glass bottle",
        "This is a normal glass bottle. It looks quite usable.")
    glass_bottle.liquid = True

    return glass_bottle
예제 #7
0
def clone():
    cabnet = container.Container('cabinet', __file__)
    cabnet.set_description('small cabinet', 'This is a small cabinet above the sink.')
    cabnet.add_adjectives('small')
    cabnet.close()
    cabnet.closable = True
    cabnet.set_max_volume_carried(20)
    cabnet.set_max_weight_carried(1000000)
    return cabnet
예제 #8
0
def clone():    
    cup = container.Container('cup', __file__)
    cup.set_description('ceramic cup', 'This is an ordinary ceramic cup. It has no decorations.')
    cup.add_adjectives('ceramic', 'undecorated')
    cup.set_max_weight_carried(400000)
    cup.set_max_volume_carried(3)
    cup.liquid = True

    return cup
예제 #9
0
def clone():
    bag = container.Container('bag', __file__)
    bag.set_description('normal bag', 'A normal-looking brown bag.')
    bag.set_weight(100)
    bag.set_volume(10)
    bag.set_max_weight_carried(20000)
    bag.set_max_volume_carried(10)
    bag.closable = True
    return bag
예제 #10
0
def clone():
    s = container.Container('shaft', __file__)
    s.set_description('shaft of sunlight',
                      'This is a shaft of warm sunlight coming into the room.',
                      unlisted=True)
    s.add_adjectives('sunlight', 'warm')
    s.add_names('sunlight')
    s.see_inside = True
    s.fix_in_place('You can\'t take sunlight!')
    return s
예제 #11
0
def clone():
    b_table = container.Container('table', __file__)
    b_table.set_description(
        'banquet-size table', 'This is an extremely long banquet table, '
        'stretching almost from one end of the room to the other.',
        unlisted=True)
    b_table.fix_in_place('Moving this table would require a lot of help.')
    b_table.add_adjectives('massive', 'enormous', 'long', 'banquet')
    b_table.set_prepositions('on', "onto")
    b_table.set_max_weight_carried(4e9)
    b_table.set_max_volume_carried(3e9)
    return b_table
예제 #12
0
def clone():

    bottle = container.Container('bottle', __file__)
    bottle.set_description(
        'blue bottle',
        'This blue bottle looks like a normal plastic bottle. It is unlabeled.'
    )
    bottle.add_adjectives('blue', 'plastic', 'unlabeled')
    bottle.set_max_weight_carried(4e9)
    bottle.set_max_volume_carried(3e9)
    bottle.liquid = True

    return bottle
예제 #13
0
def clone():
    rusty_can = container.Container('can', __file__)
    rusty_can.set_description('rusty can', 'This is a rusty canister, now discarded. It\'s large enough to hold something inside.')
    rusty_can.add_adjectives('rusty', 'oil')
    rusty_can.set_weight(2000)
    rusty_can.set_volume(20)
    rusty_can.set_max_volume_carried(20)
    rusty_can.set_max_weight_carried(10000)

    kinfe = gametools.clone('domains.school.elementQuest.knife')
    rusty_can.insert(kinfe, True)
    
    return rusty_can
예제 #14
0
def clone(obj):
    corpse = container.Container("corpse", __file__)
    corpse.add_names("corpse")
    corpse.set_description(
        'corpse of a %s' % (obj.short_desc),
        'This is the foul-smelling corpse of a %s. It looks nasty.' %
        (obj.short_desc))
    corpse.set_weight(obj.weight)
    corpse.set_volume(obj.volume)
    corpse.set_max_weight_carried(obj.max_weight_carried)
    corpse.set_max_volume_carried(obj.max_volume_carried)
    corpse.add_names('corpse')
    return corpse
예제 #15
0
    def testSAA(self):
        '''
        create a 2D movie, based on the data we put in the container object 
        in the setUp method sthis method does all the graphics involved
        since this is a 2D running for lots of points might take a while
        '''

        # for reproducibility
        np.random.seed(1792)

        # parameters to play with
        nSamples = 5000  # number of samples we use for KL
        maxiter = 30000  # max number of optimization steps
        nPoints = 60  # The number of evaluations of the true likelihood
        M = 7  # bound on the plot axes
        nopt = 50
        nwalk = 50
        burn = 500
        delta = 0.1

        # initialize container and sampler
        specs = cot.Container(rose.rosenbrock_2D)
        n = 1
        for i in range(-n, n + 1):
            for j in range(-n, n + 1):
                specs.add_point(np.array([2 * i, 2 * j]))
        sampler = smp.Sampler(specs,
                              target=targets.exp_krig_sigSqr,
                              maxiter=maxiter,
                              nwalkers=nwalk,
                              noptimizers=nopt,
                              burn=burn)
        sampler.run_mcmc(500)
        mc = sampler.flatchain()

        # memory allocations. constants etc
        a = np.arange(-M, M, delta)
        X, Y = np.meshgrid(a, a)  # create two meshgrid
        grid = np.asarray([np.ravel(X), np.ravel(Y)])
        xn = np.array([1.33, 2.45])

        avgC, gradAvgC = _g.avg_var(xn, specs.U, specs.S, specs.V, specs.Xarr,
                                    grid, specs.r, specs.d, specs.reg)
        avgPy, gradAvgPy = _g.avg_var(xn, specs.U, specs.S, specs.V,
                                      specs.Xarr, mc, specs.r, specs.d,
                                      specs.reg)

        print(avgC)
        print(avgPy)
예제 #16
0
def clone():
    cabinets = container.Container('cabinets', __file__)
    cabinets.set_description('bunch of cabinets',
                             'These cabinets are made of solid titanium.')
    cabinets.fix_in_place(
        "How do you think you can take cabinets!? You can\'t.")
    cabinets.add_names('cabinet')
    cabinets.add_adjectives('metal', 'titanium', 'strong')
    cabinets.set_max_volume_carried(5000)
    cabinets.set_max_weight_carried(100000)
    cabinets.plural = True
    cabinets.closable = True
    cabinets.close()

    return cabinets
예제 #17
0
def clone():
    bookshelf = container.Container('bookshelf', __file__)
    bookshelf.set_description(
        'oak bookshelf',
        'This bookshelf is made of oak. It has many different books on it.')
    bookshelf.closable = False
    bookshelf.add_adjectives('oak')
    bookshelf.add_names('shelf')
    bookshelf.set_prepositions('on', 'onto')

    blue_book = gametools.clone('home.alex.house.blue_book')
    blue_book.move_to(bookshelf, True)

    dusty_book = gametools.clone('home.alex.house.dusty_book')
    dusty_book.move_to(bookshelf, True)
    return bookshelf
예제 #18
0
    def __name_and_extract_to_list(self, arg, list):
        basesig = arg.get_base_signature()

        if basesig in list:
            # Already in the container list?
            # If so then check for a name, name it if needed, and we're done.
            c = list[basesig]
            if c.name is None:
                c.set_name(arg.name)
        else:
            # Add this container and extract all the subcontainers.
            c = container.Container(basesig, arg.name)
            list[basesig] = c
            c.extract_structures(self.structures)
            c.extract_dictionaries(self.dictionaries)

        return
예제 #19
0
 def __init__(self, port, baud_rate, timeout, num_motors, debug_mode):
     threading.Thread.__init__(self)
     
     if debug_mode:
         self.ser = serial.Serial(port, baud_rate, timeout=timeout)
         self.ser.flush()
     else:
         self.ser = 0
 
     self._containers = []
     for i in range(num_motors):
         cont = container.Container(self, i)
         self._containers.append(cont)
     
     self._running = True
     self._ticks = 0
     self._command_queue = []
예제 #20
0
def clone():
    table = container.Container('table', __file__)
    table.set_description(
        "kitchen table",
        "This dated-looking kitchen table has chrome edging and a Formica top."
    )
    table.fix_in_place("The table is too heavy and awkward to move.")
    table.add_adjectives("kitchen", "dated", "formica")
    table.set_prepositions("on", "onto")
    table.set_max_volume_carried(5000)
    table.set_max_weight_carried(150000)

    bottle = gametools.clone('domains.school.forest.bottle')
    table.insert(bottle)

    plate = gametools.clone('domains.school.forest.plate')
    table.insert(plate)
    return table
예제 #21
0
  def instantiate(self, name, command=None):    
    config = copy.deepcopy(self.config['config'])

    # Setup bind mounts to the host system    
    bind_mounts = {}
    if 'mounts' in self.config:
      bind_mounts = self.config['mounts']
      for src, dest in self.config['mounts'].items():
        if 'volumes' not in config:          
          config['volumes'] = {}
        
        config['volumes'][dest] = {}

    if command:
      if isinstance(command, basestring):
        config['command'] = command
      else:
        config['command'] = " ".join(command)
      
    return container.Container(name, {'template': self.name, 'image_id': self.config['image_id']}, config, mounts=bind_mounts)
예제 #22
0
def clone():
    cabinets = container.Container('cabinets', __file__)
    cabinets.set_description(
        'bunch of cabinets',
        'These cabinets are made of stone, and set into the wall.',
        unlisted=True)
    cabinets.fix_in_place(
        "How do you think you can take cabinets! You can\'t.")
    cabinets.add_names('cabinet')
    cabinets.add_adjectives('stone', 'inset', 'strong')
    cabinets.set_max_volume_carried(5000)
    cabinets.set_max_weight_carried(100000)
    cabinets.plural = True
    cabinets.closable = True
    cabinets.close()

    cup = gametools.clone('domains.school.school.cup')
    cabinets.insert(cup, True)

    return cabinets
예제 #23
0
def clone():
    flask = container.Container('flask', __file__)
    flask.set_description('small flask',
                          'This is a small flask made of clear glass. ')
    flask.add_adjectives('small', 'clear', 'glass')
    flask.set_max_volume_carried(0.050)
    flask.set_max_weight_carried(200)
    flask.liquid = True

    molasses = liquid.Liquid('molasses')
    molasses.set_description(
        'thick brown molasses',
        'This brownish liquid is sweet and thick. Not surprisingly, it is used in recipes as a sweetener and a thickener.'
    )
    molasses.add_adjectives('thick', 'brown', 'brownish')
    molasses.set_volume(0.040)
    molasses.set_weight(40)

    flask.insert(molasses)

    return flask
예제 #24
0
def clone():
    cabinets = container.Container('cabinets', __file__)
    cabinets.set_description(
        'bunch of cabinets',
        'The lightly stained wooden cabinets in this kitchen are slightly dusty.'
    )
    cabinets.fix_in_place(
        "How do you think you can take cabinets!? You can\'t.")
    cabinets.add_names('cabinet')
    cabinets.add_adjectives('wood', 'lightly stained', 'stained', 'old',
                            '1960s', "1960's", '60s', "60's")
    cabinets.set_max_volume_carried(5000)
    cabinets.set_max_weight_carried(100000)
    cabinets.plural = True
    cabinets.closable = True
    cabinets.close()

    flask = gametools.clone('domains.school.forest.flask')
    cabinets.insert(flask)

    return cabinets
예제 #25
0
def clone():
    desk = container.Container('desk', __file__)
    desk.set_description(
        'carved oak desk',
        'This carved oak desk is clearly more than 100 years old, and is carved out in the shapes of dragons and other vicious creatures. There are a few papers on its surface.',
        unlisted=True)
    desk.fix_in_place(
        'The desk is very, very heavy, and feels rooted to the floor.')
    desk.add_adjectives('carved', 'oak')
    desk.set_prepositions('on', 'onto', 'in', 'into')
    desk.set_max_weight_carried(4e9)
    desk.set_max_volume_carried(80)

    paper_one = gametools.clone('domains.school.school.paper_one')
    paper_two = gametools.clone('domains.school.school.paper_two')
    paper_three = gametools.clone('domains.school.school.paper_three')
    desk.insert(paper_one, True)
    desk.insert(paper_two, True)
    desk.insert(paper_three, True)

    return desk
예제 #26
0
    def __find_add_structs_dictionaries_arrays(self, args,
                                               multiple_return_name):
        """This is called for each method, signal, and property. With Android as
        the target readable properties and methods that have multiple return values
        a structure must be created that contains all of the return values. Hence
        if multiple_return_name is not None and the target is Android then find
        such arguments and if necessary create the structure and add it to the
        list of structures with that name."""

        out_args = []

        target_is_android = common.target_language == "android"

        if args is not None:
            for a in args:
                a.interface = self
                if a.references_named_type():
                    continue
                if a.is_structure():
                    self.__name_and_extract_struct(a)
                elif a.is_dictionary():
                    self.__name_and_extract_dictionary(a)

                if target_is_android and multiple_return_name and a.direction == "out":
                    out_args.append(a)

        if len(out_args) > 1:
            signature = "("

            for a in out_args:
                signature += a.arg_type

            signature += ")"

            return_structure_name = multiple_return_name + return_suffix
            c = container.Container(signature, return_structure_name)
            self.structures[return_structure_name] = c

        return
예제 #27
0
def generate_player(tree, player_class):
    """
    Generates player in random room

    Args:
        player_class (String): Name of player class
        tree (BSP tree): Tree representing rooms
    """
    room = random.choice(tree.root.child_room_list)
    x1, y1, x2, y2 = room.coords
    x = random.randint(x1, x2)
    y = random.randint(y1, y2)
    player_container = container.Container(inventory=[])
    player_com = creature.Creature(player_class,
                                   team="player",
                                   load_equip_scheme=True)
    player = entity.Entity(x,
                           y,
                           player_class,
                           creature=player_com,
                           container=player_container)
    return player
예제 #28
0
        return value, False


def askOptPrint():
    inputFromBoard = input('Would you like to print results? Y|N: ')
    try:

        _value = str(inputFromBoard)
        _value = _value.upper()
        if _value == "Y":
            return True
        if _value == "N":
            return False
        askOptPrint()

    except ValueError:
        print('Please type Y|N')
        askOptPrint()


if __name__ == "__main__":
    inputFromBoard = input('Please Type the Numbers of Board/Queens: ')
    numberOfQueens, ok = intTryParse(inputFromBoard)
    if ok:
        print('We are working on ', numberOfQueens, ' Queens')
        toPrint = askOptPrint()
        _container = container.Container(numberOfQueens, toPrint)
        _container.run()
    else:
        print('Please type a correct Int Number')
예제 #29
0
    def __init__(self, etcdclient, addr, port):
        self.addr = addr
        self.port = port
        logger.info("begin initialize on %s" % self.addr)

        self.fspath = env.getenv('FS_PREFIX')
        self.poolsize = env.getenv('DISKPOOL_SIZE')

        self.etcd = etcdclient
        self.master = self.etcd.getkey("service/master")[1]
        self.mode = None

        # waiting state is preserved for compatible.
        self.etcd.setkey("machines/runnodes/" + self.addr, "waiting")
        # get this node's key to judge how to init.
        [status, key] = self.etcd.getkey("machines/runnodes/" + self.addr)
        if status:
            self.key = generatekey("machines/allnodes/" + self.addr)
        else:
            logger.error("get key failed. %s" % 'machines/runnodes/' +
                         self.addr)
            sys.exit(1)

        # check token to check global directory
        [status, token_1] = self.etcd.getkey("token")
        tokenfile = open(self.fspath + "/global/token", 'r')
        token_2 = tokenfile.readline().strip()
        if token_1 != token_2:
            logger.error(
                "check token failed, global directory is not a shared filesystem"
            )
            sys.exit(1)
        logger.info("worker registered and checked the token")

        # worker search all run nodes to judge how to init
        # If the node in all node list, we will recover it.
        # Otherwise, this node is new added in.
        value = 'init-new'
        [status, alllist] = self.etcd.listdir("machines/allnodes")
        for node in alllist:
            if node['key'] == self.key:
                value = 'init-recovery'
                break
        logger.info("worker start in " + value + " mode")

        Containers = container.Container(self.addr, etcdclient)
        if value == 'init-new':
            logger.info("init worker with mode:new")
            self.mode = 'new'
            # check global directory do not have containers on this worker
            [both, onlylocal, onlyglobal] = Containers.diff_containers()
            if len(both + onlyglobal) > 0:
                logger.error(
                    "mode:new will clean containers recorded in global, please check"
                )
                sys.exit(1)
            [status, info] = Containers.delete_allcontainers()
            if not status:
                logger.error("delete all containers failed")
                sys.exit(1)
            # create new lvm VG at last
            new_group("docklet-group", self.poolsize,
                      self.fspath + "/local/docklet-storage")
            #subprocess.call([self.libpath+"/lvmtool.sh", "new", "group", "docklet-group", self.poolsize, self.fspath+"/local/docklet-storage"])
        elif value == 'init-recovery':
            logger.info("init worker with mode:recovery")
            self.mode = 'recovery'
            # recover lvm VG first
            recover_group("docklet-group",
                          self.fspath + "/local/docklet-storage")
            #subprocess.call([self.libpath+"/lvmtool.sh", "recover", "group", "docklet-group", self.fspath+"/local/docklet-storage"])
            [status, meg] = Containers.check_allcontainers()
            if status:
                logger.info("all containers check ok")
            else:
                logger.info("not all containers check ok")
                #sys.exit(1)
        else:
            logger.error("worker init mode:%s not supported" % value)
            sys.exit(1)
        # initialize rpc
        # xmlrpc.server.SimpleXMLRPCServer(addr) -- addr : (ip-addr, port)
        # if ip-addr is "", it will listen ports of all IPs of this host
        logger.info("initialize rpcserver %s:%d" % (self.addr, int(self.port)))
        # logRequests=False : not print rpc log
        #self.rpcserver = xmlrpc.server.SimpleXMLRPCServer((self.addr, self.port), logRequests=False)
        self.rpcserver = ThreadXMLRPCServer((self.addr, int(self.port)),
                                            allow_none=True,
                                            logRequests=False)
        self.rpcserver.register_introspection_functions()
        self.rpcserver.register_instance(Containers)
        self.rpcserver.register_function(monitor.workerFetchInfo)
        # register functions or instances to server for rpc
        #self.rpcserver.register_function(function_name)

        # initialize the network
        # if worker and master run on the same node, reuse bridges
        #                     don't need to create new bridges
        if (self.addr == self.master):
            logger.info("master also on this node. reuse master's network")
        else:
            logger.info("initialize network")
            # 'docklet-br' of worker do not need IP Addr.
            #[status, result] = self.etcd.getkey("network/workbridge")
            #if not status:
            #    logger.error ("get bridge IP failed, please check whether master set bridge IP for worker")
            #self.bridgeip = result
            # create bridges for worker
            #network.netsetup("init", self.bridgeip)
            if self.mode == 'new':
                if netcontrol.bridge_exists('docklet-br'):
                    netcontrol.del_bridge('docklet-br')
                netcontrol.new_bridge('docklet-br')
            else:
                if not netcontrol.bridge_exists('docklet-br'):
                    logger.error("docklet-br not found")
                    sys.exit(1)
            logger.info("setup GRE tunnel to master %s" % self.master)
            #network.netsetup("gre", self.master)
            if not netcontrol.gre_exists('docklet-br', self.master):
                netcontrol.setup_gre('docklet-br', self.master)
예제 #30
0
    def create_and_run_containers(self):
        """Creates and runs app and (optionally) devappserver containers.

        This includes the creation of a new devappserver image, unless
        self.run_devappserver is False. If image_name isn't specified, an
        image is created for the application as well. Newly made containers
        are cleaned up, but newly made images are not.
        """

        if self.run_devappserver:
            # Devappserver must know APP_ID to properly interface with
            # services like datastore, blobstore, etc. It also needs
            # to know where to find the config file, which port to
            # run the proxy on, and which port to run the api server on.
            das_env = {
                'CLEAR_DATASTORE':
                self.clear_datastore,
                'PROXY_PORT':
                self.internal_proxy_port,
                'API_PORT':
                self.internal_api_port,
                'ADMIN_PORT':
                self.internal_admin_port,
                'CONFIG_FILE':
                os.path.join(self.das_offset, os.path.basename(self.conf_path))
            }

            if self.app_id:
                das_env['APP_ID'] = self.app_id

            devappserver_image = self.build_devappserver_image(
                devbase_image=self.devbase_image)
            devappserver_container_name = (self.make_timestamped_name(
                'devappserver', self.cur_time))

            port_bindings = {
                DEFAULT_APPLICATION_PORT: self.port,
                self.internal_admin_port: self.admin_port,
                self.internal_proxy_port: self.proxy_port,
            }
            if self.extra_ports:
                port_bindings.update(self.extra_ports)

            # The host_config specifies port bindings and volume bindings.
            # /storage is bound to the storage_path. Internally, the
            # devappserver writes all the db files to /storage. The mapping
            # thus allows these files to appear on the host machine. As for
            # port mappings, we only want to expose the application (via the
            # proxy), and the admin panel.
            devappserver_hconf = docker.utils.create_host_config(
                port_bindings=port_bindings,
                binds={
                    self.storage_path: {
                        'bind': '/storage'
                    },
                })

            self.devappserver_container = container.Container(self.dclient)
            self.devappserver_container.create(
                name=devappserver_container_name,
                image=devappserver_image,
                ports=port_bindings.keys(),
                volumes=['/storage'],
                host_config=devappserver_hconf,
                environment=das_env)

            self.devappserver_container.start()
            get_logger().info('Starting container: %s',
                              devappserver_container_name)

        # The application container needs several environment variables
        # in order to start up the application properly, as well as
        # look for the api server in the correct place. Notes:
        #
        # GAE_PARTITION is always dev for development modules.
        # GAE_LONG_APP_ID is the "application ID". When devappserver
        #     is invoked, it can be passed a "--application" flag. This
        #     application must be consistent with GAE_LONG_APP_ID.
        # API_HOST is 0.0.0.0 because application container runs on the
        #     same network stack as devappserver.
        # MODULE_YAML_PATH specifies the path to the app from the
        #     app directory

        # TODO (find in g3 and link to here via comment)
        app_env = {
            'API_HOST': '0.0.0.0',
            'API_PORT': self.internal_api_port,
            'GAE_LONG_APP_ID': self.app_id,
            'GAE_PARTITION': 'dev',
            'GAE_MODULE_INSTANCE': '0',
            'MODULE_YAML_PATH': os.path.basename(self.conf_path),
            'GAE_MODULE_NAME': 'default',  # TODO(gouzenko) parse app.yaml
            'GAE_MODULE_VERSION': '1',
            'GAE_SERVER_PORT': '8080',
            'USE_MVM_AGENT': 'true'
        }

        # Build from the application directory iff image_name is not
        # specified.
        app_image = self.image_name or self.build_app_image()
        app_container_name = self.make_timestamped_name(
            'test_app', self.cur_time)

        # If devappserver is running, hook up the app to it.
        if self.run_devappserver:
            network_mode = ('container:%s' %
                            self.devappserver_container.get_id())
            ports = port_bindings = None
        else:
            port_bindings = {DEFAULT_APPLICATION_PORT: self.port}
            ports = [DEFAULT_APPLICATION_PORT]
            network_mode = None

        app_hconf = docker.utils.create_host_config(
            port_bindings=port_bindings,
            binds={self.log_path: {
                'bind': '/var/log/app_engine'
            }},
        )

        self.app_container = container.ApplicationContainer(
            self.application_configuration, self.dclient)
        self.app_container.create(name=app_container_name,
                                  image=app_image,
                                  ports=ports,
                                  volumes=['/var/log/app_engine'],
                                  host_config=app_hconf,
                                  environment=app_env)

        # Start as a shared network container, putting the application
        # on devappserver's network stack. (If devappserver is not
        # running, network_mode is None).
        try:
            self.app_container.start(network_mode=network_mode)
        except utils.AppstartAbort:
            if self.run_devappserver:
                self.abort_if_not_running(self.devappserver_container)
            raise

        # Construct a pinger container and bind it to the application's network
        # stack. This will allow the pinger to attempt to connect to the
        # application's ports.
        pinger_name = self.make_timestamped_name('pinger', self.cur_time)
        self.pinger_container = container.PingerContainer(self.dclient)
        try:
            self.pinger_container.create(name=pinger_name,
                                         image=constants.PINGER_IMAGE)
        except utils.AppstartAbort:
            if not utils.find_image(constants.PINGER_IMAGE):
                raise utils.AppstartAbort('No pinger image found. '
                                          'Did you forget to run "appstart '
                                          'init"? ')
            raise

        try:
            self.pinger_container.start(network_mode='container:{}'.format(
                self.app_container.get_id()))
        except utils.AppstartAbort:
            self.abort_if_not_running(self.app_container)
            raise

        self.wait_for_start()
        self.app_container.stream_logs()