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


Python WebSocketClientFactory.blinktrade_broker_id方法代码示例

本文整理汇总了Python中autobahn.twisted.websocket.WebSocketClientFactory.blinktrade_broker_id方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketClientFactory.blinktrade_broker_id方法的具体用法?Python WebSocketClientFactory.blinktrade_broker_id怎么用?Python WebSocketClientFactory.blinktrade_broker_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autobahn.twisted.websocket.WebSocketClientFactory的用法示例。


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

示例1: main

# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import blinktrade_broker_id [as 别名]
def main():
  parser = argparse.ArgumentParser(description="Process blinktrade withdrawals requests")

  parser.add_argument('-c',
                      "--config",
                      action="store",
                      dest="config",
                      help='Configuration file', type=str)

  arguments = parser.parse_args()

  candidates = [ os.path.join(site_config_dir('blinktrade'), 'blinktrade_withdrawer.ini'),
                 os.path.expanduser('~/.blinktrade/blinktrade_withdrawer.ini')]
  if arguments.config:
    candidates.append(arguments.config)

  config = ConfigParser.SafeConfigParser()
  config.read( candidates )

  if config.has_section('blockchain_info'):
    blockchain_main_password    = getpass.getpass('Blockchain.info main password: ')
    blockchain_second_password  = getpass.getpass('Blockchain.info second password: ')


  blinktrade_password         = getpass.getpass('blinktrade password: ')
  blinktrade_2fa              = getpass.getpass('blinktrade second factor authentication: ')


  blinktrade_port = 443
  should_connect_on_ssl = True
  blinktrade_url = urlparse( config.get("blinktrade", "webscoket_url"))
  if  blinktrade_url.port is None and blinktrade_url.scheme == 'ws':
    should_connect_on_ssl = False
    blinktrade_port = 80

  db_engine = config.get("database", "sqlalchemy_engine") + ':///' +\
              os.path.expanduser(config.get("database", "sqlalchemy_connection_string"))
  engine = create_engine(db_engine, echo=config.getboolean('database', 'sqlalchmey_verbose'))
  Base.metadata.create_all(engine)

  factory = WebSocketClientFactory(blinktrade_url.geturl())
  factory.db_session                  = scoped_session(sessionmaker(bind=engine))
  factory.verbose                     = config.getboolean("blinktrade", "verbose")
  factory.blinktrade_user             = config.get("blinktrade", "user")
  factory.blinktrade_broker_id        = config.get("blinktrade", "broker_id")
  factory.currencies                  = json.loads(config.get("blinktrade", "currencies"))
  factory.methods                     = json.loads(config.get("blinktrade", "methods"))
  factory.blinktrade_password         = blinktrade_password
  factory.blinktrade_2fa              = blinktrade_2fa

  factory.blocked_accounts            = json.loads(config.get("blinktrade", "blocked_accounts"))

  if config.has_section('blockchain_info'):
    from blockchain_info import BlockchainInfoWithdrawalProtocol
    factory.blockchain_guid             = config.get("blockchain_info", "guid")
    factory.from_address                = config.get("blockchain_info", "from_address")
    factory.note                        = config.get("blockchain_info", "note")
    factory.blockchain_main_password    = blockchain_main_password
    factory.blockchain_second_password  = blockchain_second_password
    factory.protocol = BlockchainInfoWithdrawalProtocol

  if config.has_section('mailer'):
    from mailer_protocol import MailerWithdrawalProtocol
    factory.mandrill_apikey             = config.get("mailer", "mandrill_apikey")
    factory.mandrill_template_name      = config.get("mailer", "template_name")
    factory.mandrill_from_email         = config.get("mailer", "from_email")
    factory.mandrill_from_name          = config.get("mailer", "from_name")
    factory.mandrill_to_email           = config.get("mailer", "to_email")
    factory.mandrill_to_name            = config.get("mailer", "to_name")
    factory.mandrill_website            = config.get("mailer", "website")
    factory.protocol = MailerWithdrawalProtocol

  if should_connect_on_ssl:
    reactor.connectSSL( blinktrade_url.netloc ,  blinktrade_port , factory, ssl.ClientContextFactory() )
  else:
    reactor.connectTCP(blinktrade_url.netloc ,  blinktrade_port , factory )

  reactor.run()
开发者ID:jessejusoli,项目名称:blinktrade_withdrawer,代码行数:80,代码来源:main.py


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