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


Python TBufferedTransport.open方法代码示例

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


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

示例1: __init__

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
    def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, configuration=None, timeout=None):
        authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
        if authMechanism not in authMechanisms:
            raise NotImplementedError('authMechanism is either not supported or not implemented')
        #Must set a password for thrift, even if it doesn't need one
        #Open issue with python-sasl
        if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
            password = 'password'
        socket = TSocket(host, port)
        socket.setTimeout(timeout)
        if authMechanism == 'NOSASL':
            transport = TBufferedTransport(socket)
        else:
            sasl_mech = 'PLAIN'
            saslc = sasl.Client()
            saslc.setAttr("username", user)
            saslc.setAttr("password", password)
            if authMechanism == 'KERBEROS':
                krb_host,krb_service = self._get_krb_settings(host, configuration)
                sasl_mech = 'GSSAPI'
                saslc.setAttr("host", krb_host)
                saslc.setAttr("service", krb_service)

            saslc.init()
            transport = TSaslClientTransport(saslc, sasl_mech, socket)

        self.client = TCLIService.Client(TBinaryProtocol(transport))
        transport.open()
        res = self.client.OpenSession(TOpenSessionReq(username=user, password=password, configuration=configuration))
        self.session = res.sessionHandle
        if database is not None:
            with self.cursor() as cur:
                query = "USE {0}".format(database)
                cur.execute(query) 
开发者ID:Aireed,项目名称:pyhs2,代码行数:36,代码来源:connections.py

示例2: main

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def main(args):
    if(len(args) < 4):
        print "%s tablename column pattern output[option]"%(args[0])
        sys.exit(1)

    tablename=args[1]
    column = args[2]
    pattern = args[3]

    outputfile = ""
    if(len(args)>4):
        outputfile=args[4]
    
    getConfiguration('host.properties')
    
    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    
    global client
    client = Hbase.Client(protocol)

#    tablename = "%s_%s_master_%s"%(orgId,subOrgId,orgId)

    rowlist = columnGrep(tablename,column,pattern)
    
    print len(rowlist)
    printStdout(rowlist,outputfile)
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:30,代码来源:HbaseColumnGrep.py

示例3: main

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def main(argv):
  p = argparse.ArgumentParser()
  add_common_args(p)
  # Since THeaderTransport acts as framed transport when detected frame, we
  # cannot use --transport=framed as it would result in 2 layered frames.
  p.add_argument('--override-transport')
  p.add_argument('--override-protocol')
  args = p.parse_args()
  assert args.protocol == 'header'
  assert args.transport == 'buffered'
  assert not args.ssl

  sock = TSocket(args.host, args.port, socket_family=socket.AF_INET)
  if not args.override_transport or args.override_transport == 'buffered':
    trans = TBufferedTransport(sock)
  elif args.override_transport == 'framed':
    print('TFRAMED')
    trans = TFramedTransport(sock)
  else:
    raise ValueError('invalid transport')
  trans.open()

  if not args.override_protocol or args.override_protocol == 'binary':
    proto = TBinaryProtocol(trans)
  elif args.override_protocol == 'compact':
    proto = TCompactProtocol(trans)
  else:
    raise ValueError('invalid transport')

  test_void(proto)
  test_void(proto)

  trans.close()
开发者ID:amillerchip,项目名称:thrift,代码行数:35,代码来源:theader_binary.py

示例4: main

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def main(args):

#    getColumnInfo(table_name)            

    if(len(args)<2):
        print "TableScan.py tableName No[10]"
        sys.exit(1)

    table_name=args[1]
    NO=10;
    if(len(args)<3):
        NO=10; 
    else:
        NO=int(args[2]);

    getConfiguration('host.properties')

    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = Hbase.Client(protocol)

    ret=getRowsLimit(table_name,NO)
    printRowsResult(ret)
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:27,代码来源:TableScan.py

示例5: __init__

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
 def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, cursorclass = Cursor):
     authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
     if authMechanism not in authMechanisms or authMechanism == 'KERBEROS':
         raise NotImplementedError('authMechanism is either not supported or not implemented')
     #Must set a password for thrift, even if it doesn't need one
     #Open issue with python-sasl
     if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
         password = 'password'
     socket = TSocket(host, port)
     self.cursorclass = cursorclass
     if authMechanism == 'NOSASL':
         transport = TBufferedTransport(socket)
     else:
         saslc = sasl.Client()
         saslc.setAttr("username", user)
         saslc.setAttr("password", password)
         saslc.init()
         transport = TSaslClientTransport(saslc, "PLAIN", socket)
     self.client = TCLIService.Client(TBinaryProtocol(transport))
     transport.open()
     res = self.client.OpenSession(TOpenSessionReq())
     self.session = res.sessionHandle
     if database is not None:
         with self.cursor() as cur:
             query = "USE {0}".format(database)
             cur.execute(query) 
开发者ID:gene-peters,项目名称:kix-redshift_etl,代码行数:28,代码来源:connections.py

示例6: __init__

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
    def __init__( self, host, port ):
        transport = TBufferedTransport(TSocket(host, port))
        transport.open()
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        self.client = HBaseThrift.Client(protocol)
        self.client
开发者ID:PerilousApricot,项目名称:HBaseR,代码行数:9,代码来源:HBase.py

示例7: __init__

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
    def __init__(self,context):
        self.context=context
        self.table = self.context.config.HBASE_STORAGE_TABLE
        self.data_fam = self.context.config.HBASE_STORAGE_FAMILY
        transport = TBufferedTransport(TSocket(host=self.context.config.HBASE_STORAGE_SERVER_HOST, port=self.context.config.HBASE_STORAGE_SERVER_PORT))
        transport.open()
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        self.storage = Hbase.Client(protocol)
开发者ID:nhuray,项目名称:thumbor_hbase,代码行数:11,代码来源:storage.py

示例8: HS2TestSuite

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
class HS2TestSuite(ImpalaTestSuite):
  def setup(self):
    host, port = IMPALAD_HS2_HOST_PORT.split(":")
    self.socket = TSocket(host, port)
    self.transport = TBufferedTransport(self.socket)
    self.transport.open()
    self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
    self.hs2_client = TCLIService.Client(self.protocol)

  def teardown(self):
    if self.socket:
      self.socket.close()

  @staticmethod
  def check_response(response,
                       expected_status_code = TCLIService.TStatusCode.SUCCESS_STATUS,
                       expected_error_prefix = None):
    assert response.status.statusCode == expected_status_code
    if expected_status_code != TCLIService.TStatusCode.SUCCESS_STATUS\
       and expected_error_prefix is not None:
      assert response.status.errorMessage.startswith(expected_error_prefix)

  def close(self, op_handle):
    close_op_req = TCLIService.TCloseOperationReq()
    close_op_req.operationHandle = op_handle
    close_op_resp = self.hs2_client.CloseOperation(close_op_req)
    assert close_op_resp.status.statusCode == TCLIService.TStatusCode.SUCCESS_STATUS

  def fetch(self, handle, orientation, size, expected_num_rows = None):
    """Fetches at most size number of rows from the query identified by the given
    operation handle. Uses the given fetch orientation. Asserts that the fetch returns
    a success status, and that the number of rows returned is equal to size, or
    equal to the given expected_num_rows (it one was given)."""
    fetch_results_req = TCLIService.TFetchResultsReq()
    fetch_results_req.operationHandle = handle
    fetch_results_req.orientation = orientation
    fetch_results_req.maxRows = size
    fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req)
    HS2TestSuite.check_response(fetch_results_resp)
    num_rows = size
    if expected_num_rows is not None:
      num_rows = expected_num_rows
    assert len(fetch_results_resp.results.rows) == num_rows
    return fetch_results_resp

  def fetch_fail(self, handle, orientation, expected_error_prefix):
    """Attempts to fetch rows from the query identified by the given operation handle.
    Asserts that the fetch returns an error with an error message matching the given
    expected_error_prefix."""
    fetch_results_req = TCLIService.TFetchResultsReq()
    fetch_results_req.operationHandle = handle
    fetch_results_req.orientation = orientation
    fetch_results_req.maxRows = 100
    fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req)
    HS2TestSuite.check_response(fetch_results_resp, TCLIService.TStatusCode.ERROR_STATUS,
                                expected_error_prefix)
    return fetch_results_resp
开发者ID:AhmedKammorah,项目名称:Impala,代码行数:59,代码来源:hs2_test_suite.py

示例9: connect

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def connect(server='localhost', port=9090, timeout=None):
    socket = TSocket(server, int(port))
    if timeout is not None:
        socket.setTimeout(timeout)
    transport = TBufferedTransport(socket)
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
    client = Hbase.Client(protocol)
    return client
开发者ID:bwhite,项目名称:hadoopy_hbase,代码行数:11,代码来源:__init__.py

示例10: main

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def main(args):

    getConfiguration('host.properties')

    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = Hbase.Client(protocol)

    getTableNames()
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:13,代码来源:TableNames.py

示例11: getMasterTables

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def getMasterTables(hbaseHost):
    transport = TBufferedTransport(TSocket(hbaseHost, 9090))
    transport.open()
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    client = Hbase.Client(protocol)

    for table in client.getTableNames():
        if 'master' in table:
            print table

    transport.close()
开发者ID:blueskywalker,项目名称:lyris-mystuff,代码行数:13,代码来源:getMasterTable.py

示例12: hs2_port_is_open

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
 def hs2_port_is_open(self):
   """Test if the HS2 port is open. Does not need to authenticate."""
   # Impyla will try to authenticate as part of connecting, so preserve previous logic
   # that uses the HS2 thrift code directly.
   try:
     socket = TSocket(self.hostname, self.hs2_port)
     transport = TBufferedTransport(socket)
     transport.open()
     transport.close()
     return True
   except Exception, e:
     LOG.info(e)
     return False
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:15,代码来源:impala_service.py

示例13: start

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
def start():

    logger = logging.getLogger('ted')
    logger.addHandler(logging.StreamHandler())

    transport = TBufferedTransport(TSocket('localhost', 9030))
    transport.open()

    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    global client
    client = ted.TedService.Client(protocol)

    shell = code.InteractiveConsole(globals())
    shell.interact("Run client.<command> where command is a Ted command (eg: getWatching())\nSee dir(Iface) for commands")
开发者ID:florinspatar,项目名称:ted,代码行数:16,代码来源:ted-ui.py

示例14: __init__

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
 def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None):
     authMechanisms = {'NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'}
     if authMechanism not in authMechanisms or authMechanism == 'KERBEROS':
         raise NotImplementedError('authMechanism is either not supported or not implemented')
     socket = TSocket(host, port)
     if authMechanism == 'NOSASL':
         transport = TBufferedTransport(socket)
     else:
         saslc = sasl.Client()
         saslc.setAttr("username", user)
         saslc.setAttr("password", password)
         saslc.init()
         transport = TSaslClientTransport(saslc, "PLAIN", socket)
     self.client = TCLIService.Client(TBinaryProtocol(transport))
     transport.open()
     res = self.client.OpenSession(TOpenSessionReq())
     self.session = res.sessionHandle
开发者ID:andrewmains12,项目名称:pyhs2,代码行数:19,代码来源:connections.py

示例15: ThriftClient

# 需要导入模块: from thrift.transport.TTransport import TBufferedTransport [as 别名]
# 或者: from thrift.transport.TTransport.TBufferedTransport import open [as 别名]
class ThriftClient(object):
    def __init__(self, port=6458, host="127.0.0.1"):
        self.host = host
        self.port = port
        self.client = None
        self.transport = None

    def connect(self):
        self.transport = TSocket(self.host, self.port)
        self.transport = TBufferedTransport(self.transport)
        protocol = TBinaryProtocol(self.transport)
        self.client = Client(protocol)
        self.transport.open()

    def execute(self, name, *args, **kwargs):
        if self.client is None:
            self.connect()
        result = getattr(self.client, name)(*args, **kwargs)
        return result

    def create(self, key, second, minute = -1, hour = -1, day = -1, month = -1, week = -1, action="shell", params={}):
        return self.execute("create", key, second, minute, hour, day, month, week, action, params)

    def create_timeout(self, key, second, minute = -1, hour = -1, day = -1, month = -1, week = -1, count=1, action="shell", params={}):
        return self.execute("createTimeout", key, second, minute, hour, day, month, week, count, action, params)

    def remove(self, key):
        return self.execute("remove", key)

    def get(self, key):
        return self.execute("get", key)

    def get_current(self):
        return self.execute("getCurrent")

    def get_time(self, timestamp):
        return self.execute("getTime", timestamp)

    def get_keys(self, prefix=''):
        return self.execute("getKeys", prefix)

    def __del__(self):
        if self.client:
            self.transport.close()
            self.transport = None
            self.client = None
开发者ID:soszrg,项目名称:forsun,代码行数:48,代码来源:__init__.py


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