Ejemplo n.º 1
0
    def upload(self):
        """Post system data to the central server.

        Args:
            None

        Returns:
            None

        """
        # Get devicename
        devicename = socket.getfqdn()

        # Initialize key variables
        agent = Agent.Agent(self.config, devicename)

        if conf.CUSTOM:
            conf.custom_collection(agent)
        else:
            # Update agent with linux data
            data_linux.getall(agent)

        # Post data
        print(time.time())
        success = agent.post()
        # Purge cache if success is True
        if success is True:
            log.log2console(2000, "Successfully posted data to infoset-db")
            agent.purge()
Ejemplo n.º 2
0
def main():
    populationSize = 20
    population = []
    population = [
        ag.Agent('agent {:0>6d}'.format(n), 'male', 35 * ureg.year)
        for n in range(populationSize)
    ]

    tom = population[0]
    print(tom.age)
    print(tom.cardiacSystem.heart.biscupidValve.hasProlapse)

    return population
Ejemplo n.º 3
0
    def spawn_agent(self, location=None):
        """
		Create a new agent, adding it to the graph, connecting it to other agents.
		Only called from __init__ at the moment.
		"""
        #Generate a location if none was given, and use it to instantiate
        #the new agent.
        new_location = location or self.location_generator()
        new_agent = agt.Agent(new_location)

        #Add the new agent to the graph.
        self.graph.add_node(new_agent.ID, agent=new_agent)
        for ID, agent in self.agents.iteritems():
            #Create an link with probability = connectivity.
            if random.random() < self.connectivity:
                self.graph.add_edge(new_agent.ID, ID)

        #Add the new agent to the address dict. Doing this after adding it
        #to the graph means that no self-links are created.
        self.agents[new_agent.ID] = new_agent
        return new_agent
Ejemplo n.º 4
0
    def seed(self):
        def spice_seed(space: world.Space):
            sp = spice.Spice(random.randint(self.min_spice, self.max_spice),
                             self.min_spice, self.max_spice)
            space.spice = sp
            return sp

        self.world.seed(spice_seed)

        # assign agents to spaces
        to_assign = self.agents
        if to_assign > len(self.world.spaces):
            raise Exception("Too many agents to assign")
        while to_assign > 0:
            rand_index = random.randint(0, len(self.world.spaces) - 1)
            s = self.world.spaces[rand_index]
            if s.agent is None:
                a = agent.Agent(
                    s, random.randint(self.min_vision, self.max_vision))
                s.agent = a
                self.world.resources.add(a)
                to_assign -= 1
Ejemplo n.º 5
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.agt = mod_agent.Agent('test_agent_number_685848')