def __init__(self, configPath):
        self._instance = PyPfw.ParameterFramework(configPath)

        self._logger = PfwLogger()
        self._instance.setLogger(self._logger)
        # Disable the remote interface because we don't need it and it might
        # get in the way (e.g. the port is already in use)
        self._instance.setForceNoRemoteInterface(True)

        self._instance.start()
        self._instance.setTuningMode(True)
Exemplo n.º 2
0

class MyLogger(PyPfw.ILogger):
    def __init__(self):
        # Calling the base constructor is necessary: if you don't, MyLogger
        # won't be recognised as a derived class of PyPfw.ILogger
        super(MyLogger, self).__init__()

    def log(self, is_warning, log):
        log_func = logging.warning if is_warning else logging.info
        log_func(log)


logging.root.setLevel(logging.INFO)

pfw = PyPfw.ParameterFramework(sys.argv[1])

# warning: don't pass MyLogger() directly as argument to setLogger() or it will
# be garbage collected
mylogger = MyLogger()
pfw.setLogger(mylogger)

moodType = pfw.createSelectionCriterionType(False)
for numerical, literal in enumerate(["mad", "sad", "glad"]):
    moodType.addValuePair(numerical, literal)

mood = pfw.createSelectionCriterion("Mood", moodType)

ok, error = pfw.start()
if not ok:
    print("Error while starting the pfw: '{}'".format(error))
Exemplo n.º 3
0
            exit(1)

        parsed_edds.append((edd_file.name, root))

    # We need to modify the toplevel configuration file to account for differences
    # between development setup and target (installation) setup, in particular, the
    # TuningMode must be enforced, regardless of what will be allowed on the target
    with tempfile.NamedTemporaryFile(mode='w') as fake_toplevel_config:
        install_path = os.path.dirname(os.path.realpath(args.toplevel_config))
        hostConfig.configure(infile=args.toplevel_config,
                             outfile=fake_toplevel_config,
                             structPath=install_path)
        fake_toplevel_config.flush()

        # Create a new Pfw instance
        pfw = PyPfw.ParameterFramework(fake_toplevel_config.name)

        # create and inject all the criteria
        logging.info("Creating all criteria")
        for criterion in all_criteria:
            criterion_type = pfw.createSelectionCriterionType(
                criterion['inclusive'])

            for numerical, literal in enumerate(criterion['values']):
                if criterion['inclusive']:
                    # inclusive criteria are "bitfields"
                    numerical = 1 << numerical

                ok = criterion_type.addValuePair(numerical, literal)
                if not ok:
                    logging.critical("valuepair {}/{} rejected for {}".format(