def apply(self): level_name = self._levelCombo.get() levels = [ key for key, value in PreferencesDialog._LOG_LEVELS.items() if value == level_name ] loglevel = levels[0] logging_config = build_logging_config(['qiskit_acqua'], loglevel) token = self._apiToken.get().strip() url = self._url.get().strip() hub = self._hub.get().strip() group = self._group.get().strip() project = self._project.get().strip() preferences = Preferences() preferences.set_token(token if len(token) > 0 else None) preferences.set_url(url if len(url) > 0 else None) preferences.set_hub(hub if len(hub) > 0 else None) preferences.set_group(group if len(group) > 0 else None) preferences.set_project(project if len(project) > 0 else None) preferences.set_logging_config(logging_config) preferences.save() set_logger_config(logging_config) uipreferences = UIPreferences() populate = self._populateDefaults.get() uipreferences.set_populate_defaults(False if populate == 0 else True) uipreferences.save() self._controller.get_available_backends()
def apply(self): try: level_name = self._levelCombo.get() levels = [ key for key, value in PreferencesDialog._LOG_LEVELS.items() if value == level_name ] loglevel = levels[0] logging_config = build_logging_config(['qiskit_acqua'], loglevel) preferences = Preferences() self._qconfigview.apply(preferences) self._packagesPage.apply(preferences) preferences.set_logging_config(logging_config) preferences.save() set_logger_config(logging_config) uipreferences = UIPreferences() populate = self._populateDefaults.get() uipreferences.set_populate_defaults(False if populate == 0 else True) uipreferences.save() self._controller.get_available_backends() except Exception as e: self.controller.outputview.write_line(str(e))
def main(): parser = argparse.ArgumentParser( description='QISKit ACQUA Command Line Tool') parser.add_argument('input', metavar='input', help='Algorithm JSON input file') parser.add_argument('-jo', metavar='output', help='Algorithm JSON output file name', required=False) args = parser.parse_args() preferences = Preferences() if preferences.get_logging_config() is None: logging_config = build_logging_config(['qiskit_acqua'], logging.INFO) preferences.set_logging_config(logging_config) preferences.save() set_logger_config(preferences.get_logging_config()) params = None with open(args.input) as json_file: params = json.load(json_file) ret = run_algorithm(params, None, True) if args.jo is not None: with open(args.jo, 'w') as f: print('{}'.format(ret), file=f) else: convert_json_to_dict(ret) print( '\n\n--------------------------------- R E S U L T ------------------------------------\n' ) if isinstance(ret, dict): for k, v in ret.items(): print("'{}': {}".format(k, v)) else: print(ret)