def __init__(self, *args, **kwargs): self.log = set_up_logger(self.module_name, stdout=kwargs.get("stdout")) self.import_dir = kwargs.get("dir") if not self.import_dir: self.import_dir = self.create_import_dir() else: self.log.debug("Using pre-existing import dir: {}".format(self.import_dir))
def __init__(self, api_url, api_key, verbose=False): self.logger = set_up_logger("searcharr.radarr", verbose, False) self.logger.debug("Logging started!") if api_url[-1] == "/": api_url = api_url[:-1] if api_url[:4] != "http": self.logger.error( "Invalid Radarr URL detected. Please update your settings to include http:// or https:// on the beginning of the URL." ) self.api_url = api_url + "/api/{endpoint}?apikey=" + api_key
def __init__(self, *args, **kwargs): self.log = set_up_logger(self.module_name, stdout=kwargs.get('stdout')) self.import_dir = kwargs.get('dir') if not self.import_dir: self.import_dir = self.create_import_dir() else: self.log.debug('Using pre-existing import dir: {}'.format( self.import_dir))
def __init__(self, api_url, api_key, verbose=False): self.logger = set_up_logger("searcharr.radarr", verbose, False) self.logger.debug("Logging started!") if api_url[-1] == "/": api_url = api_url[:-1] if api_url[:4] != "http": self.logger.error( "Invalid Radarr URL detected. Please update your settings to include http:// or https:// on the beginning of the URL." ) self.radarr_version = self.discover_version(api_url, api_key) if not self.radarr_version.startswith("0."): self.api_url = api_url + "/api/v3/{endpoint}?apikey=" + api_key self._quality_profiles = self.get_all_quality_profiles() self._root_folders = self.get_root_folders()
def __init__(self, api_url, auth_data=None, token=None, session_options=None, root_logger=None, log_level=None, show_auth_data=False): '''Manager constructor. -> SaltRESTManager Check the Salt's API documentation for auth data and token dictionary structure reference. Check the Request's API documentation for possible session options (like disabling SSL certificate checking or supplying custom certificates). Arguments: * api_url = a mandatory URL to Salt REST API, * auth_data = an optional dictionary containing proper authorisation data accepted by Salt `login' API call, * token = an optional dictionary returned by Salt `login' API call, * session_options = an optional dictionary containing session options, * logger = if supplied, a child logger will be created to dump debug information, * log_level = an optional log level to be set: can be either a string or a predefined int from the `logging' library, * show_auth_data = optionally the manager can be configured not to cover auth data. ''' self._session = None self._api_url = api_url self._auth_data = auth_data self._session_options = session_options self._show_auth_data = show_auth_data self.token = token self.logger = log.set_up_logger(root_logger, log_level)
def __init__(self, processing_dir, config=FEC_CONFIG): self.processing_dir = os.path.expanduser(processing_dir) self.FEC_CONFIG = config self.log = set_up_logger("fec_importer", self.processing_dir, "Unhappy FEC Importer")
args.interpretation_type, time_prediction_type=args.time_prediction_type) bs = 128 dataset.set_batch_size(bs) dataset.initialize() dataset.reset() # src_1_emb_cut, src_2_emb_cut, dst_emb_cut = dealData(src_l, dst_l, ts_l, dataset.train_src_1, dataset.train_src_2, dataset.train_dst, dataset.train_ts) # src_1_emb_cut, src_2_emb_cut, dst_emb_cut = torch.from_numpy(src_1_emb_cut).to(device).float(), torch.from_numpy(src_2_emb_cut).to(device).float(), torch.from_numpy(dst_emb_cut).to(device).float() # print(src_1_emb_cut) # print(src_2_emb_cut) # print(dst_emb_cut) logger, get_checkpoint_path, best_model_path = set_up_logger(args, sys_argv) criterion = torch.nn.CrossEntropyLoss() optimizer = torch.optim.Adam(model.parameters(), lr=LEARNING_RATE) early_stopper = EarlyStopMonitor(tolerance=1e-3) n_nodes = len(dataset.set_all_nodes) train_val(dataset, model, args.mode, args.bs, args.n_epoch, criterion, optimizer, early_stopper,
try: with DBLOCK: cur.execute(q) except sqlite3.Error as e: logger.error(f"Error executing database query [{q}]: {e}") raise q = """CREATE TABLE IF NOT EXISTS users ( id integer primary key, username text not null, admin text, permissions text );""" logger.debug(f"Executing query: [{q}] with no args...") try: with DBLOCK: cur.execute(q) except sqlite3.Error as e: logger.error(f"Error executing database query [{q}]: {e}") raise con.commit() con.close() if __name__ == "__main__": args = parse_args() logger = set_up_logger("searcharr", args.verbose, args.console_logging) tgr = Searcharr(settings.tgram_token) tgr.run()