How to use _parse_boolean method in localstack

Best Python code snippet using localstack_python

options.py

Source:options.py Github

copy

Full Screen

1import re2def _parse_list(value):3 return set([token.strip() for token in value.lower().split(',')])4def _parse_boolean(value):5 value = value.strip().lower()6 if value in ['true', 'yes', 'y']:7 return True8 if value in ['false', 'no', 'n']:9 return False10 return bool(int(value))11class Options(object):12 """13 Options object with its default settings.14 """15 def __init__(self):16 # Targets17 self.attach = list()18 self.console = list()19 self.windowed = list()20 self.service = list()21 # List options22 self.action = list()23 self.break_at = list()24 self.stalk_at = list()25 # Tracing options26 self.pause = False27 self.interactive = False28 self.time_limit = 029 self.echo = False30 self.action_events = ['exception', 'output_string']31 self.crash_events = ['exception', 'output_string']32 # Debugging options33 self.autodetach = True34 self.hostile = False35 self.follow = True36 self.restart = False37 # Output options38 self.verbose = True39 self.ignore_errors = False40 self.logfile = None41 self.database = None42 self.duplicates = True43 self.firstchance = False44 self.memory = 045 def read_config_file(self, config):46 """47 Read the configuration file48 """49 # Keep track of duplicated options50 opt_history = set()51 # Regular expression to split the command and the arguments52 regexp = re.compile(r'(\S+)\s+(.*)')53 # Open the config file54 with open(config, 'rU') as fd:55 number = 056 while 1:57 # Read a line58 line = fd.readline()59 if not line:60 break61 number += 162 # Strip the extra whitespace63 line = line.strip()64 # If it's a comment line or a blank line, discard it65 if not line or line.startswith('#'):66 continue67 # Split the option and its arguments68 match = regexp.match(line)69 if not match:70 msg = "cannot parse line %d of config file %s"71 msg = msg % (number, config)72 raise RuntimeError(msg)73 key, value = match.groups()74 # Targets75 if key == 'attach':76 if value:77 self.attach.append(value)78 elif key == 'console':79 if value:80 self.console.append(value)81 elif key == 'windowed':82 if value:83 self.windowed.append(value)84 elif key == 'service':85 if value:86 self.service.append(value)87 # List options88 elif key == 'break_at':89 self.break_at.extend(_parse_list(value))90 elif key == 'stalk_at':91 self.stalk_at.extend(_parse_list(value))92 elif key == 'action':93 self.action.append(value)94 # Switch options95 else:96 # Warn about duplicated options97 if key in opt_history:98 print("Warning: duplicated option %s in line %d"99 " of config file %s" % (key, number, config))100 print()101 else:102 opt_history.add(key)103 # Output options104 if key == 'verbose':105 self.verbose = _parse_boolean(value)106 elif key == 'logfile':107 self.logfile = value108 elif key == 'database':109 self.database = value110 elif key == 'duplicates':111 self.duplicates = _parse_boolean(value)112 elif key == 'firstchance':113 self.firstchance = _parse_boolean(value)114 elif key == 'memory':115 self.memory = int(value)116 elif key == 'ignore_python_errors':117 self.ignore_errors = _parse_boolean(value)118 # Debugging options119 elif key == 'hostile':120 self.hostile = _parse_boolean(value)121 elif key == 'follow':122 self.follow = _parse_boolean(value)123 elif key == 'autodetach':124 self.autodetach = _parse_boolean(value)125 elif key == 'restart':126 self.restart = _parse_boolean(value)127 # Tracing options128 elif key == 'pause':129 self.pause = _parse_boolean(value)130 elif key == 'interactive':131 self.interactive = _parse_boolean(value)132 elif key == 'time_limit':133 self.time_limit = int(value)134 elif key == 'echo':135 self.echo = _parse_boolean(value)136 elif key == 'action_events':137 self.action_events = _parse_list(value)138 elif key == 'crash_events':139 self.crash_events = _parse_list(value)140 # Unknown option141 else:142 msg = ("unknown option %s in line %d"143 " of config file %s") % (key, number, config)144 raise RuntimeError(msg)145 # Return the options object...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...56 path = self.get_argument("path", sickrage.app.config.general.tv_download_dir)57 nzb_name = self.get_argument("nzbName", None)58 process_method = self.get_argument("processMethod", ProcessMethod.COPY.name)59 proc_type = self.get_argument("type", 'manual')60 delete = self._parse_boolean(self.get_argument("delete", 'false'))61 failed = self._parse_boolean(self.get_argument("failed", 'false'))62 is_priority = self._parse_boolean(self.get_argument("isPriority", 'false'))63 return_data = self._parse_boolean(self.get_argument("returnData", 'false'))64 force_replace = self._parse_boolean(self.get_argument("forceReplace", 'false'))65 force_next = self._parse_boolean(self.get_argument("forceNext", 'false'))66 validation_errors = self._validate_schema(PostProcessSchema, self.request.arguments)67 if validation_errors:68 return self._bad_request(error=validation_errors)69 if not path and not sickrage.app.config.general.tv_download_dir:70 return self._bad_request(error={"path": "You need to provide a path or set TV Download Dir"})71 json_data = sickrage.app.postprocessor_queue.put(path, nzbName=nzb_name, process_method=ProcessMethod[process_method.upper()], force=force_replace,72 is_priority=is_priority, delete_on=delete, failed=failed, proc_type=proc_type, force_next=force_next)73 if 'Processing succeeded' not in json_data and 'Successfully processed' not in json_data:74 return self._bad_request(error=json_data)...

Full Screen

Full Screen

params.py

Source:params.py Github

copy

Full Screen

1from utilities import parse_arg2def _parse_boolean(name, required=False, default=False):3 boolean = parse_arg(name, default='t' if default else 'n', required=required)4 return False if 'n' == boolean else True5def _parse_int(name, required=False, default=None):6 integer = parse_arg(name, default=default, required=required)7 return int(integer) if integer is not None else None8gcs = parse_arg('--gcs', required=False)9use_gpu = parse_arg('--gpu', default='n', required=False)10start_epoch = int(parse_arg('--start-epoch', 0))11ckpt_dir = parse_arg('--ckpt-dir', None, required=False)12data_base_dir = parse_arg('--data-base-dir', '/Users/balazs/new_data')13model_checkpoint_dir = parse_arg('--model-dir', '/Users/balazs/university/tf_model')14restore_weights_dir = parse_arg('--restore-weights', required=False, default=None)15tensorboard_log_dir = parse_arg('--tb', None, required=False)16tensorboard_name = parse_arg('--tbn', "adam", required=False)17git_hexsha = parse_arg('--git-hexsha', 'NAN')18profiling = parse_arg('--profiling', default='n', required=False)19data_format = parse_arg('--data-format', default='channels_last')20if use_gpu == 'n':21 assert data_format == 'channels_last', "Only channels_last data format is availabel with CPU"22verbose_summary = _parse_boolean('--verbose-summary', default=False)23verbose = _parse_boolean('--verbose', default=False)24use_new_rnn = _parse_boolean('--new-rnn', default=False)25allow_soft_placement = _parse_boolean('--allow-soft-placement', default=False)26# Spatial transformer parameters27use_spatial_transformer = _parse_boolean('--st', default=False)28if use_spatial_transformer:29 assert data_format == 'channels_last', 'Only channels_last data format is compatible with spatial transformers'30overfit = _parse_boolean('--overfit', default=False)31patience = int(parse_arg('--patience', default=15))32batch_size = int(parse_arg('--batch-size', default=32))33allow_growth = _parse_boolean('--allow-growth', default=False)34epochs = int(parse_arg('--epochs', default=500))35epoch_per_validation = int(parse_arg('--epv', default=2))36validate_on_training = _parse_boolean("--vot", default=False)37device = '/cpu:0' if use_gpu == 'n' else '/gpu:{}'.format(use_gpu)38head = _parse_int('--head', default=None)39hidden_size = _parse_int('--hidden-size', default=None)40layers = _parse_int('--hidden-layers', default=None)41filter_size = _parse_int('--filter-size', default=None)42beta = float(parse_arg('--beta', default=0))43alpha = float(parse_arg('--alpha', default=0.6))44beam_size = _parse_int('--beam-size', default=6)45validate_only = _parse_boolean('--validate-only', default=False)46training_fname = parse_arg("--training-fname", default="training")47sparsemax = _parse_boolean("--sparsemax", default=False)48create_tex_files = parse_arg("--tex-files-dir", default=None)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful