当前位置: 首页>>代码示例>>Python>>正文


Python virtualchain.get_config_filename函数代码示例

本文整理汇总了Python中virtualchain.get_config_filename函数的典型用法代码示例。如果您正苦于以下问题:Python get_config_filename函数的具体用法?Python get_config_filename怎么用?Python get_config_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_config_filename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: default_blockcypher_opts

def default_blockcypher_opts( config_file=None ):
   """
   Get our default blockcypher.com options from a config file.
   """
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   blockcypher_opts = {}
   
   api_token = None 
   
   if parser.has_section('blockcypher'):
      
      if parser.has_option('blockcypher', 'api_token'):
         api_token = parser.get('blockcypher', 'api_token')
      
   blockcypher_opts = {
       'utxo_provider': "blockcypher",
       'api_token': api_token
   }
    
   
   # strip Nones 
   for (k, v) in blockcypher_opts.items():
      if v is None:
         del blockcypher_opts[k]
   
   return blockcypher_opts
开发者ID:john-light,项目名称:blockstore,代码行数:32,代码来源:config.py

示例2: default_chaincom_opts

def default_chaincom_opts(config_file=None):
    """
   Get our default chain.com options from a config file.
   """

    if config_file is None:
        config_file = virtualchain.get_config_filename()

    parser = SafeConfigParser()
    parser.read(config_file)

    chaincom_opts = {}

    api_key_id = None
    api_key_secret = None

    if parser.has_section("chain_com"):

        if parser.has_option("chain_com", "api_key_id"):
            api_key_id = parser.get("chain_com", "api_key_id")

        if parser.has_option("chain_com", "api_key_secret"):
            api_key_secret = parser.get("chain_com", "api_key_secret")

    chaincom_opts = {"utxo_provider": "chain_com", "api_key_id": api_key_id, "api_key_secret": api_key_secret}

    # strip Nones
    for (k, v) in chaincom_opts.items():
        if v is None:
            del chaincom_opts[k]

    return chaincom_opts
开发者ID:shaowenliu,项目名称:blockstore,代码行数:32,代码来源:config.py

示例3: default_blockchain_info_opts

def default_blockchain_info_opts( config_file=None ):
   """
   Get our default blockchain.info options from a config file.
   """
   
   if config_file is None:
       config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   blockchain_info_opts = {}
   
   api_token = None 
   
   if parser.has_section("blockchain_info"):
       
       if parser.has_option("blockchain_info", "api_token"):
           api_token = parser.get("blockchain_info", "api_token")
           
   blockchain_info_opts = {
       "utxo_provider": "blockchain_info",
       "api_token": api_token
   }
   
   # strip Nones 
   for (k, v) in blockchain_info_opts.items():
      if v is None:
         del blockchain_info_opts[k]
   
   return blockchain_info_opts
开发者ID:john-light,项目名称:blockstore,代码行数:31,代码来源:config.py

示例4: configure

def configure( config_file=None, force=False, interactive=True ):
   """
   Configure blockstore:  find and store configuration parameters to the config file.
   
   Optionally prompt for missing data interactively (with interactive=True).  Or, raise an exception
   if there are any fields missing.
   
   Optionally force a re-prompting for all configuration details (with force=True)
   
   Return (bitcoind_opts, chaincom_opts)
   """
   
   if config_file is None:
      try:
         config_file = virtualchain.get_config_filename()
      except:
         pass 
   
   bitcoind_message  = "Blockstore does not have enough information to connect\n"
   bitcoind_message += "to bitcoind.  Please supply the following parameters:"
   
   bitcoind_opts = {}
   bitcoind_params = ["server", "port", "user", "passwd", "use_https"]
   
   chaincom_message  = 'NOTE: Blockstore currently requires API access to chain.com\n'
   chaincom_message += 'for getting unspent outputs. We will add support for using\n'
   chaincom_message += 'bitcoind and/or other API providers in the next release.\n'
   chaincom_message += "\n"
   chaincom_message += "If you have not done so already, please go to https://chain.com\n"
   chaincom_message += "and register for an API key and secret.  Once you have them,"
   chaincom_message += "please enter them here."
   
   chaincom_opts = {}
   chaincom_params = ["api_key_id", "api_key_secret"]
   
   if not force:
      
      # get current set of bitcoind opts
      tmp_bitcoind_opts = default_bitcoind_opts( config_file=config_file )
      bitcoind_opts = opt_strip( "bitcoind_", tmp_bitcoind_opts )
         
      # get current set of chaincom opts 
      chaincom_opts = default_chaincom_opts( config_file=config_file )
      
   # get any missing fields 
   bitcoind_opts, missing_bitcoin_opts = find_missing( bitcoind_message, bitcoind_params, bitcoind_opts, prompt_missing=interactive )
   chaincom_opts, missing_chaincom_opts = find_missing( chaincom_message, chaincom_params, chaincom_opts, prompt_missing=interactive )
   
   if not interactive and (len(missing_bitcoin_opts) > 0 or len(missing_chaincom_opts) > 0):
       
       # cannot continue 
       raise Exception("Missing configuration fields: %s" % (",".join( missing_bitcoin_opts + missing_chaincom_opts )) )
                       
   return (bitcoind_opts, chaincom_opts)
开发者ID:hotelzululima,项目名称:blockstore,代码行数:54,代码来源:config.py

示例5: get_magic_bytes

def get_magic_bytes():
   """
   (required by virtualchain state engine)
   
   Get the magic byte sequence for our OP_RETURNs
   """
   blockstore_opts = default_blockstore_opts( virtualchain.get_config_filename() )
   if blockstore_opts['testset']:
       return MAGIC_BYTES_TESTSET
   
   else:
       return MAGIC_BYTES_MAINSET
开发者ID:shaowenliu,项目名称:blockstore,代码行数:12,代码来源:virtualchain_hooks.py

示例6: setup

def setup( return_parser=False ):
   """
   Do one-time initialization.
   Call this to set up global state and set signal handlers.
   
   If return_parser is True, return a partially-
   setup argument parser to be populated with 
   subparsers (i.e. as part of main())
   
   Otherwise return None.
   """
   
   global blockstore_opts 
   global blockchain_client
   global blockchain_broadcaster
   global bitcoin_opts
   global utxo_opts 
   global blockstore_opts
   global dht_opts
   
   # set up our implementation 
   virtualchain.setup_virtualchain( blockstore_state_engine )
   
   # acquire configuration, and store it globally
   blockstore_opts, bitcoin_opts, utxo_opts, dht_opts = configure( interactive=True )
   
   # merge in command-line bitcoind options 
   config_file = virtualchain.get_config_filename()
   
   arg_bitcoin_opts = None 
   argparser = None 
   
   if return_parser:
      arg_bitcoin_opts, argparser = virtualchain.parse_bitcoind_args( return_parser=return_parser )
   
   else:
      arg_bitcoin_opts = virtualchain.parse_bitcoind_args( return_parser=return_parser )

   # command-line overrides config file
   for (k, v) in arg_bitcoin_opts.items():
      bitcoin_opts[k] = v
   
   # store options 
   set_bitcoin_opts( bitcoin_opts )
   set_utxo_opts( utxo_opts )
   
   if return_parser:
      return argparser 
   else:
      return None
开发者ID:john-light,项目名称:blockstore,代码行数:50,代码来源:blockstored.py

示例7: default_blockstore_opts

def default_blockstore_opts( config_file=None, testset=False ):
   """
   Get our default blockstore opts from a config file
   or from sane defaults.
   """
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   blockstore_opts = {}
   tx_broadcaster = None 
   utxo_provider = None
   testset_first_block = None
   max_subsidy = 0
   
   if parser.has_section('blockstore'):
      
      if parser.has_option('blockstore', 'tx_broadcaster'):
         tx_broadcaster = parser.get('blockstore', 'tx_broadcaster')
      
      if parser.has_option('blockstore', 'utxo_provider'):
         utxo_provider = parser.get('blockstore', 'utxo_provider')
      
      if parser.has_option('blockstore', 'testset'):
         testset = bool(parser.get('blockstore', 'testset'))
         
      if parser.has_option('blockstore', 'testset_first_block'):
         testset_first_block = int( parser.get('blockstore', 'testset_first_block') )
         
      if parser.has_option('blockstore', 'max_subsidy'):
         max_subsidy = int( parser.get('blockstore', 'max_subsidy'))
         
         
   blockstore_opts = {
       'tx_broadcaster': tx_broadcaster,
       'utxo_provider': utxo_provider,
       'testset': testset,
       'testset_first_block': testset_first_block,
       'max_subsidy': max_subsidy
   }
   
   # strip Nones 
   for (k, v) in blockstore_opts.items():
      if v is None:
         del blockstore_opts[k]
   
   return blockstore_opts
开发者ID:jmktx,项目名称:blockstore,代码行数:50,代码来源:config.py

示例8: default_utxo_provider

def default_utxo_provider( config_file=None ):
   """
   Get our defualt UTXO provider options from a config file.
   """
   
   global SUPPORTED_UTXO_PROVIDERS
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   for provider_name in SUPPORTED_UTXO_PROVIDERS:
       if parser.has_section( provider_name ):
           return provider_name 
       
   return None
开发者ID:john-light,项目名称:blockstore,代码行数:18,代码来源:config.py

示例9: get_first_block_id

def get_first_block_id():
   """
   (required by virtualchain state engine)
   
   Get the id of the first block to start indexing.
   """ 
   blockstore_opts = default_blockstore_opts( virtualchain.get_config_filename() )
   start_block = None
   
   if TESTNET:
       if blockstore_opts['testset']:
           start_block = FIRST_BLOCK_TESTNET_TESTSET
       else:
           start_block = FIRST_BLOCK_TESTNET
   else:
       if blockstore_opts['testset']:
           start_block = FIRST_BLOCK_MAINNET_TESTSET
       else:
           start_block = FIRST_BLOCK_MAINNET

   return start_block
开发者ID:shaowenliu,项目名称:blockstore,代码行数:21,代码来源:virtualchain_hooks.py

示例10: write_config_file

def write_config_file( bitcoind_opts=None, chaincom_opts=None, config_file=None ):
   """
   Update a configuration file, given the bitcoind options and chain.com options.
   Return True on success 
   Return False on failure
   """
   
   if config_file is None:
      try:
         config_file = virtualchain.get_config_filename()
      except:
         return False
      
   if config_file is None:
      return False 
   
   parser = SafeConfigParser()
   parser.read(config_file)
   
   if bitcoind_opts is not None:
      
      bitcoind_opts = opt_strip( "bitcoind_", bitcoind_opts )
      
      for opt_name, opt_value in bitcoind_opts.items():
         parser.set( 'bitcoind', opt_name, opt_value )
      
   if chaincom_opts is not None:
      
      for opt_name, opt_value in chaincom_opts.items():
         parser.set( 'chain_com', opt_name, opt_value )
      
   with open(config_file, "w") as fout:
      parser.write( fout )
   
   return True

   
开发者ID:hotelzululima,项目名称:blockstore,代码行数:35,代码来源:config.py

示例11: default_blockstore_opts

def default_blockstore_opts( config_file=None ):
   """
   Get our default blockstore opts from a config file
   or from sane defaults.
   """
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   blockstore_opts = {}
   tx_broadcaster = None 
   utxo_provider = None
   
   if parser.has_section('blockstore'):
      
      if parser.has_option('blockstore', 'tx_broadcaster'):
         tx_broadcaster = parser.get('blockstore', 'tx_broadcaster')
      
      if parser.has_option('blockstore', 'utxo_provider'):
         utxo_provider = parser.get('blockstore', 'utxo_provider')
      
   blockstore_opts = {
       'tx_broadcaster': tx_broadcaster,
       'utxo_provider': utxo_provider
   }
    
   
   # strip Nones 
   for (k, v) in blockstore_opts.items():
      if v is None:
         del blockstore_opts[k]
   
   return blockstore_opts
开发者ID:john-light,项目名称:blockstore,代码行数:36,代码来源:config.py

示例12: default_chaincom_opts

def default_chaincom_opts( config_file=None ):
   """
   Get our default chain.com options from a config file.
   """
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   parser = SafeConfigParser()
   parser.read( config_file )
   
   chaincom_opts = {}
   
   api_key_id = None 
   api_key_secret = None
   
   if parser.has_section('chain_com'):
      
      if parser.has_option('chain_com', 'api_key_id'):
         api_key_id = parser.get('chain_com', 'api_key_id')
      
      if parser.has_option('chain_com', 'api_key_secret'):
         api_key_secret = parser.get('chain_com', 'api_key_secret')
      
      chaincom_opts = {
         'api_key_id': api_key_id,
         'api_key_secret': api_key_secret
      }
      
   
   # strip Nones 
   for (k, v) in chaincom_opts.items():
      if v is None:
         del chaincom_opts[k]
   
   return chaincom_opts
开发者ID:hotelzululima,项目名称:blockstore,代码行数:36,代码来源:config.py

示例13: default_dht_opts

def default_dht_opts( config_file=None ):
   """
   Get our default DHT options from the config file.
   """
   
   global DHT_SERVER_PORT, DEFAULT_DHT_SERVERS
   
   if config_file is None:
      config_file = virtualchain.get_config_filename()
   
   
   defaults = {
      'disable': str(True),
      'port': str(DHT_SERVER_PORT),
      'servers': ",".join( ["%s:%s" % (host, port) for (host, port) in DEFAULT_DHT_SERVERS] )
   }
   
   parser = SafeConfigParser( defaults )
   parser.read( config_file )
   
   if parser.has_section('dht'):
      
      disable = parser.get('dht', 'disable')
      port = parser.get('dht', 'port')
      servers = parser.get('dht', 'servers')     # expect comma-separated list of host:port
      
      if disable is None:
         disable = True 
         
      if port is None:
         port = DHT_SERVER_PORT
         
      if servers is None:
         servers = DEFAULT_DHT_SERVERS
         
      try:
         disable = bool(disable)
      except:
         raise Exception("Invalid field value for dht.disable: expected bool")
      
      try:
         port = int(port)
      except:
         raise Exception("Invalid field value for dht.port: expected int")
      
      parsed_servers = []
      try:
         server_list = servers.split(",")
         for server in server_list:
            server_host, server_port = server.split(":")
            server_port = int(server_port)
            
            parsed_servers.append( (server_host, server_port) )
            
      except:
         raise Exception("Invalid field value for dht.servers: expected 'HOST:PORT[,HOST:PORT...]'")
      
      dht_opts = {
         'disable': disable,
         'port': port,
         'servers': ",".join( ["%s:%s" % (host, port) for (host, port) in DEFAULT_DHT_SERVERS] )
      }
      
      return dht_opts 
   
   else:
      
      # use defaults
      dht_opts = {
         'disable': True,
         'port': DHT_SERVER_PORT,
         'servers': ",".join( ["%s:%s" % (host, port) for (host, port) in DEFAULT_DHT_SERVERS] )
      }
         
      return dht_opts
开发者ID:john-light,项目名称:blockstore,代码行数:75,代码来源:config.py

示例14: default_bitcoind_utxo_opts

def default_bitcoind_utxo_opts( config_file=None ):
   """
   Get our default bitcoind UTXO options from a config file.
   """
   
   if config_file is None:
       config_file = virtualchain.get_config_filename()
       
   parser = SafeConfigParser()
   parser.read( config_file )
   
   bitcoind_utxo_opts = {}
   
   server = None 
   port = None 
   rpc_username = None 
   rpc_password = None 
   use_https = None 
   version_byte = None
   
   if parser.has_section("bitcoind_utxo"):
       
       if parser.has_option("bitcoind_utxo", "server"):
           server = parser.get("bitcoind_utxo", "server")
           
       if parser.has_option("bitcoind_utxo", "port"):
           port = int( parser.get("bitcoind_utxo", "port") )
                      
       if parser.has_option("bitcoind_utxo", "rpc_username"):
           rpc_username = parser.get("bitcoind_utxo", "rpc_username")
           
       if parser.has_option("bitcoind_utxo", "rpc_password"):
           rpc_password = parser.get("bitcoind_utxo", "rpc_password")
       
       if parser.has_option("bitcoind_utxo", "use_https"):
           use_https = bool( parser.get("bitcoind_utxo", "use_https") )
           
       if parser.has_option("bitcoind_utxo", "version_byte"):
           version_byte = int(parser.get("bitcoind_utxo", "version_byte"))
           
           
   if use_https is None:
       use_https = True 
   
   if version_byte is None:
       version_byte = 0 
       
   if server is None:
       server = '127.0.0.1'
   
   if port is None:
       port = 8332 
       
   bitcoind_utxo_opts = {
       "utxo_provider": "bitcoind_utxo",
       "rpc_username": rpc_username,
       "rpc_password": rpc_password,
       "server": server,
       "port": port,
       "use_https": use_https,
       "version_byte": version_byte
   }
   
   # strip Nones 
   for (k, v) in bitcoind_utxo_opts.items():
      if v is None:
         del bitcoind_utxo_opts[k]
   
   return bitcoind_utxo_opts
开发者ID:john-light,项目名称:blockstore,代码行数:69,代码来源:config.py

示例15: configure

def configure( config_file=None, force=False, interactive=True, testset=False ):
   """
   Configure blockstack:  find and store configuration parameters to the config file.

   Optionally prompt for missing data interactively (with interactive=True).  Or, raise an exception
   if there are any fields missing.

   Optionally force a re-prompting for all configuration details (with force=True)

   Return (bitcoind_opts, utxo_opts)
   """

   global SUPPORTED_UTXO_PROVIDERS, SUPPORTED_UTXO_PARAMS, SUPPORTED_UTXO_PROMPT_MESSAGES

   if config_file is None:
      try:
         # get input for everything
         config_file = virtualchain.get_config_filename()
      except:
         raise

   if not os.path.exists( config_file ):
       # definitely ask for everything
       force = True

   # get blockstack opts
   blockstack_opts = {}
   blockstack_opts_defaults = default_blockstack_opts( config_file=config_file, testset=testset )
   blockstack_params = blockstack_opts_defaults.keys()

   if not force:

       # default blockstack options
       blockstack_opts = default_blockstack_opts( config_file=config_file, testset=testset )

   blockstack_msg = "ADVANCED USERS ONLY.\nPlease enter blockstack configuration hints."

   # NOTE: disabled
   blockstack_opts, missing_blockstack_opts, num_blockstack_opts_prompted = find_missing( blockstack_msg, blockstack_params, blockstack_opts, blockstack_opts_defaults, prompt_missing=False )

   utxo_provider = None
   if 'utxo_provider' in blockstack_opts:
       utxo_provider = blockstack_opts['utxo_provider']
   else:
       utxo_provider = default_utxo_provider( config_file=config_file )

   bitcoind_message  = "Blockstack does not have enough information to connect\n"
   bitcoind_message += "to bitcoind.  Please supply the following parameters, or\n"
   bitcoind_message += "press [ENTER] to select the default value."

   bitcoind_opts = {}
   bitcoind_opts_defaults = default_bitcoind_opts( config_file=config_file )
   bitcoind_params = bitcoind_opts_defaults.keys()

   if not force:

      # get default set of bitcoind opts
      bitcoind_opts = default_bitcoind_opts( config_file=config_file )


   # get any missing bitcoind fields
   bitcoind_opts, missing_bitcoin_opts, num_bitcoind_prompted = find_missing( bitcoind_message, bitcoind_params, bitcoind_opts, bitcoind_opts_defaults, prompt_missing=interactive, strip_prefix="bitcoind_" )

   # find the current utxo provider
   while utxo_provider is None or utxo_provider not in SUPPORTED_UTXO_PROVIDERS:

       # prompt for it?
       if interactive or force:

           utxo_message  = 'NOTE: Blockstack currently requires an external API\n'
           utxo_message += 'for querying unspent transaction outputs.  The set of\n'
           utxo_message += 'supported providers are:\n'
           utxo_message += "\t\n".join( SUPPORTED_UTXO_PROVIDERS ) + "\n"
           utxo_message += "Please get the requisite API tokens and enter them here."

           utxo_provider_dict = interactive_prompt( utxo_message, ['utxo_provider'], {} )
           utxo_provider = utxo_provider_dict['utxo_provider']

       else:
           raise Exception("No UTXO provider given")

   utxo_opts = {}
   utxo_opts_defaults = default_utxo_provider_opts( utxo_provider, config_file=config_file )
   utxo_params = SUPPORTED_UTXO_PARAMS[ utxo_provider ]

   if not force:

      # get current set of utxo opts
      utxo_opts = default_utxo_provider_opts( utxo_provider, config_file=config_file )

   utxo_opts, missing_utxo_opts, num_utxo_opts_prompted = find_missing( SUPPORTED_UTXO_PROMPT_MESSAGES[utxo_provider], utxo_params, utxo_opts, utxo_opts_defaults, prompt_missing=interactive )
   utxo_opts['utxo_provider'] = utxo_provider

   dht_opts = {}
   dht_opts_defaults = default_dht_opts( config_file=config_file )
   dht_params = dht_opts_defaults.keys()

   if not force:

       # default DHT options
#.........这里部分代码省略.........
开发者ID:ChairmanTubeAmp,项目名称:blockstack-server,代码行数:101,代码来源:config.py


注:本文中的virtualchain.get_config_filename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。