def testGlobalInstances(self, name=None): p = configargparse.getArgumentParser(name, prog="prog", usage="test") self.assertEqual(p.usage, "test") self.assertEqual(p.prog, "prog") self.assertRaisesRegex(ValueError, "kwargs besides 'name' can only be " "passed in the first time", configargparse.getArgumentParser, name, prog="prog") p2 = configargparse.getArgumentParser(name) self.assertEqual(p, p2)
def init_command_line_args(): p = configargparse.getArgumentParser() # usage="usage: %prog [options] [arg1] .. ") #p.add("--LSF", dest="use_LSF", action="store_true", help="Execute each command as an LSF job.") #p.add("--SGE", dest="use_SGE", action="store_true", help="Execute each command as an SGE job.") p.add("-t", "--test", dest="is_test", action="store_true", help="Prints all commands without " "actually running them. -t overrides all other options (eg. -f, -F).") p.add("-F", "--force_all", dest="should_force_all", action="store_true", help="Forces execution of all commands " "even if their output files are up to date.") p.add("-f", "--force", dest="force_these", action="append", help="Forces execution of specific step(s) " "(-f 1.1 or -f myscript) even if their output files are up to date.") p.add("-o", "--only", dest="only_these", action="append", help="Only execute commands matching the " "given pattern (eg. -o 1.3 or -o myscript). -o can be specified more than once to run several specific " "commands and nothing else. -o can be used with -f, -F to force the execution of the given command(s).") p.add("-b", "--begin", dest="begin_with_these", action="append", help="Execute commands starting at this " "command (eg. -b 1.3 or -b myscript). -b can be specified more than once, in which case they are OR'd " "together. -b can be used together with -e and/or -f, -F to execute a specific subset of commands.") p.add("-e", "--end", dest="end_with_these", action="append", help="Execute commands up to and including this " "command (eg. -e 1.3 or -e myscript). -e can be specified more than once, in which case they are OR'd " "together. -e can be used together with -b and/or -f, -F to execute a specific subset of commands.") p.add("-p", "--num_processes", type=int, help="Number of Jobs to run in parallel. Default: unlimited. " "For example, if 4 Jobs are added via job_runner.add_parallel(..), and then the pipeline is run with -p 3, " "then 3 of the 4 jobs will be launched right away in parallel, and the 4th job will be launched as soon as " "one of the 3 completes.", default=1)
def get_config(): p = configargparse.getArgumentParser(default_config_files=[ os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini' ]) add_arguments(p) parsed_config, _ = p.parse_known_args() if not parsed_config.safe_mode: logging.warning( 'Your app is configured to skip the wifi check when the USB is plugged in. Read the ' 'documentation to ensure this is what you want, since this is less secure' ) # overwrite with enum parsed_config.bitcoin_chain = Chain.parse_from_chain( parsed_config.bitcoin_chain) if parsed_config.bitcoin_chain == Chain.mocknet or parsed_config.bitcoin_chain == Chain.regtest: parsed_config.bitcoin_chain_for_pycoin = Chain.testnet else: parsed_config.bitcoin_chain_for_pycoin = parsed_config.bitcoin_chain bitcoin.SelectParams(parsed_config.bitcoin_chain_for_pycoin.name) configure_logger() return parsed_config
def load_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser( description='Allows to revoke certificates or complete batches or ' 'even future uses of issuing addresses. All revoked ' 'certificates need to be part of the same transaction.', default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') group = p.add_mutually_exclusive_group(required='True') group.add_argument('-s', '--address', action='store_true', help='revoke the issuing_address (from config file)') group.add_argument('-b', '--batch', type=str, help='revoke a whole batch identified by its transaction id') group.add_argument('-p', nargs='+', help='a list of certificate pdf files to revoke') p.add_argument('-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this') p.add_argument('-a', '--issuing_address', type=str, help='the issuing address with enough funds for the transaction; assumed to be imported in local node wallet') p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument('-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-w', '--full_node_rpc_password', type=str, help='the rpc password as specified in the node\'s configuration') p.add_argument('-l', '--blockchain', type=str, default='bitcoin', help='choose blockchain; currently bitcoin or litecoin') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') args, _ = p.parse_known_args() return args
def test_multiple_parse_known_args(self): non_existent_config_files = ["/blah/foo.conf", "/usr/bin/ba.conf"] cap = configargparse.getArgumentParser( prog="UnitTest", description="unit testing", formatter_class=configargparse.ArgumentDefaultsHelpFormatter, default_config_files=non_existent_config_files, args_for_setting_config_path=["-c", "--config"], ) cap.add( "--variant", help="Specifies which variant of the config should be used. Use the config name without the .conf", default="debug", ) parsed_args = cap.parse_known_args() add_to_parser_in_func() cap.add( "-c", "--cfg", is_config_file=True, help="Manually specify the config file path if you want to override the variant default", ) parsed_args = cap.parse_known_args(args=["--variant", "release"])
def get_config(): p = configargparse.getArgumentParser(default_config_files=[ os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini' ]) add_arguments(p) parsed_config, _ = p.parse_known_args() if not parsed_config.safe_mode: logging.warning( 'Your app is configured to skip the wifi check when the USB is plugged in. Read the ' 'documentation to ensure this is what you want, since this is less secure' ) if parsed_config.wallet_connector_type == 'bitcoind': bitcoin.SelectParams(parsed_config.bitcoin_chain) if parsed_config.bitcoin_chain == 'mainnet': parsed_config.netcode = 'BTC' else: parsed_config.netcode = 'XTN' configure_logger() set_fee_per_trx(parsed_config.tx_fee) set_satoshi_per_byte(parsed_config.satoshi_per_byte) set_min_per_output(parsed_config.dust_threshold) return parsed_config
def _hunter_is_not_order_dependent(precall): samplesdir = uth.samplesdir() relativepaths = [ 'factory/test_factory.cpp', 'numbers/test_direct_include.cpp', 'simple/helloworld_c.c', 'simple/helloworld_cpp.cpp', 'simple/test_cflags.c'] bulkpaths = [os.path.join(samplesdir, filename) for filename in relativepaths] temp_config = ct.unittesthelper.create_temp_config() argv = [ '--config', temp_config, '--include', uth.ctdir()] + bulkpaths cap = configargparse.getArgumentParser() ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hntr = ct.hunter.Hunter(args, headerdeps, magicparser) os.unlink(temp_config) realpath = os.path.join(samplesdir, 'dottypaths/dottypaths.cpp') if precall: result = hntr.required_source_files(realpath) return result else: for filename in bulkpaths: discard = hntr.required_source_files(filename) result = hntr.required_source_files(realpath) return result
def test_hunter_follows_source_files_from_header(self): origcache = ct.dirnamer.user_cache_dir('ct') tempdir = tempfile.mkdtemp() _reload_ct(tempdir) temp_config = ct.unittesthelper.create_temp_config() argv = [ '-c', temp_config, '--include', uth.ctdir()] cap = configargparse.getArgumentParser() ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hntr = ct.hunter.Hunter(args, headerdeps, magicparser) relativepath = 'factory/widget_factory.hpp' realpath = os.path.join(uth.samplesdir(), relativepath) filesfromheader = hntr.required_source_files(realpath) filesfromsource = hntr.required_source_files( ct.utils.implied_source(realpath)) self.assertSetEqual(filesfromheader, filesfromsource) # Cleanup os.unlink(temp_config) shutil.rmtree(tempdir) _reload_ct(origcache)
def setUp(self): uth.reset() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def build_arg_parser(): p = configargparse.getArgumentParser( prog='index_ccdb', description='fill Elasticsearch with public complaint data', ignore_unknown_config_file_keys=True, default_config_files=['./config.ini'], args_for_setting_config_path=['-c', '--config'], args_for_writing_out_config_file=['--save-config']) p.add('--dump-config', action='store_true', dest='dump_config', help='dump config vars and their source') group = add_basic_es_arguments(p) group.add('--settings', required=True, help="Describes how the ES index should function") group.add('--mapping', required=True, help="Describes how process the input documents") group.add('--doc-type', dest='doc_type', default='complaint', help='Elasticsearch document type') group = p.add_argument_group('Files') group.add('--dataset', dest='dataset', required=True, help="Complaint data in NDJSON format") return p
def test_duplicateForced(self): parser = configargparse.getArgumentParser('pynYNAB') args = parser.parse_known_args()[0] args.schema = 'example' args.csvfile = os.path.join(gettempdir(), 'data.csv') args.accountname = None args.import_duplicates = True args.logginglevel = 'debug' content = """Date,Payee,Amount,Memo,Account 2016-02-01,Super Pants Inc.,-20,Buying pants,Cash """ with open(args.csvfile, mode='w') as f: f.writelines(content) transaction = self.getTr( datetime(year=2016, month=2, day=1).date(), 'Super Pants Inc.', -20, 'Buying pants', 'Cash') self.client.budget.be_transactions.append(transaction) schema = verify_csvimport(args) delta = do_csvimport(args, schema, self.client) self.assertEqual(delta, 1) self.assertEqual( sum(1 for tr in self.client.budget.be_transactions if tr.key2 == transaction.key2), 2)
def get_config(): base_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser( default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=True, is_config_file=True, help='config file path') p.add_argument( '-k', '--issuer_address', type=str, required=True, help= 'the issuer\'s Bitcoin address that will be used to issue the certificates' ) p.add_argument( '-r', '--revocation_address', type=str, required=True, help= 'the issuer\'s Bitcoin revocation address that can be used to revocate the certificates' ) p.add_argument( '-d', '--issuer_id', type=str, required=True, help= 'the issuer\'s publicly accessible identification file; i.e. URL of the file generated by this tool' ) p.add_argument('-u', '--issuer_url', type=str, help='the issuers main URL address') p.add_argument('-l', '--issuer_certs_url', type=str, help='the issuer\'s URL address of the certificates') p.add_argument('-n', '--issuer_name', type=str, help='the issuer\'s name') p.add_argument('-e', '--issuer_email', type=str, help='the issuer\'s email') p.add_argument('-m', '--issuer_logo_file', type=str, help='the issuer\' logo image') p.add_argument( '-o', '--output_file', type=str, help='the output file to save the issuer\'s identification file') args, _ = p.parse_known_args() return args
def get_config(): configure_logger() p = configargparse.getArgumentParser(default_config_files=[os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini']) add_arguments(p) parsed_config, _ = p.parse_known_args() if not parsed_config.safe_mode: logging.warning('Your app is configured to skip the wifi check when the USB is plugged in. Read the ' 'documentation to ensure this is what you want, since this is less secure') # overwrite with enum parsed_config.chain = Chain.parse_from_chain(parsed_config.chain) # ensure it's a supported chain if parsed_config.chain.blockchain_type != BlockchainType.bitcoin and \ parsed_config.chain.blockchain_type != BlockchainType.ethereum and \ parsed_config.chain.blockchain_type != BlockchainType.mock: raise UnknownChainError(parsed_config.chain.name) logging.info('This run will try to issue on the %s chain', parsed_config.chain.name) if parsed_config.chain.blockchain_type == BlockchainType.bitcoin: bitcoin_chain_for_python_bitcoinlib = parsed_config.chain if parsed_config.chain == Chain.bitcoin_regtest: bitcoin_chain_for_python_bitcoinlib = Chain.bitcoin_regtest bitcoin.SelectParams(chain_to_bitcoin_network(bitcoin_chain_for_python_bitcoinlib)) configure_logger() return parsed_config
def test_import(self): parser = configargparse.getArgumentParser('pynYNAB') args = parser.parse_known_args()[0] args.schema = 'example' args.csvfile = os.path.join(gettempdir(),'data.csv') args.accountname = None args.import_duplicates=False args.logginglevel = 'debug' content = """Date,Payee,Amount,Memo,Account 2016-02-01,Super Pants Inc.,-20,Buying pants,Cash 2016-02-02,Thai Restaurant,-10,Food,Checking Account 2016-02-03,,10,Saving!,Savings """ with open(args.csvfile, mode='w') as f: f.writelines(content) Transactions = [ self.getTr(datetime(year=2016, month=2, day=1).date(), 'Super Pants Inc.', -20, 'Buying pants', 'Cash'), self.getTr(datetime(year=2016, month=2, day=2).date(), 'Thai Restaurant', -10, 'Food', 'Checking Account'), self.getTr(datetime(year=2016, month=2, day=3).date(), '', 10, 'Saving!', 'Savings'), ] do_csvimport(args) self.reload() for tr in Transactions: print(json.dumps(tr, cls=ComplexEncoder)) print(json.dumps( [tr2 for tr2 in self.client.budget.be_transactions if tr2.amount == tr.amount], cls=ComplexEncoder)) self.assertTrue(self.client.budget.be_transactions.containsduplicate(tr))
def initialize(self): cwd = os.getcwd() p = configargparse.getArgumentParser( default_config_files=[os.path.join(cwd, 'conf.ini')]) self.add_arguments(p) args, _ = p.parse_known_args() # overwrite with enum args.chain = Chain.parse_from_chain(args.chain) # ensure it's a supported chain if args.chain.blockchain_type != BlockchainType.bitcoin and \ args.chain.blockchain_type != BlockchainType.ethereum and \ args.chain.blockchain_type != BlockchainType.mock: raise UnknownChainError(args.chain.name) logging.info('This run will try to issue on the %s chain', args.chain.name) if args.chain.blockchain_type == BlockchainType.bitcoin: bitcoin_chain_for_python_bitcoinlib = args.chain if args.chain == Chain.bitcoin_regtest: bitcoin_chain_for_python_bitcoinlib = Chain.bitcoin_regtest bitcoin.SelectParams( chain_to_bitcoin_network(bitcoin_chain_for_python_bitcoinlib)) self.config = args return self
def test_duplicateForced(self): parser = configargparse.getArgumentParser('pynYNAB') args = parser.parse_known_args()[0] args.schema = 'example' args.csvfile = os.path.join(gettempdir(), 'data.csv') args.accountname = None args.import_duplicates = True args.logginglevel = 'debug' content = """Date,Payee,Amount,Memo,Account 2016-02-01,Super Pants Inc.,-20,Buying pants,Cash """ with open(args.csvfile, mode='w') as f: f.writelines(content) transaction = self.getTr( datetime(year=2016, month=2, day=1).date(), 'Super Pants Inc.', -20, 'Buying pants', 'Cash') do_csvimport(args) self.reload() do_csvimport(args) self.reload() self.assertTrue( len([ tr2 for tr2 in self.client.budget.be_transactions if transaction._hash() == tr2._hash() ]) == 2)
def main(argv=None): cap = configargparse.getArgumentParser() cap.add("filename", help='File to use in "$CPP $CPPFLAGS -MM filename"', nargs="+") # This will add the common arguments as a side effect ct.headerdeps.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) hh = ct.headerdeps.CppHeaderDeps(args) if not ct.wrappedos.isfile(args.filename[0]): sys.stderr.write( "The supplied filename ({0}) isn't a file. " " Did you spell it correctly? " "Another possible reason is that you didn't supply a filename and " "that configargparse has picked an unused positional argument from " "the config file.\n".format(args.filename[0])) return 1 results = ct.utils.OrderedSet() for fname in args.filename: results |= hh.process(fname) for dep in results: print(dep) return 0
def define_options(self): p = configargparse.getArgumentParser(default_config_files=[ '/etc/JiraDash/conf.d/*.conf', '~/.config/JiraDash' ]) p.add('-c', '--config', is_config_file=True, help='Config file.') p.add('--jira-user', help="Jira username", required=True) p.add('--jira-token', help="Jira API token", required=True) p.add('--jira-server', help="Jira server URL", required=True) p.add('--jira-project', help="Jira project", required=True, action='append') p.add( '--jira-filter', help= "Filter conditions to add to Jira query. Ex: '--jira-filter fixVersions = alpha1'", action='append') p.add( '--groupby', help= "Group epics or issues by this field in mermaid or csv output. Ex: '--groupby components'", choices=['fixVersions', 'components']) p.add('--out-dir', '-o', help="Directory where to output graphs", default="mermaid_out") p.add('--csvfile', help="CSV input data") p.add('command', help="command to execute", nargs=1, choices=COMMANDS) self._parser = p
def create_config(): p = configargparse.getArgumentParser(default_config_files=[os.path.join(BASE_DIR, 'conf_local.ini'), os.path.join(BASE_DIR, 'conf.ini'), '/etc/cert-issuer/conf.ini']) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--notifier_type', default='noop', type=str, env_var='NOTIFIER_TYPE', help='type of notification on certificate introduction') p.add_argument('--mongodb_uri', default='mongodb://localhost:27017/test', type=str, env_var='MONGODB_URI', help='mongo connection URI') p.add_argument('--mandrill_api_key', type=str, env_var='MANDRILL_API_KEY', help='Mandrill API key; needed if notifier_type is mail') p.add_argument('--issuer_email', type=str, env_var='ISSUER_EMAIL', help='email address from which notification should be sent') p.add_argument('--issuer_name', type=str, env_var='ISSUER_NAME', help='name from which notification should be sent') p.add_argument('--subject', type=str, env_var='SUBJECT', help='notification subject line') p.add_argument('--recent_certids', type=str, env_var='RECENT_CERTIDS', help='recent certificate ids') p.add_argument('--secret_key', type=str, env_var='SECRET_KEY', help='Flask secret key, to enable cryptographically signed sessions') p.add_argument('--cert_store_type', type=str, env_var='CERT_STORE_TYPE', help='type of key value store to use for Cert Store') p.add_argument('--cert_store_path', type=str, env_var='CERT_STORE_PATH', help='path to file system Cert Store') p.add_argument('--v1_aware', action='store_true', env_var='V1_AWARE', help='Whether to support v1 certs') p.add_argument('--site_description', env_var='SITE_DESCRIPTION', help='Site description got issuer that is hosting the certificate viewer', default='A Blockchain Certificate Issuer Site') p.add_argument('--issuer_logo_path', env_var='ISSUER_LOGO_PATH', help='Issuer logo to display in certificate viewer', default='img/logo.png') p.add_argument('--theme', env_var='THEME', help='Flask theme to use for display', default='default') args, _ = p.parse_known_args() return args
def create_config(): p = configargparse.getArgumentParser(default_config_files=[ os.path.join(BASE_DIR, 'conf_test.ini'), os.path.join(BASE_DIR, 'conf_local.ini'), os.path.join(BASE_DIR, 'conf.ini'), '/etc/cert-issuer/conf.ini' ]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument( '--mongodb_uri', default='mongodb://localhost:27017/test', type=str, env_var='MONGODB_URI', help='Mongo connection string, including db containing certificates') p.add_argument('--cert_store_type', type=str, help='type of key value store to use for Cert Store') p.add_argument('--cert_store_path', type=str, help='path to file system Cert Store') p.add_argument('--v1_aware', action='store_true', help='Whether to support v1 certs') args, _ = p.parse_known_args() return args
def _hunter_is_not_order_dependent(precall): samplesdir = uth.samplesdir() relativepaths = [ "factory/test_factory.cpp", "numbers/test_direct_include.cpp", "simple/helloworld_c.c", "simple/helloworld_cpp.cpp", "simple/test_cflags.c", ] bulkpaths = [ os.path.join(samplesdir, filename) for filename in relativepaths ] temp_config = ct.unittesthelper.create_temp_config() argv = ["--config", temp_config, "--include", uth.ctdir()] cap = configargparse.getArgumentParser() ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hntr = ct.hunter.Hunter(args, headerdeps, magicparser) os.unlink(temp_config) realpath = os.path.join(samplesdir, "dottypaths/dottypaths.cpp") if precall: result = hntr.required_source_files(realpath) return result else: for filename in bulkpaths: discard = hntr.required_source_files(filename) result = hntr.required_source_files(realpath) return result
def _grab_timestamps(self, deeper_is_included=False): ''' There are 8 files we want timestamps for. main.cpp, extra.hpp, extra.cpp, deeper.hpp, deeper.cpp, deeper.o, main.o, extra.o and the executable called "main". This must be called inside the directory where main.cpp lives. ''' # Create a namer so that we get the names of the object files correct cap = configargparse.getArgumentParser() args = ct.apptools.parseargs(cap, self._create_argv(), verbose=0) nmr = ct.namer.Namer(args) # These are the basic filenames fnames = [os.path.realpath('main.cpp') , os.path.realpath('extra.hpp') , os.path.realpath('extra.cpp')] if deeper_is_included: fnames.append( os.path.realpath('deeper.hpp') ) fnames.append( os.path.realpath('deeper.cpp') ) # Add in the object filenames (only cpp have object files) for fname in [name for name in fnames if 'cpp' in name]: fnames.append(nmr.object_pathname(fname)) # Add the executable name fnames.append(nmr.executable_pathname('main.cpp')) timestamps = {} for fname in fnames: timestamps[fname] = os.path.getmtime(fname) return timestamps
def test_samples(self): relativeexpectedexes = { 'simple/helloworld_c.c', 'simple/helloworld_cpp.cpp', 'dottypaths/dottypaths.cpp', 'library/main.cpp', 'lotsofmagic/lotsofmagic.cpp', 'magicsourceinheader/main.cpp', 'magicinclude/main.cpp', 'movingheaders/main.cpp'} relativeexpectedtests = { 'cross_platform/test_source.cpp', 'factory/test_factory.cpp', 'numbers/test_direct_include.cpp', 'numbers/test_library.cpp', 'simple/test_cflags.c'} expectedexes = { os.path.realpath(os.path.join(uth.samplesdir(),exe)) for exe in relativeexpectedexes } expectedtests = { os.path.realpath(os.path.join(uth.samplesdir(),tt)) for tt in relativeexpectedtests } config_files = ct.configutils.config_files_from_variant(exedir=uth.cakedir(), argv=[]) cap = configargparse.getArgumentParser( description='TestFindTargetsModule', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, default_config_files=config_files, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=True) ct.findtargets.add_arguments(cap) args = ct.apptools.parseargs(cap, argv=['--shorten']) findtargets = ct.findtargets.FindTargets(args,exedir=uth.cakedir()) executabletargets, testtargets = findtargets(path=uth.cakedir()) self.assertSetEqual(expectedexes, set(executabletargets)) self.assertSetEqual(expectedtests, set(testtargets))
def test_import(self): parser = configargparse.getArgumentParser('pynYNAB') args = parser.parse_known_args()[0] args.schema = 'example' args.csvfile = os.path.join(gettempdir(), 'data.csv') args.accountname = None args.import_duplicates = False args.logginglevel = 'debug' content = """Date,Payee,Amount,Memo,Account 2016-02-01,Super Pants Inc.,-20,Buying pants,Cash 2016-02-02,Thai Restaurant,-10,Food,Checking Account 2016-02-03,,10,Saving!,Savings """ with open(args.csvfile, mode='w') as f: f.writelines(content) transactions = [ self.getTr(datetime(year=2016, month=2, day=1).date(), 'Super Pants Inc.', -20, 'Buying pants', 'Cash'), self.getTr(datetime(year=2016, month=2, day=2).date(), 'Thai Restaurant', -10, 'Food', 'Checking Account'), self.getTr(datetime(year=2016, month=2, day=3).date(), '', 10, 'Saving!', 'Savings'), ] do_csvimport(args) self.reload() for transaction in transactions: self.assertIn(transaction, self.client.budget.be_transactions)
def setup(): p = configargparse.getArgumentParser() try: options = p.parse_known_args() except Exception, e: print e sys.exit(1)
def main(argv=None): cap = configargparse.getArgumentParser() ct.headerdeps.add_arguments(cap) add_arguments(cap) cap.add( "filename", help='File/s to extract magicflags from"', nargs='+') # Figure out what style classes are available and add them to the command # line options styles = [st[:-5].lower() for st in dict(globals()) if st.endswith('Style')] cap.add( '--style', choices=styles, default='pretty', help="Output formatting style") args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = create(args, headerdeps) styleclass = globals()[args.style.title() + 'Style'] styleobject = styleclass(args) for fname in args.filename: realpath = ct.wrappedos.realpath(fname) styleobject(realpath, magicparser.parse(realpath)) print() return 0
def main(argv=None): cap = configargparse.getArgumentParser() cap.add( "filename", help='File to use in "$CPP $CPPFLAGS -MM filename"', nargs='+') # This will add the common arguments as a side effect ct.headerdeps.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) hh = ct.headerdeps.CppHeaderDeps(args) if not ct.wrappedos.isfile(args.filename[0]): sys.stderr.write( "The supplied filename ({0}) isn't a file. " " Did you spell it correctly? " "Another possible reason is that you didn't supply a filename and " "that configargparse has picked an unused positional argument from " "the config file.\n".format( args.filename[0])) return 1 results = ct.utils.OrderedSet() for fname in args.filename: results |= hh.process(fname) for dep in results: print(dep) return 0
def _direct_cpp_tester(self, filename, extraargs=None): """ For a given filename call HeaderTree.process() and HeaderDependencies.process """ if extraargs is None: extraargs = [] realpath = ct.wrappedos.realpath(filename) temp_config_name = ct.unittesthelper.create_temp_config() argv = ["--config=" + temp_config_name] + extraargs # Turn off diskcaching so that we can't just read up a prior result origcache = ct.dirnamer.user_cache_dir() _reload_ct("None") cap = configargparse.getArgumentParser() ct.headerdeps.add_arguments(cap) argvdirect = argv + ["--headerdeps=direct"] argsdirect = ct.apptools.parseargs(cap, argvdirect) argvcpp = argv + ["--headerdeps", "cpp"] argscpp = ct.apptools.parseargs(cap, argvcpp) hdirect = ct.headerdeps.create(argsdirect) hcpp = ct.headerdeps.create(argscpp) hdirectresult = hdirect.process(realpath) hcppresult = hcpp.process(realpath) self.assertSetEqual(hdirectresult, hcppresult) os.unlink(temp_config_name) _reload_ct(origcache)
def get_config(): base_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser( default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') p.add_argument('--unsigned_certificates_dir', type=str, help='output directory for unsigned certificates') p.add_argument('--roster', type=str, help='roster file name') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(base_dir, args.data_dir)) return args
def test_hunter_follows_source_files_from_header(self): origcache = ct.dirnamer.user_cache_dir("ct") tempdir = tempfile.mkdtemp() _reload_ct(tempdir) temp_config = ct.unittesthelper.create_temp_config() argv = ["-c", temp_config, "--include", uth.ctdir()] cap = configargparse.getArgumentParser() ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hntr = ct.hunter.Hunter(args, headerdeps, magicparser) relativepath = "factory/widget_factory.hpp" realpath = os.path.join(uth.samplesdir(), relativepath) filesfromheader = hntr.required_source_files(realpath) filesfromsource = hntr.required_source_files( ct.utils.implied_source(realpath)) self.assertSetEqual(filesfromheader, filesfromsource) # Cleanup os.unlink(temp_config) shutil.rmtree(tempdir) _reload_ct(origcache)
def test_duplicate(self): parser = configargparse.getArgumentParser('pynYNAB') args = parser.parse_known_args()[0] args.schema = 'example' args.csvfile = os.path.join('data', 'test.csv') args.accountname = None args.import_duplicates = False args.level = 'debug' content = """Date,Payee,Amount,Memo,Account 2016-02-01,Super Pants Inc.,-20,Buying pants,Credit """ try: os.makedirs(os.path.dirname(args.csvfile)) except OSError as e: if e.errno != errno.EEXIST: raise with open(args.csvfile, mode='w') as f: f.writelines(content) transaction=self.getTr(datetime(year=2016, month=2, day=1).date(), 'Super Pants Inc.', -20, 'Buying pants', 'Credit') for i in range(2): do_csvimport(args) self.reload() identical=[tr2 for tr2 in self.client.budget.be_transactions if transaction.hash() == tr2.hash()] print('Transactions with same hash: %s'%len(identical)) self.assertTrue(len(identical) == 1)
def lambda_handler(event,context): p = configargparse.getArgumentParser() p.add_argument('--region', '-r', default="us-east-1", help="AWS region containing snapshots", nargs="+",env_var="REGION") p.add_argument('--delete','-del',help="To delete the resources found",action='store_true',default=False,env_var="DELETE") args = p.parse_args() for region in args.region: s3_client = boto3.client('s3') s3 = boto3.resource('s3') client = boto3.client('ec2', region_name=region) response = client.describe_addresses() eips = [] for address in response['Addresses']: if 'NetworkInterfaceId' not in address: eips.append(address['PublicIp']) eip_file = open("/tmp/eip_file","w+") with eip_file as fh: for eip in eips: fh.write("Public Ip: ") fh.write(eip) fh.write("\n") with open("/tmp/eip_file", "rb") as f: s3_client.upload_fileobj(f, "cleanup-s3", "eip_file") for ip in eips: if args.delete: try: ec2.release_address(PublicIp=ip) except ClientError as e: continue return
def load_config(): base_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add_argument('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument( '-p', '--hash_prefix', type=str, default='20202020202020', help='prepend the hash that we wish to issue with this hexadecimal') p.add_argument('-f', nargs='+', help='a list of certificate pdf files to validate') args, _ = p.parse_known_args() return args
def get_config(): configure_logger() #configure_logger 함수 호출 p = configargparse.getArgumentParser(default_config_files=[ os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini' ]) add_arguments(p) parsed_config, _ = p.parse_known_args() if not parsed_config.safe_mode: logging.warning( 'Your app is configured to skip the wifi check when the USB is plugged in. Read the ' 'documentation to ensure this is what you want, since this is less secure' ) # overwrite with enum parsed_config.chain = Chain.parse_from_chain(parsed_config.chain) # ensure it's a supported chain if parsed_config.chain.blockchain_type != BlockchainType.bitcoin and \ parsed_config.chain.blockchain_type != BlockchainType.ethereum and \ parsed_config.chain.blockchain_type != BlockchainType.mock: raise UnknownChainError(parsed_config.chain.name) logging.info('This run will try to issue on the %s chain', parsed_config.chain.name) if parsed_config.chain.blockchain_type == BlockchainType.bitcoin: bitcoin_chain_for_python_bitcoinlib = parsed_config.chain if parsed_config.chain == Chain.bitcoin_regtest: bitcoin_chain_for_python_bitcoinlib = Chain.bitcoin_regtest bitcoin.SelectParams( chain_to_bitcoin_network(bitcoin_chain_for_python_bitcoinlib)) return parsed_config
def main(argv=None): cap = configargparse.getArgumentParser() ct.headerdeps.add_arguments(cap) add_arguments(cap) cap.add("filename", help='File/s to extract magicflags from"', nargs="+") # Figure out what style classes are available and add them to the command # line options styles = [ st[:-5].lower() for st in dict(globals()) if st.endswith("Style") ] cap.add("--style", choices=styles, default="pretty", help="Output formatting style") args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = create(args, headerdeps) styleclass = globals()[args.style.title() + "Style"] styleobject = styleclass(args) for fname in args.filename: realpath = ct.wrappedos.realpath(fname) styleobject(realpath, magicparser.parse(realpath)) print() return 0
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'cert_tools/conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_logo_file', type=str, help='issuer logo image file, png format') p.add_argument('--issuer_signature_file', type=str, help='issuer signature image file, png format') p.add_argument('--cert_image_file', type=str, help='issuer logo image file, png format') p.add_argument('--issuer_url', type=str, help='issuer URL') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--issuer_email', type=str, help='issuer email') p.add_argument('--issuer_name', type=str, help='issuer name') p.add_argument('--issuer_id', type=str, help='path to issuer public keys') p.add_argument('--certificate_language', type=str, required=False, help='certificate language') p.add_argument('--certificate_description', type=str, help='the display description of the certificate') p.add_argument('--certificate_title', type=str, help='the title of the certificate') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_global_fields', action=helpers.make_action('global_fields'), help='additional global fields') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def get_arg_parser(): """Create the parser for the command-line args.""" parser = configargparse.getArgumentParser() parser.add_argument("--longhelp", help="Print out configuration details", action="store_true") parser.add_argument("--marathon", "-m", nargs="+", env_var='MARATHON_URL', help="[required] Marathon endpoint, eg. -m " + "http://marathon1:8080 http://marathon2:8080") parser.add_argument("--hostname", env_var='F5_CC_BIGIP_HOSTNAME', help="F5 BIG-IP hostname") parser.add_argument("--username", env_var='F5_CC_BIGIP_USERNAME', help="F5 BIG-IP username") parser.add_argument("--password", env_var='F5_CC_BIGIP_PASSWORD', help="F5 BIG-IP password") parser.add_argument("--partition", env_var='F5_CC_PARTITIONS', help="[required] Only generate config for apps which" " match the specified partition." " Can use this arg multiple times to" " specify multiple partitions", action="append", default=list()) parser.add_argument("--health-check", "-H", env_var='F5_CC_USE_HEALTHCHECK', help="If set, respect Marathon's health check " "statuses before adding the app instance into " "the backend pool.", action="store_true") parser.add_argument("--marathon-ca-cert", env_var='F5_CC_MARATHON_CA_CERT', help="CA certificate for Marathon HTTPS connections") parser.add_argument('--sse-timeout', "-t", type=int, env_var='F5_CC_SSE_TIMEOUT', default=30, help='Marathon event stream timeout') parser.add_argument('--verify-interval', "-v", type=int, env_var='F5_CC_VERIFY_INTERVAL', default=30, help="Interval at which to verify " "the BIG-IP configuration.") parser.add_argument("--version", help="Print out version information and exit", action="store_true") parser = set_logging_args(parser) parser = set_marathon_auth_args(parser) return parser
def migrate_main(): print('migrate YNAB4 to pynYNAB') """Migrate a YNAB4 budget transaction history to nYNAB, using pyynab""" parser = configargparse.getArgumentParser('pynYNAB') parser.description = inspect.getdoc(migrate_main) parser.add_argument('budget', metavar='BudgetPath', type=str, help='The budget .ynab4 directory') args = parser.parse_args() test_common_args(args) budget_base_name = os.path.basename(args.budget) budget_path = os.path.dirname(args.budget) budget_name = re.match(r"(?P<budget_name>.*)~[A-Z0-9]{8}\.ynab4", budget_base_name).groupdict().get('budget_name') if args.budgetname is not None: budget_name = args.budgetname thisynab = YNAB(budget_path, budget_name) client = clientfromargs(args, reset=True) for ynab4_account in thisynab.accounts: account = Account( name=ynab4_account.name, account_type=ynab4_account.type.value, on_budget=ynab4_account.on_budget, sortable_index=random.randint(-50000, 50000), ) mindate = min([ ynab4transaction.date for ynab4transaction in thisynab.transactions if ynab4transaction.account == ynab4_account ]) client.add_account(account, 0, mindate) for master_category in thisynab.master_categories: master_entity = MasterCategory(name=master_category.name, sortable_index=random.randint( -50000, 50000)) client.budget.be_master_categories.append(master_entity) for category in master_category.categories: entity = Subcategory(name=category.name, entities_master_category_id=master_entity.id, sortable_index=random.randint(-50000, 50000)) client.budget.be_subcategories.append(entity) client.sync() for ynab4_payee in thisynab.payees: payee = Payee(name=ynab4_payee.name) client.budget.be_payees.append(payee) client.sync() for ynab4transaction in thisynab.transactions: transaction = Transaction() pass
def verboseprintconfig(args): if args.verbose >= 3: print(" ".join(["Using variant =", args.variant])) cap = configargparse.getArgumentParser() cap.print_values() if args.verbose >= 2: verbose_print_args(args)
def setUp(self): uth.reset() cap = configargparse.getArgumentParser( description="Configargparser in test code", formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c", "--config"], ignore_unknown_config_file_keys=False, )
def load_config(): base_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir)) default_config = os.path.join(base_dir, 'config.ini') p = configargparse.getArgumentParser(default_config_files=[default_config]) p.add('-c', '--config', required=False, is_config_file=True, help='config file path') p.add_argument( '-d', '--working_directory', type=str, default='.', help='the main working directory - all paths/files are relative to this' ) p.add_argument( '-o', '--output_pdf_index_file', type=str, default='index_document.pdf', help= 'the name of the pdf index document which hash will be stored in the blockchain' ) p.add_argument( '-a', '--issuing_address', type=str, help= 'the issuing address with enough funds for the transaction; assumed to be imported in local node wallet' ) p.add_argument('-n', '--full_node_url', type=str, default='127.0.0.1:18332', help='the url of the full node to use') p.add_argument( '-u', '--full_node_rpc_user', type=str, help='the rpc user as specified in the node\'s configuration') p.add_argument('-t', '--testnet', action='store_true', help='specify if testnet or mainnet will be used') p.add_argument('-f', '--tx_fee_per_byte', type=int, default=100, help='the fee per transaction byte in satoshis') p.add_argument( '-p', '--hash_prefix', type=str, help='prepend the hash that we wish to issue with this hexadecimal') args, _ = p.parse_known_args() return args
def main(argv=None): cap = configargparse.getArgumentParser() ct.apptools.add_base_arguments(cap) add_arguments(cap) args = cap.parse_args(args=argv) ct.apptools.verbose_print_args(args) print(args.parallel) return 0
def main(argv=None): cap = configargparse.getArgumentParser() ct.apptools.add_base_arguments(cap) add_arguments(cap) args = cap.parse_args(args=argv) if args.verbose >= 2: ct.apptools.verbose_print_args(args) print(args.parallel) return 0
def setUp(self): uth.reset() global _moduletmpdir if not _moduletmpdir or not os.path.exists(_moduletmpdir) : _moduletmpdir = tempfile.mkdtemp() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def main(argv=None): cap = configargparse.getArgumentParser() MakefileCreator.add_arguments(cap) ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hunter = ct.hunter.Hunter(args, headerdeps, magicparser) makefile_creator = MakefileCreator(args, hunter) makefile_creator.create() return 0
def ofximport_main(): print('pynYNAB OFX import') """Manually import an OFX into a nYNAB budget""" parser = configargparse.getArgumentParser('pynYNAB') parser.description = inspect.getdoc(ofximport_main) parser.add_argument('ofxfile', metavar='OFXPath', type=str, help='The OFX file to import') args = parser.parse_args() test_common_args(args) do_ofximport(args)
def setUp(self): try: if self._tmpdir is not None: shutil.rmtree(self._tmpdir, ignore_errors=True) except AttributeError: pass self._tmpdir = tempfile.mkdtemp() uth.reset() cap = configargparse.getArgumentParser( description='Configargparser in test code', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=False)
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('-p', '--cert_path', type=str, required=True, help='Path to certificates') p.add_argument('-u', '--url_prefix', type=str, help='URL prefix') p.add_argument('-o', '--output_path', type=str, help='Path to output file') args, _ = p.parse_known_args() return args
def main(argv=None): cap = configargparse.getArgumentParser() ct.findtargets.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) findtargets = FindTargets(args) styleclass = globals()[args.style.title() + 'Style'] styleobj = styleclass() executabletargets, testtargets = findtargets() styleobj(executabletargets, testtargets) return 0
def main(argv=None): cap = configargparse.getArgumentParser() MakefileCreator.add_arguments(cap) ct.hunter.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hunter = ct.hunter.Hunter(args, headerdeps, magicparser) makefile_creator = MakefileCreator(args, hunter) makefile_creator.create() # And clean up for the test cases where main is called more than once makefile_creator.clear_cache() return 0
def parse_args(): p = configargparse.getArgumentParser(default_config_files=[os.path.join(PATH, 'conf.ini'), '/etc/cert-issuer/conf.ini', os.path.join(PATH, 'conf_regtest.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--issuing_address', required=True, help='issuing address') p.add_argument('--revocation_address', required=True, help='revocation address') p.add_argument('--usb_name', required=True, help='usb path to key_file') p.add_argument('--key_file', required=True, help='name of file on USB containing private key') p.add_argument('--wallet_connector_type', default='bitcoind', help='connector to use for wallet') p.add_argument('--broadcaster_type', default='bitcoind', help='connector to use for broadcast') p.add_argument('--disable_regtest_mode', action='store_true', help='Use regtest mode of bitcoind (default: 0). Warning! Only change this if you have a local ' 'bitcoind client (not the included Docker container) and you are sure you want to spend money. ' 'Our included docker container is configured to run only in regtest mode.') p.add_argument('--storage_address', required=False, help='storage address. Not needed for bitcoind deployment') p.add_argument('--wallet_guid', required=False, help='wallet guid. Not needed for bitcoind deployment') p.add_argument('--wallet_password', required=False, help='wallet password. Not needed for bitcoind deployment') p.add_argument('--api_key', required=False, help='api key. Not needed for bitcoind deployment') p.add_argument('--transfer_from_storage_address', action='store_true', help='Transfer BTC from storage to issuing address (default: 0). Advanced usage') p.add_argument('--skip_sign', action='store_true', help='Sign certificates in unsigned_certs folder (default: 0). Only change this option for ' 'troubleshooting.') p.add_argument('--skip_wifi_check', action='store_true', help='Used to make sure your private key is not plugged in with the wifi on (default: False). ' 'Only change this option for troubleshooting.') p.add_argument('--dust_threshold', default=0.0000275, type=float, help='blockchain dust threshold (in BTC) -- below this 1/3 is fees.') p.add_argument('--tx_fees', default=0.0001, type=float, help='recommended tx fee (in BTC) for inclusion in next block. http://bitcoinexchangerate.org/fees') p.add_argument('--batch_size', default=10, type=int, help='Certificate batch size') p.add_argument('--satoshi_per_byte', default=41, type=int, help='Satoshi per byte') p.add_argument('--data_path', default=DATA_PATH, help='Default path to data directory, storing unsigned certs') p.add_argument('--archive_path', default=ARCHIVE_PATH, help='Default path to data directory, storing issued certs') return p.parse_known_args()
def __init__(self, job=None, num_processes=sys.maxint, shell='/bin/bash'): """ Args: job: if only one Job will be run. Otherwise, use .add_parallel(..) num_processes: Max number of jobs to run in parallel. """ if JobRunner._instance: raise Exception("Creating more than one JobRunner object is not supported. Instead, use " "JobRunner.getInstance() to get the single instance of JobRunner.") JobRunner._instance = self # TODO put these in config file: self.pipeline_shutdown_reason = "" # used to prevent jobs from starting if upstream command or job fails. self.LOG_HEARTBEAT_INTERVAL_MINUTES = 2.5 # how frequently to write "still running" message to log self.SGE_max_cores_to_reserve = 12 # The maximum number of SGE cores to reserve for a job. self.pipeline_id = str(random.randint(10*5, 10**6 - 1)) self.time_stamp = time.strftime("%Y-%m-%d_%H.%M.%S") self.next_job_id = 1 # the job id is prepended to the command id in log output self.shell = shell self._fix_keyboard_interrupt_handling() self.jobs = [] # jobs to run in parallel self.threads = [] # thread pool if job: self.add_parallel(job) init_command_line_args() p = configargparse.getArgumentParser() opts, args = p.parse_known_args() self.is_test = opts.is_test self.use_SGE = None # opts.use_SGE self.use_LSF = None # opts.use_LSF self.should_force_all = opts.should_force_all self.force_these = opts.force_these self.only_these = opts.only_these self.begin_with_these = opts.begin_with_these self.end_with_these = opts.end_with_these self.num_processes = opts.num_processes self.clean = None # opts.clean
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('-k', '--extended_public_key', type=str, required=True, help='the HD extended public key used to generate the revocation addresses') p.add_argument('-p', '--key_path', type=str, help='the key path used to derive the child key under which the addresses will be generated') p.add_argument('-n', '--number_of_addresses', type=int, default=10, help='the number of revocation addresses to generate') p.add_argument('-o', '--output_file', type=str, help='the output file to save the revocation addresses') p.add_argument('-u', '--use_uncompressed', action='store_true', default=False, help='whether to use uncompressed bitcoin addresses') args, _ = p.parse_known_args() return args
def main(argv): variant = ct.configutils.extract_variant(argv=argv) config_files = ct.configutils.config_files_from_variant(variant=variant,argv=argv) cap = configargparse.getArgumentParser( description='A convenience tool to aid migration from cake to the ct-* tools', formatter_class=configargparse.ArgumentDefaultsHelpFormatter, auto_env_var_prefix='', default_config_files=config_files, args_for_setting_config_path=["-c","--config"], ignore_unknown_config_file_keys=True) Cake.add_arguments(cap) Cake.registercallback() args = ct.apptools.parseargs(cap, argv) if not any([args.filename, args.static, args.dynamic, args.tests, args.auto]): print( 'Nothing for cake to do. Did you mean cake --auto? Use cake --help for help.') return 0 signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGPIPE, signal_handler) try: cake = Cake(args) cake.process() # For testing purposes, clear out the memcaches for the times when main is called more than once. cake.clear_cache() except IOError as ioe: if args.verbose < 2: print( " ".join(["Error processing", ioe.filename, ". Does it exist?"])) return 1 else: raise except Exception as err: if args.verbose < 2: print(err.message) return 1 else: raise return 0
def get_config(): base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) p = configargparse.getArgumentParser(default_config_files=[os.path.join(base_dir, 'conf.ini')]) p.add('-c', '--my-config', required=True, is_config_file=True, help='config file path') p.add_argument('-k', '--issuer_address', type=str, required=True, help='the issuer\'s Bitcoin address that will be used to issue the certificates') p.add_argument('-r', '--revocation_address', type=str, required=True, help='the issuer\'s Bitcoin revocation address that can be used to revocate the certificates') p.add_argument('-d', '--issuer_id', type=str, required=True, help='the issuer\'s publicly accessible identification file; i.e. URL of the file generated by this tool') p.add_argument('-u', '--issuer_url', type=str, help='the issuers main URL address') p.add_argument('-l', '--issuer_certs_url', type=str, help='the issuer\'s URL address of the certificates') p.add_argument('-n', '--issuer_name', type=str, help='the issuer\'s name') p.add_argument('-e', '--issuer_email', type=str, help='the issuer\'s email') p.add_argument('-m', '--issuer_logo_file', type=str, help='the issuer\' logo image') p.add_argument('-o', '--output_file', type=str, help='the output file to save the issuer\'s identification file') args, _ = p.parse_known_args() return args
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=False, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('--issuer_certs_url', type=str, help='issuer certificates URL') p.add_argument('--template_dir', type=str, help='the template output directory') p.add_argument('--template_file_name', type=str, help='the template file name') p.add_argument('--hash_emails', action='store_true', help='whether to hash emails in the certificate') p.add_argument('--additional_per_recipient_fields', action=helpers.make_action('per_recipient_fields'), help='additional per-recipient fields') p.add_argument('--unsigned_certificates_dir', type=str, help='output directory for unsigned certificates') p.add_argument('--roster', type=str, help='roster file name') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args
def main(argv=None): cap = configargparse.getArgumentParser() Filelist.add_arguments(cap) args = ct.apptools.parseargs(cap, argv) headerdeps = ct.headerdeps.create(args) magicparser = ct.magicflags.create(args, headerdeps) hunter = ct.hunter.Hunter(args, headerdeps, magicparser) filelist = Filelist(args, hunter) filelist.process() # For testing purposes, clear out the memcaches for the times when main is called more than once. ct.wrappedos.clear_cache() ct.utils.clear_cache() ct.git_utils.clear_cache() headerdeps.clear_cache() magicparser.clear_cache() hunter.clear_cache() return 0
def get_config(): cwd = os.getcwd() p = configargparse.getArgumentParser(default_config_files=[os.path.join(cwd, 'conf.ini')]) p.add('-c', '--my-config', required=True, is_config_file=True, help='config file path') p.add_argument('--data_dir', type=str, help='where data files are located') p.add_argument('-k', '--issuer_public_key', type=str, required=True, help='The key(s) an issuer uses to sign Assertions. See https://openbadgespec.org/#Profile for more details') p.add_argument('-k', '--public_key_created', type=str, help='ISO8601-formatted date the issuer public key should be considered active') p.add_argument('-r', '--revocation_list_uri', type=str, required=True, help='URI of the Revocation List used for marking revocation. See https://openbadgespec.org/#Profile for more details') p.add_argument('-d', '--issuer_id', type=str, required=True, help='the issuer\'s publicly accessible identification file; i.e. URL of the file generated by this tool') p.add_argument('-u', '--issuer_url', type=str, help='the issuer\'s main URL address') p.add_argument('-n', '--issuer_name', type=str, help='the issuer\'s name') p.add_argument('-e', '--issuer_email', type=str, help='the issuer\'s email') p.add_argument('-m', '--issuer_logo_file', type=str, help='the issuer\' logo image') p.add_argument('-i', '--intro_url', required=False, type=str, help='the issuer\'s introduction URL address') p.add_argument('-o', '--output_file', type=str, help='the output file to save the issuer\'s identification file') args, _ = p.parse_known_args() args.abs_data_dir = os.path.abspath(os.path.join(cwd, args.data_dir)) return args