Python configparser.NoOptionError() Examples
The following are 30
code examples of configparser.NoOptionError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
configparser
, or try the search function
.
Example #1
Source File: train.py From yolo2-pytorch with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, env): super(SummaryWorker, self).__init__() self.env = env self.config = env.config self.queue = multiprocessing.Queue() try: self.timer_scalar = utils.train.Timer(env.config.getfloat('summary', 'scalar')) except configparser.NoOptionError: self.timer_scalar = lambda: False try: self.timer_image = utils.train.Timer(env.config.getfloat('summary', 'image')) except configparser.NoOptionError: self.timer_image = lambda: False try: self.timer_histogram = utils.train.Timer(env.config.getfloat('summary', 'histogram')) except configparser.NoOptionError: self.timer_histogram = lambda: False with open(os.path.expanduser(os.path.expandvars(env.config.get('summary_histogram', 'parameters'))), 'r') as f: self.histogram_parameters = utils.RegexList([line.rstrip() for line in f]) self.draw_bbox = utils.visualize.DrawBBox(env.category) self.draw_feature = utils.visualize.DrawFeature()
Example #2
Source File: protocol.py From rucio with Apache License 2.0 | 6 votes |
def _module_init_(cls): """ Initialize the class object on first module load. """ cls.register(cls.__hash, "hash") cls.register(cls.__identity, "identity") cls.register(cls.__ligo, "ligo") cls.register(cls.__belleii, "belleii") policy_module = None try: policy_module = config.config_get('policy', 'lfn2pfn_module') except (NoOptionError, NoSectionError): pass if policy_module: # TODO: The import of importlib is done like this due to a dependency issue with python 2.6 and incompatibility of the module with py3.x # More information https://github.com/rucio/rucio/issues/875 import importlib importlib.import_module(policy_module) cls._DEFAULT_LFN2PFN = config.get_lfn2pfn_algorithm_default()
Example #3
Source File: optionparser.py From securityheaders with Apache License 2.0 | 6 votes |
def __add_checks__(self, appconfig, result): checks = [] unwanted = [] for checker in appconfig.sections(): if "checker" in checker.lower() or "collector" in checker.lower(): try: enabled=not strtobool(appconfig.get(checker, 'disabled')) except NoOptionError: enabled=True try: enabled=strtobool(appconfig.get(checker, 'enabled')) except NoOptionError: enabled=True if enabled: checks.append(checker) else: unwanted.append(checker) result['checks'] = checks result['unwanted'] = unwanted
Example #4
Source File: crypt.py From pgrepup with GNU General Public License v3.0 | 6 votes |
def _get_key(): if this.key: return this.key secret = getpass.getpass() try: salt = config().get('Security', 'salt') except NoOptionError: salt = base64.urlsafe_b64encode(os.urandom(16)) config().set('Security', 'salt', salt) kdf = PBKDF2HMAC( algorithm=hashes.SHA256(), length=32, salt=salt, iterations=100000, backend=default_backend() ) this.key = base64.urlsafe_b64encode(kdf.derive(secret)) return this.key
Example #5
Source File: wlt_2_updateconfig.py From WLANThermo_v2 with GNU General Public License v3.0 | 6 votes |
def config_write(configfile, config, oldconfig): # Schreibt das Configfile # Ein Lock sollte im aufrufenden Programm gehalten werden! tmp_filename = get_random_filename(configfile) with codecs.open(tmp_filename, 'w', 'utf_8') as new_ini: for section_name in config.sections(): new_ini.write(u'[{section_name}]\n'.format(section_name=section_name)) for (key, value) in config.items(section_name): try: new_ini.write(u'{key} = {value}\n'.format(key=key, value=update_settings(section_name, key, oldconfig.get(section_name, key)))) except (configparser.NoSectionError, configparser.NoOptionError): new_ini.write(u'{key} = {value}\n'.format(key=key, value=value)) new_ini.write('\n') new_ini.flush() os.fsync(new_ini.fileno()) new_ini.close() os.rename(tmp_filename, configfile)
Example #6
Source File: versioneer.py From confusable_homoglyphs with MIT License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #7
Source File: config.py From IDEA with MIT License | 6 votes |
def __get_attr(cls, attr_type, section, option): """ :param attr_type: can be int, float, str, bool :param section: :param option: :return: """ result = None try: if attr_type is int: result = cls.Parser.getint(section=section, option=option) elif attr_type is float: result = cls.Parser.getfloat(section=section, option=option) elif attr_type is bool: result = cls.Parser.getfloat(section=section, option=option) elif attr_type is str: result = cls.Parser.getfloat(section=section, option=option) except configparser.NoOptionError: pass return result
Example #8
Source File: versioneer.py From landmarkerio-server with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #9
Source File: versioneer.py From recordlinkage with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #10
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: Value of option in section [conf/stanza]. :rtype: ``string`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The section does not exist. - The section exists but the option does not exist. ''' try: return self._cfg.get('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #11
Source File: ta_data_loader.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def _read_default_settings(): cur_dir = op.dirname(op.abspath(__file__)) setting_file = op.join(cur_dir,"../../","splunktalib", "setting.conf") parser = configparser.ConfigParser() parser.read(setting_file) settings = {} keys = ("process_size", "thread_min_size", "thread_max_size", "task_queue_size") for option in keys: try: settings[option] = parser.get("global", option) except configparser.NoOptionError: settings[option] = -1 try: settings[option] = int(settings[option]) except ValueError: settings[option] = -1 log.logger.debug("settings: %s", settings) return settings
Example #12
Source File: versioneer.py From wg-gesucht-crawler-cli with MIT License | 6 votes |
def get_config_from_root(root): # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #13
Source File: train.py From yolo2-pytorch with GNU Lesser General Public License v3.0 | 6 votes |
def get_loader(self): paths = [os.path.join(self.cache_dir, phase + '.pkl') for phase in self.config.get('train', 'phase').split()] dataset = utils.data.Dataset( utils.data.load_pickles(paths), transform=transform.augmentation.get_transform(self.config, self.config.get('transform', 'augmentation').split()), one_hot=None if self.config.getboolean('train', 'cross_entropy') else len(self.category), shuffle=self.config.getboolean('data', 'shuffle'), dir=os.path.join(self.model_dir, 'exception'), ) logging.info('num_examples=%d' % len(dataset)) try: workers = self.config.getint('data', 'workers') if torch.cuda.is_available(): workers = workers * torch.cuda.device_count() except configparser.NoOptionError: workers = multiprocessing.cpu_count() collate_fn = utils.data.Collate( transform.parse_transform(self.config, self.config.get('transform', 'resize_train')), utils.train.load_sizes(self.config), maintain=self.config.getint('data', 'maintain'), transform_image=transform.get_transform(self.config, self.config.get('transform', 'image_train').split()), transform_tensor=transform.get_transform(self.config, self.config.get('transform', 'tensor').split()), dir=os.path.join(self.model_dir, 'exception'), ) return torch.utils.data.DataLoader(dataset, batch_size=self.args.batch_size * torch.cuda.device_count() if torch.cuda.is_available() else self.args.batch_size, shuffle=True, num_workers=workers, collate_fn=collate_fn, pin_memory=torch.cuda.is_available())
Example #14
Source File: train.py From yolo2-pytorch with GNU Lesser General Public License v3.0 | 6 votes |
def iterate(self, data): for key in data: t = data[key] if torch.is_tensor(t): data[key] = utils.ensure_device(t) tensor = torch.autograd.Variable(data['tensor']) pred = pybenchmark.profile('inference')(model._inference)(self.inference, tensor) height, width = data['image'].size()[1:3] rows, cols = pred['feature'].size()[-2:] loss, debug = pybenchmark.profile('loss')(model.loss)(self.anchors, norm_data(data, height, width, rows, cols), pred, self.config.getfloat('model', 'threshold')) loss_hparam = {key: loss[key] * self.config.getfloat('hparam', key) for key in loss} loss_total = sum(loss_hparam.values()) self.optimizer.zero_grad() loss_total.backward() try: clip = self.config.getfloat('train', 'clip') nn.utils.clip_grad_norm(self.inference.parameters(), clip) except configparser.NoOptionError: pass self.optimizer.step() return dict( height=height, width=width, rows=rows, cols=cols, data=data, pred=pred, debug=debug, loss_total=loss_total, loss=loss, loss_hparam=loss_hparam, )
Example #15
Source File: eval.py From yolo2-pytorch with GNU Lesser General Public License v3.0 | 6 votes |
def get_loader(self): paths = [os.path.join(self.cache_dir, phase + '.pkl') for phase in self.config.get('eval', 'phase').split()] dataset = utils.data.Dataset(utils.data.load_pickles(paths)) logging.info('num_examples=%d' % len(dataset)) size = tuple(map(int, self.config.get('image', 'size').split())) try: workers = self.config.getint('data', 'workers') except configparser.NoOptionError: workers = multiprocessing.cpu_count() collate_fn = utils.data.Collate( transform.parse_transform(self.config, self.config.get('transform', 'resize_eval')), [size], transform_image=transform.get_transform(self.config, self.config.get('transform', 'image_test').split()), transform_tensor=transform.get_transform(self.config, self.config.get('transform', 'tensor').split()), ) return torch.utils.data.DataLoader(dataset, batch_size=self.args.batch_size, num_workers=workers, collate_fn=collate_fn)
Example #16
Source File: config.py From rucio with Apache License 2.0 | 6 votes |
def config_get_bool(section, option, raise_exception=True, default=None): """ Return the boolean value for a given option in a section :param section: the named section. :param option: the named option. :param raise_exception: Boolean to raise or not NoOptionError or NoSectionError. :param default: the default value if not found. . :returns: the configuration value. """ try: return get_config().getboolean(section, option) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as err: if raise_exception: raise err if default is None: return default return bool(default)
Example #17
Source File: droidconfig.py From droidlysis with MIT License | 6 votes |
def match_properties(self, match, properties): ''' Call this when the recursive search has been done to analyze the results and understand which properties have been spotted. match: returned by droidutil.recursive_search. This is a dictionary of matching lines ordered by matching keyword (pattern) properties: dictionary of properties where the key is the property name and the value will be False/True if set or not throws NoSessionError, NoOptionError ''' for section in self.configparser.sections(): pattern_list = self.configparser.get(section, 'pattern').split('|') properties[section] = False for pattern in pattern_list: if match[pattern]: if self.verbose: print( "Setting properties[%s] = True (matches %s)" % (section, pattern)) properties[section] = True break
Example #18
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get_float(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section as a float. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: A float value. :rtype: ``float`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The stanza exists but the value does not exist (perhaps having never been updated). - The stanza does not exist. - The value exists but cannot be converted to a float. ''' try: return self._cfg.getfloat('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #19
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: Value of option in section [conf/stanza]. :rtype: ``string`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The section does not exist. - The section exists but the option does not exist. ''' try: return self._cfg.get('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #20
Source File: metadata.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def get_float(self, conf, stanza, option): '''Return the metadata value of option in [conf/stanza] section as a float. :param conf: Conf name. :type conf: ``string`` :param stanza: Stanza name. :type stanza: ``string`` :param option: Option name in section [conf/stanza]. :type option: ``string`` :returns: A float value. :rtype: ``float`` :raises ValueError: Raises ValueError if the value cannot be determined. Note that this can occur in several situations: - The stanza exists but the value does not exist (perhaps having never been updated). - The stanza does not exist. - The value exists but cannot be converted to a float. ''' try: return self._cfg.getfloat('/'.join([conf, stanza]), option) except (NoSectionError, NoOptionError): raise ValueError('The metadata value could not be determined.')
Example #21
Source File: policy.py From rucio with Apache License 2.0 | 5 votes |
def get_policy(): policy = REGION.get('policy') if isinstance(policy, NoValue): try: policy = config_get('policy', 'permission') except (NoOptionError, NoSectionError): policy = 'atlas' REGION.set('policy', policy) return policy
Example #22
Source File: versioneer.py From bitmask-dev with GNU General Public License v3.0 | 5 votes |
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #23
Source File: versioneer.py From filesystem_spec with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #24
Source File: versioneer.py From vpython-jupyter with MIT License | 5 votes |
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg, "r") as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
Example #25
Source File: rule.py From rucio with Apache License 2.0 | 5 votes |
def generate_email_for_rule_ok_notification(rule, session=None): """ Generate (If necessary) an eMail for a rule with notification mode Y. :param rule: The rule object. :param session: The Database session """ session.flush() if rule.state == RuleState.OK and rule.notification == RuleNotification.YES: try: with open('%s/rule_ok_notification.tmpl' % config_get('common', 'mailtemplatedir'), 'r') as templatefile: template = Template(templatefile.read()) email = get_account(account=rule.account, session=session).email if email: text = template.safe_substitute({'rule_id': str(rule.id), 'created_at': str(rule.created_at), 'expires_at': str(rule.expires_at), 'rse_expression': rule.rse_expression, 'comment': rule.comments, 'scope': rule.scope.external, 'name': rule.name, 'did_type': rule.did_type}) add_message(event_type='email', payload={'body': text, 'to': [email], 'subject': '[RUCIO] Replication rule %s has been succesfully transferred' % (str(rule.id))}, session=session) except (IOError, NoOptionError): pass
Example #26
Source File: policy.py From rucio with Apache License 2.0 | 5 votes |
def get_lifetime_policy(): lifetime_dict = REGION.get('lifetime_dict') if isinstance(lifetime_dict, NoValue): lifetime_dict = {'data': [], 'mc': [], 'valid': [], 'other': []} try: lifetime_dir = config_get('lifetime', 'directory') except (NoSectionError, NoOptionError): lifetime_dir = '/opt/rucio/etc/policies' for dtype in ['data', 'mc', 'valid', 'other']: input_file_name = '%s/config_%s.json' % (lifetime_dir, dtype) if os.path.isfile(input_file_name): with open(input_file_name, 'r') as input_file: lifetime_dict[dtype] = json.load(input_file) REGION.set('lifetime_dict', lifetime_dict) return lifetime_dict
Example #27
Source File: test_rse_lfn2path.py From rucio with Apache License 2.0 | 5 votes |
def test_config_default_override(self): """LFN2PFN: Test override of default LFN2PFN algorithm via config (Success)""" if not config.config_has_section('policy'): config.config_add_section('policy') try: orig_value = config.config_get('policy', 'lfn2pfn_algorithm_default') except (NoOptionError, NoSectionError): orig_value = None def static_test(scope, name, rse, rse_attrs, proto_attrs): """Static test function for config override.""" del scope del name del rse del rse_attrs del proto_attrs return "static_test_value" RSEDeterministicTranslation.register(static_test) try: config.config_set('policy', 'lfn2pfn_algorithm_default', 'static_test') RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access assert_equal(self.translator.path("foo", "bar"), "static_test_value") finally: if orig_value is None: config.config_remove_option('policy', 'lfn2pfn_algorithm_default') else: config.config_set('policy', 'lfn2pfn_algorithm_default', orig_value) RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access
Example #28
Source File: policy.py From rucio with Apache License 2.0 | 5 votes |
def get_scratchdisk_lifetime(): scratchdisk_lifetime = REGION.get('scratchdisk_lifetime') if isinstance(scratchdisk_lifetime, NoValue): try: scratchdisk_lifetime = config_get('policy', 'scratchdisk_lifetime') scratchdisk_lifetime = int(scratchdisk_lifetime) except (NoOptionError, NoSectionError, ValueError): scratchdisk_lifetime = 14 REGION.set('scratchdisk_lifetime', scratchdisk_lifetime) return scratchdisk_lifetime
Example #29
Source File: config.py From rucio with Apache License 2.0 | 5 votes |
def get_lfn2pfn_algorithm_default(): """Returns the default algorithm name for LFN2PFN translation for this server.""" default_lfn2pfn = "hash" try: default_lfn2pfn = config_get('policy', 'lfn2pfn_algorithm_default') except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): pass return default_lfn2pfn
Example #30
Source File: config.py From rucio with Apache License 2.0 | 5 votes |
def config_get_int(section, option, raise_exception=True, default=None): """Return the integer value for a given option in a section""" try: return get_config().getint(section, option) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as err: if raise_exception and default is None: raise err return default