def dump_tree(goal, depth=0):
    if goal.is_unique() or goal.is_empty():
        return
    next_goals = goal.next()
    for i, g in enumerate(next_goals):
        logger.debug( "  " * depth, print_goal(g, i+1))
        dump_tree(g, depth+1)
Пример #2
0
 def setupCredentials(self):
     """
     Create Credentials or Manage existing Credentials        
     """
     logger = self.getLoggerInstance()
     credentialConfig, status = self.loadCredentialInputs()
     if not status:
         return credentialConfig, False
     resCRE, statCRE = self.getResponse("GET", "Credential")
     creResponse = []
     for credential in credentialConfig:
         found = False
         if not statCRE and "No information found" in resCRE:
             found = False
         else:
             found = [
                 creList["credential"]["id"]
                 for creList in resCRE["credentialList"]
                 if creList["credential"]["label"] == credential["Name"]
             ]
         if not found:
             action = "POST"
             creId = ""
         else:
             action = "PUT"
             creId = found[0]
         resDC, statDC = self.defineCredential(credential, creId, action)
         creResponse.append(str(resDC))
         if not statDC:
             return creResponse, False
         if not found: creId = resDC["credential"]["id"]
         self.credentialMap[credential["Name"]] = creId
     logger.info(' credentialMap : ')
     logger.debug(self.credentialMap)
     return creResponse, True
Пример #3
0
    def test_cleanePublishedTemplates(self):

        response = self.cleanUpTemplates()
        logger = self.getLoggerInstance()
        logger.debug('Cleaning Published Template Response is')
        logger.info(response)
        self.log_data("Cleaning Published Template Response is :%s" %
                      str(response))
Пример #4
0
    def test_cleanDeployedTemplates(self):

        response = self.cleanUpServices()
        logger = self.getLoggerInstance()
        logger.debug('Cleaning Deployed  Services  Response is')
        logger.info(response)
        logger.info(response)
        self.log_data("Cleaning Deployed  Services  Response is :%s" %
                      str(response))
Пример #5
0
    def getAddOnModule(self):
        """
        Get list of  add on module         
        """
        logger = self.getLoggerInstance()
        resCRE, statCRE = self.getResponse("GET", "AddOnModule")

        logger.info('Add On Module : ')
        logger.debug(resCRE)
        return resCRE, True
def print_obj_refs(gcontext):
    olist = sorted(gcontext.problem.objects, key = lambda o: o.name)
    for o in olist:
        p = partitions.Partition.get_initial_partition(o.type, gcontext.refs)
        ref_entry = p.get_child_for_object(o)
        final_entry = None
        while ref_entry is not None and ref_entry != final_entry:
            final_entry = ref_entry
            ref_entry = ref_entry.expand_single(o)
        logger.debug(o + final_entry.text())
        logger.debug( final_entry.description())
Пример #7
0
 def getAddOnModuleById(self, refId=""):
     """
     Get list of  add on module         
     """
     logger = self.getLoggerInstance()
     response, status = self.getResponse("GET", "AddOnModule", refId=refId)
     if status:
         logger.info('Add On got successfully bye refId: ')
         logger.debug(response)
         self.log_data('Add On Module get successfully:')
         self.log_data('Payload:')
         self.log_data(response)
         return response, True
     else:
         "Please check URI not able to get add on module info", False
Пример #8
0
 def createAddOnModule(self):
     """
     Get list of  add on module         
     """
     logger = self.getLoggerInstance()
     payload = self.readFile(globalVars.addOnModulePayload)
     payload = payload.replace("$uploadUrl", globalVars.aDDOnModulePath)
     response, status = self.getResponse("POST", "AddOnModule", payload)
     if status:
         logger.info('Add On Module created successfully: ')
         logger.debug(response)
         self.log_data('Add On Module created successfully:')
         self.log_data('Payload:')
         self.log_data(payload)
         return response, True
     else:
         "Please check input value add on module not created", False
def interactive(gcontext, initial):
    logger.debug( "--------------")
    current_goal = None
    all_goals = []

    stack = []
    done=False
    while not done:
        # next_goals = current_goal.next()
        logger.debug( "current: " + current_goal)
        if current_goal is None:
            next_goals = initial
        else:
            next_goals = [g for g in current_goal.next_flattened() if not g.is_empty()]
        # next_goals = [g for g in current_goal.next() if not g.is_empty()]
        logger.debug("%d goals selected" % len(all_goals))
        for i, g in enumerate(next_goals):
            logger.debug(print_goal(g, i+1))
            # print map(str, g.all_partitions())

        c = raw_input().strip()
        if c == "d":
            for i, g in enumerate(next_goals):
                logger.debug( map(str, g.all_partitions()))
                logger.debug( g.dump_goal_stats())
        elif c == "q":
            exit(0)
        else:
            try:
                i = int(c)
                if i > 0 and i <= len(next_goals):
                    stack.append(current_goal)
                    current_goal = next_goals[i-1]
                    if current_goal.is_unique():
                        logger.debug( "selected")
                        all_goals.append(current_goal)
                        current_goal = None
                        stack = []
                else:
                    logger.warn( "invalid choice")
            except ValueError, e:
                if stack:
                    logger.debug("go back")
                    current_goal = stack.pop()
def create_goal_context():
    #print "The ROS argument is:", args.ros
    neurobots_dict = None
    if args.ros != False: # != False makes sure that processing --ros without parameters (an empty list) ends up in the second branch
        logger.info("Fetching problem from ROS database")
        import ros_database
        (prob,neurobots_dict) = ros_database.get_problem_from_database(dom)
    else:
        logger.info("Loading problem %s" % args.problem)
        prob = pddl.load_problem(args.problem, dom)
    logger.debug("REF: " + args.references)
    refs = reference_list.ReferenceList(prob, args.references)
    
    serialization_path = "/tmp/reference_list" if not args.serialized_partitions else (args.serialized_partitions[0])
    file_serialization = serialization_path + ".ser"
    file_serialization_hash = serialization_path + "_hash.ser"
    
    world_hash_ok = check_world_hash(file_serialization_hash, neurobots_dict)
    constants.WORLD_HASH_OK = world_hash_ok
    constants.SERIALIZATION_PATH = serialization_path
    
    if not world_hash_ok:
        create_world_hash_file(file_serialization_hash, neurobots_dict)
    
    if not constants.SERIALIZE_PARTITIONS or (constants.SERIALIZE_PARTITIONS and not refs.deserialize(file_serialization)):
        logger.debug("\033[93m atomic_partitions\033[0m")
        refs.create_atomic_partitions()
        logger.debug("\033[93m extended_partitions\033[0m")
        refs.create_extended_partitions()
        logger.debug("\033[93m optimistic_partitions\033[0m")
        refs.create_optimistic_partitions()
        if constants.SERIALIZE_PARTITIONS:
            refs.serialize(file_serialization)
            
    if args.refs:
        logger.debug("Refs...")
        logger.debug("refs: " + args.refs)
        if args.type is not None:
            types = [dom.types[args.type]]
            logger.debug("types:" + types)
        else:
            types = dom.types.itervalues()

        for t in types:
            logger.debug("\n")
            logger.debug(t + ":")
            for p in refs.type_partitions[t]:
                logger.debug( "     %.2f|%.2f:  %s" % (p.information(), p.information(potential=True), p))

            logger.debug( "   total I: ~%.2f" % refs.type_information[t])

        # for t in types:
        #     groups = refs.filter_groups(refs.groups, typ=t)
        #     if not groups:
        #         continue
        #     print t, ":"
        #     best = refs.get_best_groups(t)
        #     print "   ", refs.group_gain(best, typ=t), map(lambda x: map(str, x), best)
        #     print "\n"
        #     for g in refs.get_all_groups(t):
        #         I = refs.group_gain([g], typ=t)
        #         print "      ", I , map(str, g)
        exit(0)
    return (goals.GoalContext(prob, refs),neurobots_dict)
            try:
                typ = dom.types[tstr]
                current_partition = partitions.Partition.get_initial_partition(typ, gcontext.refs)
                next_partitions = current_partition.children[0].all_next()
                do_print = True
                # current_groups = list(refs.get_all_groups(typ))
            except KeyError:
                logger.error( "type not found")
                continue

        else:
            if do_print:
                logger.info( "-----------------------------------------------")
                for i, p in enumerate(next_partitions):
                    if p.information(potential=True) <= 0.0000001:
                        logger.debug( "%2d: !%s" % (i, p.dump_stats()))
                    else:
                        logger.debug( "%2d: %s" % (i, p.dump_stats()))
                do_print = False

            c = raw_input().strip()

            if c == "p":
                do_print = True
            if parse(c, "o", len(next_partitions)-1):
                _, i = parse(c, "o")
                p = next_partitions[i]
                for c in p.children:
                    logger.debug(c)
                    logger.debug("         %s", map(str, c.get_matches()))
Пример #12
0
 def test_cleanCredential(self):
     response = self.cleanCredential()
     logger = self.getLoggerInstance()
     logger.debug('Cleane Credential Response is')
     logger.info(response)
Пример #13
0
 def test_cleanNetwork(self):
     response = self.cleanNetwork()
     logger = self.getLoggerInstance()
     logger.debug('Cleane Network Response is')
     logger.info(response)
Пример #14
0
 def test_cleanManagedDevice(self):
     response = self.cleanManagedDevice()
     logger = self.getLoggerInstance()
     logger.debug('Cleane ManagedDevice Devices Response is')
     logger.info(response)
Пример #15
0
 def test_cleanDiscoveryDevice(self):
     response = self.cleanDiscovery()
     logger = self.getLoggerInstance()
     logger.debug('Cleane descovery Devices Response is')
     logger.info(response)
Пример #16
0
    def test_cleaneServerPool(self):

        response = self.cleanServerPool()
        logger = self.getLoggerInstance()
        logger.debug('Cleane Server Pool Response is')
        logger.info(response)