def test__save_config(self, init_config): modified_config = copy.deepcopy(cfg._default_conf)[ 'spotify_downloader'] modified_config['file_format'] = 'just_a_test' cfg.save_config(modified_config) config = cfg._get_config(init_config) assert config == modified_config
def ok_selected(self): """Executes when the OK button is selected. Args: None """ parent = self.parent() self.save_login = self.saveLoginCheckbox.isChecked() parent.token = self.loginTokenBox.text() parent.server_url = self.serverURLBox.currentText() parent.listing_url = self.listingURLBox.currentText() parent.show() # Save our settings if requested if self.saveLoginCheckbox.checkState() > 0: save_login = True keyring.set_password("vaultkee", str(parent.server_url), str(parent.token)) else: save_login = False config.save_config(self.serverURLBox.currentIndex(), self.listingURLBox.currentIndex(), save_login) # Save our URLs to cache server_urls = [ str(self.serverURLBox.itemText(i)) for i in range(self.serverURLBox.count()) ] listing_urls = [ str(self.listingURLBox.itemText(i)) for i in range(self.listingURLBox.count()) ] server_urls.append(str(parent.server_url)) listing_urls.append(str(parent.listing_url)) config.save_cache(server_urls, listing_urls, append=True) # Populate our main window with data from the server. error = populate_path_tree(parent.pathTreeWidget, parent.listing_url, parent.server_url, parent.token) if error: error_text = "ERROR: Could not populate the path viewer.\n" error_text += str(error) parent.error_dialog.textEdit.setText(error_text) parent.error_dialog.show() parent.secret_dialog.populate_paths()
def put_settings(): if not request.json or 'settings' not in request.json: abort(400, 'Error Saving settings: settings obligatory') log.info("Saving settings") try: config.save_config(request.json['settings']) config.init_config() return jsonify({'status': 'OK'}) except Exception: log.error("Error Saving settings", exc_info=True) abort(500, 'Error Saving settings')
def ok_selected(self): """Executes when the OK button is selected. Args: None """ parent = self.parent() self.save_login = self.saveLoginCheckbox.isChecked() parent.token = self.loginTokenBox.text() parent.server_url = self.serverURLBox.currentText() parent.listing_url = self.listingURLBox.currentText() parent.show() # Save our settings if requested if self.saveLoginCheckbox.checkState() > 0: save_login = True keyring.set_password("vaultkee", str(parent.server_url), str(parent.token)) else: save_login = False config.save_config(self.serverURLBox.currentIndex(), self.listingURLBox.currentIndex(), save_login) # Save our URLs to cache server_urls = [str(self.serverURLBox.itemText(i)) for i in range(self.serverURLBox.count())] listing_urls = [str(self.listingURLBox.itemText(i)) for i in range(self.listingURLBox.count())] server_urls.append(str(parent.server_url)) listing_urls.append(str(parent.listing_url)) config.save_cache(server_urls, listing_urls, append=True) # Populate our main window with data from the server. error = populate_path_tree(parent.pathTreeWidget, parent.listing_url, parent.server_url, parent.token) if error: error_text = "ERROR: Could not populate the path viewer.\n" error_text += str(error) parent.error_dialog.textEdit.setText(error_text) parent.error_dialog.show() parent.secret_dialog.populate_paths()
def test_save_config(): config.save_config() assert os.path.exists(config.get_config_path())
cfg.weighted_prediction = args.weighted_prediction assert ( cfg.test_annotations is not None ), "Annotations need to be specified either via commandline argument (--annotations) or config (test_annotations)." assert ( cfg.test_imagedir is not None ), "Imagedir needs to be specified either via commandline argument (--imagedir) or config (test_imagedir)." if not hasattr(cfg, "num_classes"): # infer number of classes with open(cfg.annotations) as f: NUM_CLASSES = len(json.load(f)["categories"]) cfg.num_classes = NUM_CLASSES pathlib.Path(args.outdir).mkdir(exist_ok=True, parents=True) save_config(cfg, args.outdir) print(cfg) print("Initializing model from checkpoint {}".format(args.checkpoint)) checkpoint = torch.load(args.checkpoint, map_location="cpu") model = Model.from_config(cfg) missing_keys, unexpected_keys = model.load_state_dict( checkpoint['model_state_dict'], strict=False) assert not missing_keys, "Checkpoint is missing keys required to initialize the model: {}".format( missing_keys) if len(unexpected_keys): print( "Checkpoint contains unexpected keys that were not used to initialize the model: " ) print(unexpected_keys)
Generate the reports """ # TODO: Load report generators dynamicaly logger.debug("Generating reports") report = JSONReport() report.generate_report(Loot.loot) report = TerminalReport() report.generate_report(Loot.loot) logger.debug("Finished generating reports") if __name__ == "__main__": init() logger = config.get_logger("Main") try: main() except NotImplementedError as e: logger.error(e) sys.exit(ExitCode.NotImplemented) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() tb = traceback.format_exception(exc_type, exc_value, exc_traceback) print(utils.error_message(), "Unknown error encountered ({ERR}) - please report this via Github\n{EXCEPTION}" .format(ERR=e.args[0], EXCEPTION="".join(tb))) sys.exit(ExitCode.UnknownError) finally: print() print(utils.normal_message(), "Thank you for using Lancer") config.save_config()