├── README.md ├── hbase ├── Hbase.py ├── readme └── ttypes.py ├── python3.6 ├── readme └── uuid.py ├── tensorflow_cpp ├── ann_model_loader.cpp ├── ann_model_loader.h ├── load.py ├── main.cpp ├── model_loader_base.h └── readme └── ttypes.py /README.md: -------------------------------------------------------------------------------- 1 | # infrastructure 2 | 架构相关内容 3 | -------------------------------------------------------------------------------- /hbase/readme: -------------------------------------------------------------------------------- 1 | 替换Hbase文件/usr/local/lib/python3.6/dist-packages/hbase/Hbase.py和ttypes.py 2 | -------------------------------------------------------------------------------- /hbase/ttypes.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | 7 | from thrift.Thrift import * 8 | 9 | from thrift.transport import TTransport 10 | from thrift.protocol import TBinaryProtocol 11 | try: 12 | from thrift.protocol import fastbinary 13 | except: 14 | fastbinary = None 15 | 16 | 17 | class TCell(object): 18 | """ 19 | TCell - Used to transport a cell value (byte[]) and the timestamp it was 20 | stored with together as a result for get and getRow methods. This promotes 21 | the timestamp of a cell to a first-class value, making it easy to take 22 | note of temporal data. Cell is used all the way from HStore up to HTable. 23 | 24 | Attributes: 25 | - value 26 | - timestamp 27 | """ 28 | 29 | thrift_spec = ( 30 | None, # 0 31 | (1, TType.STRING, 'value', None, None, ), # 1 32 | (2, TType.I64, 'timestamp', None, None, ), # 2 33 | ) 34 | 35 | def __init__(self, value=None, timestamp=None,): 36 | self.value = value 37 | self.timestamp = timestamp 38 | 39 | def read(self, iprot): 40 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 41 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 42 | return 43 | iprot.readStructBegin() 44 | while True: 45 | (fname, ftype, fid) = iprot.readFieldBegin() 46 | if ftype == TType.STOP: 47 | break 48 | if fid == 1: 49 | if ftype == TType.STRING: 50 | self.value = iprot.readString(); 51 | else: 52 | iprot.skip(ftype) 53 | elif fid == 2: 54 | if ftype == TType.I64: 55 | self.timestamp = iprot.readI64(); 56 | else: 57 | iprot.skip(ftype) 58 | else: 59 | iprot.skip(ftype) 60 | iprot.readFieldEnd() 61 | iprot.readStructEnd() 62 | 63 | def write(self, oprot): 64 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 65 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 66 | return 67 | oprot.writeStructBegin('TCell') 68 | if self.value != None: 69 | oprot.writeFieldBegin('value', TType.STRING, 1) 70 | oprot.writeString(self.value) 71 | oprot.writeFieldEnd() 72 | if self.timestamp != None: 73 | oprot.writeFieldBegin('timestamp', TType.I64, 2) 74 | oprot.writeI64(self.timestamp) 75 | oprot.writeFieldEnd() 76 | oprot.writeFieldStop() 77 | oprot.writeStructEnd() 78 | 79 | def __repr__(self): 80 | L = ['%s=%r' % (key, value) 81 | for key, value in self.__dict__.items()] 82 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 83 | 84 | def __eq__(self, other): 85 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 86 | 87 | def __ne__(self, other): 88 | return not (self == other) 89 | 90 | class ColumnDescriptor(object): 91 | """ 92 | An HColumnDescriptor contains information about a column family 93 | such as the number of versions, compression settings, etc. It is 94 | used as input when creating a table or adding a column. 95 | 96 | Attributes: 97 | - name 98 | - maxVersions 99 | - compression 100 | - inMemory 101 | - bloomFilterType 102 | - bloomFilterVectorSize 103 | - bloomFilterNbHashes 104 | - blockCacheEnabled 105 | - timeToLive 106 | """ 107 | 108 | thrift_spec = ( 109 | None, # 0 110 | (1, TType.STRING, 'name', None, None, ), # 1 111 | (2, TType.I32, 'maxVersions', None, 3, ), # 2 112 | (3, TType.STRING, 'compression', None, "NONE", ), # 3 113 | (4, TType.BOOL, 'inMemory', None, False, ), # 4 114 | (5, TType.STRING, 'bloomFilterType', None, "NONE", ), # 5 115 | (6, TType.I32, 'bloomFilterVectorSize', None, 0, ), # 6 116 | (7, TType.I32, 'bloomFilterNbHashes', None, 0, ), # 7 117 | (8, TType.BOOL, 'blockCacheEnabled', None, False, ), # 8 118 | (9, TType.I32, 'timeToLive', None, -1, ), # 9 119 | ) 120 | 121 | def __init__(self, name=None, maxVersions=thrift_spec[2][4], compression=thrift_spec[3][4], inMemory=thrift_spec[4][4], bloomFilterType=thrift_spec[5][4], bloomFilterVectorSize=thrift_spec[6][4], bloomFilterNbHashes=thrift_spec[7][4], blockCacheEnabled=thrift_spec[8][4], timeToLive=thrift_spec[9][4],): 122 | self.name = name 123 | self.maxVersions = maxVersions 124 | self.compression = compression 125 | self.inMemory = inMemory 126 | self.bloomFilterType = bloomFilterType 127 | self.bloomFilterVectorSize = bloomFilterVectorSize 128 | self.bloomFilterNbHashes = bloomFilterNbHashes 129 | self.blockCacheEnabled = blockCacheEnabled 130 | self.timeToLive = timeToLive 131 | 132 | def read(self, iprot): 133 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 134 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 135 | return 136 | iprot.readStructBegin() 137 | while True: 138 | (fname, ftype, fid) = iprot.readFieldBegin() 139 | if ftype == TType.STOP: 140 | break 141 | if fid == 1: 142 | if ftype == TType.STRING: 143 | self.name = iprot.readString(); 144 | else: 145 | iprot.skip(ftype) 146 | elif fid == 2: 147 | if ftype == TType.I32: 148 | self.maxVersions = iprot.readI32(); 149 | else: 150 | iprot.skip(ftype) 151 | elif fid == 3: 152 | if ftype == TType.STRING: 153 | self.compression = iprot.readString(); 154 | else: 155 | iprot.skip(ftype) 156 | elif fid == 4: 157 | if ftype == TType.BOOL: 158 | self.inMemory = iprot.readBool(); 159 | else: 160 | iprot.skip(ftype) 161 | elif fid == 5: 162 | if ftype == TType.STRING: 163 | self.bloomFilterType = iprot.readString(); 164 | else: 165 | iprot.skip(ftype) 166 | elif fid == 6: 167 | if ftype == TType.I32: 168 | self.bloomFilterVectorSize = iprot.readI32(); 169 | else: 170 | iprot.skip(ftype) 171 | elif fid == 7: 172 | if ftype == TType.I32: 173 | self.bloomFilterNbHashes = iprot.readI32(); 174 | else: 175 | iprot.skip(ftype) 176 | elif fid == 8: 177 | if ftype == TType.BOOL: 178 | self.blockCacheEnabled = iprot.readBool(); 179 | else: 180 | iprot.skip(ftype) 181 | elif fid == 9: 182 | if ftype == TType.I32: 183 | self.timeToLive = iprot.readI32(); 184 | else: 185 | iprot.skip(ftype) 186 | else: 187 | iprot.skip(ftype) 188 | iprot.readFieldEnd() 189 | iprot.readStructEnd() 190 | 191 | def write(self, oprot): 192 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 193 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 194 | return 195 | oprot.writeStructBegin('ColumnDescriptor') 196 | if self.name != None: 197 | oprot.writeFieldBegin('name', TType.STRING, 1) 198 | oprot.writeString(self.name) 199 | oprot.writeFieldEnd() 200 | if self.maxVersions != None: 201 | oprot.writeFieldBegin('maxVersions', TType.I32, 2) 202 | oprot.writeI32(self.maxVersions) 203 | oprot.writeFieldEnd() 204 | if self.compression != None: 205 | oprot.writeFieldBegin('compression', TType.STRING, 3) 206 | oprot.writeString(self.compression) 207 | oprot.writeFieldEnd() 208 | if self.inMemory != None: 209 | oprot.writeFieldBegin('inMemory', TType.BOOL, 4) 210 | oprot.writeBool(self.inMemory) 211 | oprot.writeFieldEnd() 212 | if self.bloomFilterType != None: 213 | oprot.writeFieldBegin('bloomFilterType', TType.STRING, 5) 214 | oprot.writeString(self.bloomFilterType) 215 | oprot.writeFieldEnd() 216 | if self.bloomFilterVectorSize != None: 217 | oprot.writeFieldBegin('bloomFilterVectorSize', TType.I32, 6) 218 | oprot.writeI32(self.bloomFilterVectorSize) 219 | oprot.writeFieldEnd() 220 | if self.bloomFilterNbHashes != None: 221 | oprot.writeFieldBegin('bloomFilterNbHashes', TType.I32, 7) 222 | oprot.writeI32(self.bloomFilterNbHashes) 223 | oprot.writeFieldEnd() 224 | if self.blockCacheEnabled != None: 225 | oprot.writeFieldBegin('blockCacheEnabled', TType.BOOL, 8) 226 | oprot.writeBool(self.blockCacheEnabled) 227 | oprot.writeFieldEnd() 228 | if self.timeToLive != None: 229 | oprot.writeFieldBegin('timeToLive', TType.I32, 9) 230 | oprot.writeI32(self.timeToLive) 231 | oprot.writeFieldEnd() 232 | oprot.writeFieldStop() 233 | oprot.writeStructEnd() 234 | 235 | def __repr__(self): 236 | L = ['%s=%r' % (key, value) 237 | for key, value in self.__dict__.items()] 238 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 239 | 240 | def __eq__(self, other): 241 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 242 | 243 | def __ne__(self, other): 244 | return not (self == other) 245 | 246 | class TRegionInfo(object): 247 | """ 248 | A TRegionInfo contains information about an HTable region. 249 | 250 | Attributes: 251 | - startKey 252 | - endKey 253 | - id 254 | - name 255 | - version 256 | """ 257 | 258 | thrift_spec = ( 259 | None, # 0 260 | (1, TType.STRING, 'startKey', None, None, ), # 1 261 | (2, TType.STRING, 'endKey', None, None, ), # 2 262 | (3, TType.I64, 'id', None, None, ), # 3 263 | (4, TType.STRING, 'name', None, None, ), # 4 264 | (5, TType.BYTE, 'version', None, None, ), # 5 265 | ) 266 | 267 | def __init__(self, startKey=None, endKey=None, id=None, name=None, version=None,): 268 | self.startKey = startKey 269 | self.endKey = endKey 270 | self.id = id 271 | self.name = name 272 | self.version = version 273 | 274 | def read(self, iprot): 275 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 276 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 277 | return 278 | iprot.readStructBegin() 279 | while True: 280 | (fname, ftype, fid) = iprot.readFieldBegin() 281 | if ftype == TType.STOP: 282 | break 283 | if fid == 1: 284 | if ftype == TType.STRING: 285 | self.startKey = iprot.readString(); 286 | else: 287 | iprot.skip(ftype) 288 | elif fid == 2: 289 | if ftype == TType.STRING: 290 | self.endKey = iprot.readString(); 291 | else: 292 | iprot.skip(ftype) 293 | elif fid == 3: 294 | if ftype == TType.I64: 295 | self.id = iprot.readI64(); 296 | else: 297 | iprot.skip(ftype) 298 | elif fid == 4: 299 | if ftype == TType.STRING: 300 | self.name = iprot.readString(); 301 | else: 302 | iprot.skip(ftype) 303 | elif fid == 5: 304 | if ftype == TType.BYTE: 305 | self.version = iprot.readByte(); 306 | else: 307 | iprot.skip(ftype) 308 | else: 309 | iprot.skip(ftype) 310 | iprot.readFieldEnd() 311 | iprot.readStructEnd() 312 | 313 | def write(self, oprot): 314 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 315 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 316 | return 317 | oprot.writeStructBegin('TRegionInfo') 318 | if self.startKey != None: 319 | oprot.writeFieldBegin('startKey', TType.STRING, 1) 320 | oprot.writeString(self.startKey) 321 | oprot.writeFieldEnd() 322 | if self.endKey != None: 323 | oprot.writeFieldBegin('endKey', TType.STRING, 2) 324 | oprot.writeString(self.endKey) 325 | oprot.writeFieldEnd() 326 | if self.id != None: 327 | oprot.writeFieldBegin('id', TType.I64, 3) 328 | oprot.writeI64(self.id) 329 | oprot.writeFieldEnd() 330 | if self.name != None: 331 | oprot.writeFieldBegin('name', TType.STRING, 4) 332 | oprot.writeString(self.name) 333 | oprot.writeFieldEnd() 334 | if self.version != None: 335 | oprot.writeFieldBegin('version', TType.BYTE, 5) 336 | oprot.writeByte(self.version) 337 | oprot.writeFieldEnd() 338 | oprot.writeFieldStop() 339 | oprot.writeStructEnd() 340 | 341 | def __repr__(self): 342 | L = ['%s=%r' % (key, value) 343 | for key, value in self.__dict__.items()] 344 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 345 | 346 | def __eq__(self, other): 347 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 348 | 349 | def __ne__(self, other): 350 | return not (self == other) 351 | 352 | class Mutation(object): 353 | """ 354 | A Mutation object is used to either update or delete a column-value. 355 | 356 | Attributes: 357 | - isDelete 358 | - column 359 | - value 360 | """ 361 | 362 | thrift_spec = ( 363 | None, # 0 364 | (1, TType.BOOL, 'isDelete', None, False, ), # 1 365 | (2, TType.STRING, 'column', None, None, ), # 2 366 | (3, TType.STRING, 'value', None, None, ), # 3 367 | ) 368 | 369 | def __init__(self, isDelete=thrift_spec[1][4], column=None, value=None,): 370 | self.isDelete = isDelete 371 | self.column = column 372 | self.value = value 373 | 374 | def read(self, iprot): 375 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 376 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 377 | return 378 | iprot.readStructBegin() 379 | while True: 380 | (fname, ftype, fid) = iprot.readFieldBegin() 381 | if ftype == TType.STOP: 382 | break 383 | if fid == 1: 384 | if ftype == TType.BOOL: 385 | self.isDelete = iprot.readBool(); 386 | else: 387 | iprot.skip(ftype) 388 | elif fid == 2: 389 | if ftype == TType.STRING: 390 | self.column = iprot.readString(); 391 | else: 392 | iprot.skip(ftype) 393 | elif fid == 3: 394 | if ftype == TType.STRING: 395 | self.value = iprot.readString(); 396 | else: 397 | iprot.skip(ftype) 398 | else: 399 | iprot.skip(ftype) 400 | iprot.readFieldEnd() 401 | iprot.readStructEnd() 402 | 403 | def write(self, oprot): 404 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 405 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 406 | return 407 | oprot.writeStructBegin('Mutation') 408 | if self.isDelete != None: 409 | oprot.writeFieldBegin('isDelete', TType.BOOL, 1) 410 | oprot.writeBool(self.isDelete) 411 | oprot.writeFieldEnd() 412 | if self.column != None: 413 | oprot.writeFieldBegin('column', TType.STRING, 2) 414 | oprot.writeString(self.column) 415 | oprot.writeFieldEnd() 416 | if self.value != None: 417 | oprot.writeFieldBegin('value', TType.STRING, 3) 418 | oprot.writeString(self.value) 419 | oprot.writeFieldEnd() 420 | oprot.writeFieldStop() 421 | oprot.writeStructEnd() 422 | 423 | def __repr__(self): 424 | L = ['%s=%r' % (key, value) 425 | for key, value in self.__dict__.items()] 426 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 427 | 428 | def __eq__(self, other): 429 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 430 | 431 | def __ne__(self, other): 432 | return not (self == other) 433 | 434 | class BatchMutation(object): 435 | """ 436 | A BatchMutation object is used to apply a number of Mutations to a single row. 437 | 438 | Attributes: 439 | - row 440 | - mutations 441 | """ 442 | 443 | thrift_spec = ( 444 | None, # 0 445 | (1, TType.STRING, 'row', None, None, ), # 1 446 | (2, TType.LIST, 'mutations', (TType.STRUCT,(Mutation, Mutation.thrift_spec)), None, ), # 2 447 | ) 448 | 449 | def __init__(self, row=None, mutations=None,): 450 | self.row = row 451 | self.mutations = mutations 452 | 453 | def read(self, iprot): 454 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 455 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 456 | return 457 | iprot.readStructBegin() 458 | while True: 459 | (fname, ftype, fid) = iprot.readFieldBegin() 460 | if ftype == TType.STOP: 461 | break 462 | if fid == 1: 463 | if ftype == TType.STRING: 464 | self.row = iprot.readString(); 465 | else: 466 | iprot.skip(ftype) 467 | elif fid == 2: 468 | if ftype == TType.LIST: 469 | self.mutations = [] 470 | (_etype3, _size0) = iprot.readListBegin() 471 | for _i4 in range(_size0): 472 | _elem5 = Mutation() 473 | _elem5.read(iprot) 474 | self.mutations.append(_elem5) 475 | iprot.readListEnd() 476 | else: 477 | iprot.skip(ftype) 478 | else: 479 | iprot.skip(ftype) 480 | iprot.readFieldEnd() 481 | iprot.readStructEnd() 482 | 483 | def write(self, oprot): 484 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 485 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 486 | return 487 | oprot.writeStructBegin('BatchMutation') 488 | if self.row != None: 489 | oprot.writeFieldBegin('row', TType.STRING, 1) 490 | oprot.writeString(self.row) 491 | oprot.writeFieldEnd() 492 | if self.mutations != None: 493 | oprot.writeFieldBegin('mutations', TType.LIST, 2) 494 | oprot.writeListBegin(TType.STRUCT, len(self.mutations)) 495 | for iter6 in self.mutations: 496 | iter6.write(oprot) 497 | oprot.writeListEnd() 498 | oprot.writeFieldEnd() 499 | oprot.writeFieldStop() 500 | oprot.writeStructEnd() 501 | 502 | def __repr__(self): 503 | L = ['%s=%r' % (key, value) 504 | for key, value in self.__dict__.items()] 505 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 506 | 507 | def __eq__(self, other): 508 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 509 | 510 | def __ne__(self, other): 511 | return not (self == other) 512 | 513 | class TRowResult(object): 514 | """ 515 | Holds row name and then a map of columns to cells. 516 | 517 | Attributes: 518 | - row 519 | - columns 520 | """ 521 | 522 | thrift_spec = ( 523 | None, # 0 524 | (1, TType.STRING, 'row', None, None, ), # 1 525 | (2, TType.MAP, 'columns', (TType.STRING,None,TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 2 526 | ) 527 | 528 | def __init__(self, row=None, columns=None,): 529 | self.row = row 530 | self.columns = columns 531 | 532 | def read(self, iprot): 533 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 534 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 535 | return 536 | iprot.readStructBegin() 537 | while True: 538 | (fname, ftype, fid) = iprot.readFieldBegin() 539 | if ftype == TType.STOP: 540 | break 541 | if fid == 1: 542 | if ftype == TType.STRING: 543 | self.row = iprot.readString(); 544 | else: 545 | iprot.skip(ftype) 546 | elif fid == 2: 547 | if ftype == TType.MAP: 548 | self.columns = {} 549 | (_ktype8, _vtype9, _size7 ) = iprot.readMapBegin() 550 | for _i11 in range(_size7): 551 | _key12 = iprot.readString(); 552 | _val13 = TCell() 553 | _val13.read(iprot) 554 | self.columns[_key12] = _val13 555 | iprot.readMapEnd() 556 | else: 557 | iprot.skip(ftype) 558 | else: 559 | iprot.skip(ftype) 560 | iprot.readFieldEnd() 561 | iprot.readStructEnd() 562 | 563 | def write(self, oprot): 564 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 565 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 566 | return 567 | oprot.writeStructBegin('TRowResult') 568 | if self.row != None: 569 | oprot.writeFieldBegin('row', TType.STRING, 1) 570 | oprot.writeString(self.row) 571 | oprot.writeFieldEnd() 572 | if self.columns != None: 573 | oprot.writeFieldBegin('columns', TType.MAP, 2) 574 | oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.columns)) 575 | for kiter14,viter15 in self.columns.items(): 576 | oprot.writeString(kiter14) 577 | viter15.write(oprot) 578 | oprot.writeMapEnd() 579 | oprot.writeFieldEnd() 580 | oprot.writeFieldStop() 581 | oprot.writeStructEnd() 582 | 583 | def __repr__(self): 584 | L = ['%s=%r' % (key, value) 585 | for key, value in self.__dict__.items()] 586 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 587 | 588 | def __eq__(self, other): 589 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 590 | 591 | def __ne__(self, other): 592 | return not (self == other) 593 | 594 | class IOError(Exception): 595 | """ 596 | An IOError exception signals that an error occurred communicating 597 | to the Hbase master or an Hbase region server. Also used to return 598 | more general Hbase error conditions. 599 | 600 | Attributes: 601 | - message 602 | """ 603 | 604 | thrift_spec = ( 605 | None, # 0 606 | (1, TType.STRING, 'message', None, None, ), # 1 607 | ) 608 | 609 | def __init__(self, message=None,): 610 | self.message = message 611 | 612 | def read(self, iprot): 613 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 614 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 615 | return 616 | iprot.readStructBegin() 617 | while True: 618 | (fname, ftype, fid) = iprot.readFieldBegin() 619 | if ftype == TType.STOP: 620 | break 621 | if fid == 1: 622 | if ftype == TType.STRING: 623 | self.message = iprot.readString(); 624 | else: 625 | iprot.skip(ftype) 626 | else: 627 | iprot.skip(ftype) 628 | iprot.readFieldEnd() 629 | iprot.readStructEnd() 630 | 631 | def write(self, oprot): 632 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 633 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 634 | return 635 | oprot.writeStructBegin('IOError') 636 | if self.message != None: 637 | oprot.writeFieldBegin('message', TType.STRING, 1) 638 | oprot.writeString(self.message) 639 | oprot.writeFieldEnd() 640 | oprot.writeFieldStop() 641 | oprot.writeStructEnd() 642 | 643 | def __str__(self): 644 | return repr(self) 645 | 646 | def __repr__(self): 647 | L = ['%s=%r' % (key, value) 648 | for key, value in self.__dict__.items()] 649 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 650 | 651 | def __eq__(self, other): 652 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 653 | 654 | def __ne__(self, other): 655 | return not (self == other) 656 | 657 | class IllegalArgument(Exception): 658 | """ 659 | An IllegalArgument exception indicates an illegal or invalid 660 | argument was passed into a procedure. 661 | 662 | Attributes: 663 | - message 664 | """ 665 | 666 | thrift_spec = ( 667 | None, # 0 668 | (1, TType.STRING, 'message', None, None, ), # 1 669 | ) 670 | 671 | def __init__(self, message=None,): 672 | self.message = message 673 | 674 | def read(self, iprot): 675 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 676 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 677 | return 678 | iprot.readStructBegin() 679 | while True: 680 | (fname, ftype, fid) = iprot.readFieldBegin() 681 | if ftype == TType.STOP: 682 | break 683 | if fid == 1: 684 | if ftype == TType.STRING: 685 | self.message = iprot.readString(); 686 | else: 687 | iprot.skip(ftype) 688 | else: 689 | iprot.skip(ftype) 690 | iprot.readFieldEnd() 691 | iprot.readStructEnd() 692 | 693 | def write(self, oprot): 694 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 695 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 696 | return 697 | oprot.writeStructBegin('IllegalArgument') 698 | if self.message != None: 699 | oprot.writeFieldBegin('message', TType.STRING, 1) 700 | oprot.writeString(self.message) 701 | oprot.writeFieldEnd() 702 | oprot.writeFieldStop() 703 | oprot.writeStructEnd() 704 | 705 | def __str__(self): 706 | return repr(self) 707 | 708 | def __repr__(self): 709 | L = ['%s=%r' % (key, value) 710 | for key, value in self.__dict__.items()] 711 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 712 | 713 | def __eq__(self, other): 714 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 715 | 716 | def __ne__(self, other): 717 | return not (self == other) 718 | 719 | class AlreadyExists(Exception): 720 | """ 721 | An AlreadyExists exceptions signals that a table with the specified 722 | name already exists 723 | 724 | Attributes: 725 | - message 726 | """ 727 | 728 | thrift_spec = ( 729 | None, # 0 730 | (1, TType.STRING, 'message', None, None, ), # 1 731 | ) 732 | 733 | def __init__(self, message=None,): 734 | self.message = message 735 | 736 | def read(self, iprot): 737 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 738 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 739 | return 740 | iprot.readStructBegin() 741 | while True: 742 | (fname, ftype, fid) = iprot.readFieldBegin() 743 | if ftype == TType.STOP: 744 | break 745 | if fid == 1: 746 | if ftype == TType.STRING: 747 | self.message = iprot.readString(); 748 | else: 749 | iprot.skip(ftype) 750 | else: 751 | iprot.skip(ftype) 752 | iprot.readFieldEnd() 753 | iprot.readStructEnd() 754 | 755 | def write(self, oprot): 756 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 757 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 758 | return 759 | oprot.writeStructBegin('AlreadyExists') 760 | if self.message != None: 761 | oprot.writeFieldBegin('message', TType.STRING, 1) 762 | oprot.writeString(self.message) 763 | oprot.writeFieldEnd() 764 | oprot.writeFieldStop() 765 | oprot.writeStructEnd() 766 | 767 | def __str__(self): 768 | return repr(self) 769 | 770 | def __repr__(self): 771 | L = ['%s=%r' % (key, value) 772 | for key, value in self.__dict__.items()] 773 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 774 | 775 | def __eq__(self, other): 776 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 777 | 778 | def __ne__(self, other): 779 | return not (self == other) 780 | 781 | -------------------------------------------------------------------------------- /python3.6/readme: -------------------------------------------------------------------------------- 1 | python3.6相关的文件或者升级文件 2 | -------------------------------------------------------------------------------- /python3.6/uuid.py: -------------------------------------------------------------------------------- 1 | r"""UUID objects (universally unique identifiers) according to RFC 4122. 2 | 3 | This module provides immutable UUID objects (class UUID) and the functions 4 | uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 5 | UUIDs as specified in RFC 4122. 6 | 7 | If all you want is a unique ID, you should probably call uuid1() or uuid4(). 8 | Note that uuid1() may compromise privacy since it creates a UUID containing 9 | the computer's network address. uuid4() creates a random UUID. 10 | 11 | Typical usage: 12 | 13 | >>> import uuid 14 | 15 | # make a UUID based on the host ID and current time 16 | >>> uuid.uuid1() # doctest: +SKIP 17 | UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') 18 | 19 | # make a UUID using an MD5 hash of a namespace UUID and a name 20 | >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org') 21 | UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') 22 | 23 | # make a random UUID 24 | >>> uuid.uuid4() # doctest: +SKIP 25 | UUID('16fd2706-8baf-433b-82eb-8c7fada847da') 26 | 27 | # make a UUID using a SHA-1 hash of a namespace UUID and a name 28 | >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org') 29 | UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') 30 | 31 | # make a UUID from a string of hex digits (braces and hyphens ignored) 32 | >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}') 33 | 34 | # convert a UUID to a string of hex digits in standard form 35 | >>> str(x) 36 | '00010203-0405-0607-0809-0a0b0c0d0e0f' 37 | 38 | # get the raw 16 bytes of the UUID 39 | >>> x.bytes 40 | b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' 41 | 42 | # make a UUID from a 16-byte string 43 | >>> uuid.UUID(bytes=x.bytes) 44 | UUID('00010203-0405-0607-0809-0a0b0c0d0e0f') 45 | """ 46 | 47 | import os 48 | 49 | __author__ = 'Ka-Ping Yee ' 50 | 51 | RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [ 52 | 'reserved for NCS compatibility', 'specified in RFC 4122', 53 | 'reserved for Microsoft compatibility', 'reserved for future definition'] 54 | 55 | int_ = int # The built-in int type 56 | bytes_ = bytes # The built-in bytes type 57 | 58 | class UUID(object): 59 | """Instances of the UUID class represent UUIDs as specified in RFC 4122. 60 | UUID objects are immutable, hashable, and usable as dictionary keys. 61 | Converting a UUID to a string with str() yields something in the form 62 | '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts 63 | five possible forms: a similar string of hexadecimal digits, or a tuple 64 | of six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and 65 | 48-bit values respectively) as an argument named 'fields', or a string 66 | of 16 bytes (with all the integer fields in big-endian order) as an 67 | argument named 'bytes', or a string of 16 bytes (with the first three 68 | fields in little-endian order) as an argument named 'bytes_le', or a 69 | single 128-bit integer as an argument named 'int'. 70 | 71 | UUIDs have these read-only attributes: 72 | 73 | bytes the UUID as a 16-byte string (containing the six 74 | integer fields in big-endian byte order) 75 | 76 | bytes_le the UUID as a 16-byte string (with time_low, time_mid, 77 | and time_hi_version in little-endian byte order) 78 | 79 | fields a tuple of the six integer fields of the UUID, 80 | which are also available as six individual attributes 81 | and two derived attributes: 82 | 83 | time_low the first 32 bits of the UUID 84 | time_mid the next 16 bits of the UUID 85 | time_hi_version the next 16 bits of the UUID 86 | clock_seq_hi_variant the next 8 bits of the UUID 87 | clock_seq_low the next 8 bits of the UUID 88 | node the last 48 bits of the UUID 89 | 90 | time the 60-bit timestamp 91 | clock_seq the 14-bit sequence number 92 | 93 | hex the UUID as a 32-character hexadecimal string 94 | 95 | int the UUID as a 128-bit integer 96 | 97 | urn the UUID as a URN as specified in RFC 4122 98 | 99 | variant the UUID variant (one of the constants RESERVED_NCS, 100 | RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE) 101 | 102 | version the UUID version number (1 through 5, meaningful only 103 | when the variant is RFC_4122) 104 | """ 105 | 106 | def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, 107 | int=None, version=None): 108 | r"""Create a UUID from either a string of 32 hexadecimal digits, 109 | a string of 16 bytes as the 'bytes' argument, a string of 16 bytes 110 | in little-endian order as the 'bytes_le' argument, a tuple of six 111 | integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version, 112 | 8-bit clock_seq_hi_variant, 8-bit clock_seq_low, 48-bit node) as 113 | the 'fields' argument, or a single 128-bit integer as the 'int' 114 | argument. When a string of hex digits is given, curly braces, 115 | hyphens, and a URN prefix are all optional. For example, these 116 | expressions all yield the same UUID: 117 | 118 | UUID('{12345678-1234-5678-1234-567812345678}') 119 | UUID('12345678123456781234567812345678') 120 | UUID('urn:uuid:12345678-1234-5678-1234-567812345678') 121 | UUID(bytes='\x12\x34\x56\x78'*4) 122 | UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' + 123 | '\x12\x34\x56\x78\x12\x34\x56\x78') 124 | UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) 125 | UUID(int=0x12345678123456781234567812345678) 126 | 127 | Exactly one of 'hex', 'bytes', 'bytes_le', 'fields', or 'int' must 128 | be given. The 'version' argument is optional; if given, the resulting 129 | UUID will have its variant and version set according to RFC 4122, 130 | overriding the given 'hex', 'bytes', 'bytes_le', 'fields', or 'int'. 131 | """ 132 | 133 | if [hex, bytes, bytes_le, fields, int].count(None) != 4: 134 | raise TypeError('one of the hex, bytes, bytes_le, fields, ' 135 | 'or int arguments must be given') 136 | if hex is not None: 137 | hex = hex.replace('urn:', '').replace('uuid:', '') 138 | hex = hex.strip('{}').replace('-', '') 139 | if len(hex) != 32: 140 | raise ValueError('badly formed hexadecimal UUID string') 141 | int = int_(hex, 16) 142 | if bytes_le is not None: 143 | if len(bytes_le) != 16: 144 | raise ValueError('bytes_le is not a 16-char string') 145 | bytes = (bytes_le[4-1::-1] + bytes_le[6-1:4-1:-1] + 146 | bytes_le[8-1:6-1:-1] + bytes_le[8:]) 147 | if bytes is not None: 148 | if len(bytes) != 16: 149 | raise ValueError('bytes is not a 16-char string') 150 | assert isinstance(bytes, bytes_), repr(bytes) 151 | int = int_.from_bytes(bytes, byteorder='big') 152 | if fields is not None: 153 | if len(fields) != 6: 154 | raise ValueError('fields is not a 6-tuple') 155 | (time_low, time_mid, time_hi_version, 156 | clock_seq_hi_variant, clock_seq_low, node) = fields 157 | if not 0 <= time_low < 1<<32: 158 | raise ValueError('field 1 out of range (need a 32-bit value)') 159 | if not 0 <= time_mid < 1<<16: 160 | raise ValueError('field 2 out of range (need a 16-bit value)') 161 | if not 0 <= time_hi_version < 1<<16: 162 | raise ValueError('field 3 out of range (need a 16-bit value)') 163 | if not 0 <= clock_seq_hi_variant < 1<<8: 164 | raise ValueError('field 4 out of range (need an 8-bit value)') 165 | if not 0 <= clock_seq_low < 1<<8: 166 | raise ValueError('field 5 out of range (need an 8-bit value)') 167 | if not 0 <= node < 1<<48: 168 | raise ValueError('field 6 out of range (need a 48-bit value)') 169 | clock_seq = (clock_seq_hi_variant << 8) | clock_seq_low 170 | int = ((time_low << 96) | (time_mid << 80) | 171 | (time_hi_version << 64) | (clock_seq << 48) | node) 172 | if int is not None: 173 | if not 0 <= int < 1<<128: 174 | raise ValueError('int is out of range (need a 128-bit value)') 175 | if version is not None: 176 | if not 1 <= version <= 5: 177 | raise ValueError('illegal version number') 178 | # Set the variant to RFC 4122. 179 | int &= ~(0xc000 << 48) 180 | int |= 0x8000 << 48 181 | # Set the version number. 182 | int &= ~(0xf000 << 64) 183 | int |= version << 76 184 | self.__dict__['int'] = int 185 | 186 | def __eq__(self, other): 187 | if isinstance(other, UUID): 188 | return self.int == other.int 189 | return NotImplemented 190 | 191 | # Q. What's the value of being able to sort UUIDs? 192 | # A. Use them as keys in a B-Tree or similar mapping. 193 | 194 | def __lt__(self, other): 195 | if isinstance(other, UUID): 196 | return self.int < other.int 197 | return NotImplemented 198 | 199 | def __gt__(self, other): 200 | if isinstance(other, UUID): 201 | return self.int > other.int 202 | return NotImplemented 203 | 204 | def __le__(self, other): 205 | if isinstance(other, UUID): 206 | return self.int <= other.int 207 | return NotImplemented 208 | 209 | def __ge__(self, other): 210 | if isinstance(other, UUID): 211 | return self.int >= other.int 212 | return NotImplemented 213 | 214 | def __hash__(self): 215 | return hash(self.int) 216 | 217 | def __int__(self): 218 | return self.int 219 | 220 | def __repr__(self): 221 | return '%s(%r)' % (self.__class__.__name__, str(self)) 222 | 223 | def __setattr__(self, name, value): 224 | raise TypeError('UUID objects are immutable') 225 | 226 | def __str__(self): 227 | hex = '%032x' % self.int 228 | return '%s-%s-%s-%s-%s' % ( 229 | hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:]) 230 | 231 | @property 232 | def bytes(self): 233 | return self.int.to_bytes(16, 'big') 234 | 235 | @property 236 | def bytes_le(self): 237 | bytes = self.bytes 238 | return (bytes[4-1::-1] + bytes[6-1:4-1:-1] + bytes[8-1:6-1:-1] + 239 | bytes[8:]) 240 | 241 | @property 242 | def fields(self): 243 | return (self.time_low, self.time_mid, self.time_hi_version, 244 | self.clock_seq_hi_variant, self.clock_seq_low, self.node) 245 | 246 | @property 247 | def time_low(self): 248 | return self.int >> 96 249 | 250 | @property 251 | def time_mid(self): 252 | return (self.int >> 80) & 0xffff 253 | 254 | @property 255 | def time_hi_version(self): 256 | return (self.int >> 64) & 0xffff 257 | 258 | @property 259 | def clock_seq_hi_variant(self): 260 | return (self.int >> 56) & 0xff 261 | 262 | @property 263 | def clock_seq_low(self): 264 | return (self.int >> 48) & 0xff 265 | 266 | @property 267 | def time(self): 268 | return (((self.time_hi_version & 0x0fff) << 48) | 269 | (self.time_mid << 32) | self.time_low) 270 | 271 | @property 272 | def clock_seq(self): 273 | return (((self.clock_seq_hi_variant & 0x3f) << 8) | 274 | self.clock_seq_low) 275 | 276 | @property 277 | def node(self): 278 | return self.int & 0xffffffffffff 279 | 280 | @property 281 | def hex(self): 282 | return '%032x' % self.int 283 | 284 | @property 285 | def urn(self): 286 | return 'urn:uuid:' + str(self) 287 | 288 | @property 289 | def variant(self): 290 | if not self.int & (0x8000 << 48): 291 | return RESERVED_NCS 292 | elif not self.int & (0x4000 << 48): 293 | return RFC_4122 294 | elif not self.int & (0x2000 << 48): 295 | return RESERVED_MICROSOFT 296 | else: 297 | return RESERVED_FUTURE 298 | 299 | @property 300 | def version(self): 301 | # The version bits are only meaningful for RFC 4122 UUIDs. 302 | if self.variant == RFC_4122: 303 | return int((self.int >> 76) & 0xf) 304 | 305 | def _popen(command, *args): 306 | import os, shutil, subprocess 307 | executable = shutil.which(command) 308 | if executable is None: 309 | path = os.pathsep.join(('/sbin', '/usr/sbin')) 310 | executable = shutil.which(command, path=path) 311 | if executable is None: 312 | return None 313 | # LC_ALL=C to ensure English output, stderr=DEVNULL to prevent output 314 | # on stderr (Note: we don't have an example where the words we search 315 | # for are actually localized, but in theory some system could do so.) 316 | env = dict(os.environ) 317 | env['LC_ALL'] = 'C' 318 | proc = subprocess.Popen((executable,) + args, 319 | stdout=subprocess.PIPE, 320 | stderr=subprocess.DEVNULL, 321 | env=env) 322 | return proc 323 | 324 | def _find_mac(command, args, hw_identifiers, get_index): 325 | try: 326 | proc = _popen(command, *args.split()) 327 | if not proc: 328 | return 329 | with proc: 330 | for line in proc.stdout: 331 | words = line.lower().rstrip().split() 332 | for i in range(len(words)): 333 | if words[i] in hw_identifiers: 334 | try: 335 | word = words[get_index(i)] 336 | mac = int(word.replace(b':', b''), 16) 337 | if mac: 338 | return mac 339 | except (ValueError, IndexError): 340 | # Virtual interfaces, such as those provided by 341 | # VPNs, do not have a colon-delimited MAC address 342 | # as expected, but a 16-byte HWAddr separated by 343 | # dashes. These should be ignored in favor of a 344 | # real MAC address 345 | pass 346 | except OSError: 347 | pass 348 | 349 | def _ifconfig_getnode(): 350 | """Get the hardware address on Unix by running ifconfig.""" 351 | # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes. 352 | for args in ('', '-a', '-av'): 353 | mac = _find_mac('ifconfig', args, [b'hwaddr', b'ether'], lambda i: i+1) 354 | if mac: 355 | return mac 356 | 357 | def _ip_getnode(): 358 | """Get the hardware address on Unix by running ip.""" 359 | # This works on Linux with iproute2. 360 | mac = _find_mac('ip', 'link list', [b'link/ether'], lambda i: i+1) 361 | if mac: 362 | return mac 363 | 364 | def _arp_getnode(): 365 | """Get the hardware address on Unix by running arp.""" 366 | import os, socket 367 | try: 368 | ip_addr = socket.gethostbyname(socket.gethostname()) 369 | except OSError: 370 | return None 371 | 372 | # Try getting the MAC addr from arp based on our IP address (Solaris). 373 | return _find_mac('arp', '-an', [os.fsencode(ip_addr)], lambda i: -1) 374 | 375 | def _lanscan_getnode(): 376 | """Get the hardware address on Unix by running lanscan.""" 377 | # This might work on HP-UX. 378 | return _find_mac('lanscan', '-ai', [b'lan0'], lambda i: 0) 379 | 380 | def _netstat_getnode(): 381 | """Get the hardware address on Unix by running netstat.""" 382 | # This might work on AIX, Tru64 UNIX and presumably on IRIX. 383 | try: 384 | proc = _popen('netstat', '-ia') 385 | if not proc: 386 | return 387 | with proc: 388 | words = proc.stdout.readline().rstrip().split() 389 | try: 390 | i = words.index(b'Address') 391 | except ValueError: 392 | return 393 | for line in proc.stdout: 394 | try: 395 | words = line.rstrip().split() 396 | word = words[i] 397 | if len(word) == 17 and word.count(b':') == 5: 398 | mac = int(word.replace(b':', b''), 16) 399 | if mac: 400 | return mac 401 | except (ValueError, IndexError): 402 | pass 403 | except OSError: 404 | pass 405 | 406 | def _ipconfig_getnode(): 407 | """Get the hardware address on Windows by running ipconfig.exe.""" 408 | import os, re 409 | dirs = ['', r'c:\windows\system32', r'c:\winnt\system32'] 410 | try: 411 | import ctypes 412 | buffer = ctypes.create_string_buffer(300) 413 | ctypes.windll.kernel32.GetSystemDirectoryA(buffer, 300) 414 | dirs.insert(0, buffer.value.decode('mbcs')) 415 | except: 416 | pass 417 | for dir in dirs: 418 | try: 419 | pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') 420 | except OSError: 421 | continue 422 | with pipe: 423 | for line in pipe: 424 | value = line.split(':')[-1].strip().lower() 425 | if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): 426 | return int(value.replace('-', ''), 16) 427 | 428 | def _netbios_getnode(): 429 | """Get the hardware address on Windows using NetBIOS calls. 430 | See http://support.microsoft.com/kb/118623 for details.""" 431 | import win32wnet, netbios 432 | ncb = netbios.NCB() 433 | ncb.Command = netbios.NCBENUM 434 | ncb.Buffer = adapters = netbios.LANA_ENUM() 435 | adapters._pack() 436 | if win32wnet.Netbios(ncb) != 0: 437 | return 438 | adapters._unpack() 439 | for i in range(adapters.length): 440 | ncb.Reset() 441 | ncb.Command = netbios.NCBRESET 442 | ncb.Lana_num = ord(adapters.lana[i]) 443 | if win32wnet.Netbios(ncb) != 0: 444 | continue 445 | ncb.Reset() 446 | ncb.Command = netbios.NCBASTAT 447 | ncb.Lana_num = ord(adapters.lana[i]) 448 | ncb.Callname = '*'.ljust(16) 449 | ncb.Buffer = status = netbios.ADAPTER_STATUS() 450 | if win32wnet.Netbios(ncb) != 0: 451 | continue 452 | status._unpack() 453 | bytes = status.adapter_address[:6] 454 | if len(bytes) != 6: 455 | continue 456 | return int.from_bytes(bytes, 'big') 457 | 458 | # Thanks to Thomas Heller for ctypes and for his help with its use here. 459 | 460 | # If ctypes is available, use it to find system routines for UUID generation. 461 | # XXX This makes the module non-thread-safe! 462 | _uuid_generate_time = _UuidCreate = None 463 | try: 464 | import ctypes, ctypes.util 465 | import sys 466 | 467 | # The uuid_generate_* routines are provided by libuuid on at least 468 | # Linux and FreeBSD, and provided by libc on Mac OS X. 469 | _libnames = ['uuid'] 470 | if not sys.platform.startswith('win'): 471 | _libnames.append('c') 472 | for libname in _libnames: 473 | try: 474 | lib = ctypes.CDLL(ctypes.util.find_library(libname)) 475 | except Exception: 476 | continue 477 | if hasattr(lib, 'uuid_generate_time'): 478 | _uuid_generate_time = lib.uuid_generate_time 479 | break 480 | del _libnames 481 | 482 | # The uuid_generate_* functions are broken on MacOS X 10.5, as noted 483 | # in issue #8621 the function generates the same sequence of values 484 | # in the parent process and all children created using fork (unless 485 | # those children use exec as well). 486 | # 487 | # Assume that the uuid_generate functions are broken from 10.5 onward, 488 | # the test can be adjusted when a later version is fixed. 489 | if sys.platform == 'darwin': 490 | if int(os.uname().release.split('.')[0]) >= 9: 491 | _uuid_generate_time = None 492 | 493 | # On Windows prior to 2000, UuidCreate gives a UUID containing the 494 | # hardware address. On Windows 2000 and later, UuidCreate makes a 495 | # random UUID and UuidCreateSequential gives a UUID containing the 496 | # hardware address. These routines are provided by the RPC runtime. 497 | # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the last 498 | # 6 bytes returned by UuidCreateSequential are fixed, they don't appear 499 | # to bear any relationship to the MAC address of any network device 500 | # on the box. 501 | try: 502 | lib = ctypes.windll.rpcrt4 503 | except: 504 | lib = None 505 | _UuidCreate = getattr(lib, 'UuidCreateSequential', 506 | getattr(lib, 'UuidCreate', None)) 507 | except: 508 | pass 509 | 510 | def _unixdll_getnode(): 511 | """Get the hardware address on Unix using ctypes.""" 512 | _buffer = ctypes.create_string_buffer(16) 513 | _uuid_generate_time(_buffer) 514 | return UUID(bytes=bytes_(_buffer.raw)).node 515 | 516 | def _windll_getnode(): 517 | """Get the hardware address on Windows using ctypes.""" 518 | _buffer = ctypes.create_string_buffer(16) 519 | if _UuidCreate(_buffer) == 0: 520 | return UUID(bytes=bytes_(_buffer.raw)).node 521 | 522 | def _random_getnode(): 523 | """Get a random node ID, with eighth bit set as suggested by RFC 4122.""" 524 | import random 525 | return random.getrandbits(48) | 0x010000000000 526 | 527 | _node = None 528 | 529 | def getnode(): 530 | """Get the hardware address as a 48-bit positive integer. 531 | 532 | The first time this runs, it may launch a separate program, which could 533 | be quite slow. If all attempts to obtain the hardware address fail, we 534 | choose a random 48-bit number with its eighth bit set to 1 as recommended 535 | in RFC 4122. 536 | """ 537 | 538 | global _node 539 | if _node is not None: 540 | return _node 541 | 542 | import sys 543 | if sys.platform == 'win32': 544 | getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] 545 | else: 546 | getters = [_unixdll_getnode, _ifconfig_getnode, _ip_getnode, 547 | _arp_getnode, _lanscan_getnode, _netstat_getnode] 548 | 549 | for getter in getters + [_random_getnode]: 550 | try: 551 | _node = getter() 552 | except: 553 | continue 554 | if _node is not None: 555 | return _node 556 | 557 | _last_timestamp = None 558 | 559 | def uuid1(node=None, clock_seq=None): 560 | """Generate a UUID from a host ID, sequence number, and the current time. 561 | If 'node' is not given, getnode() is used to obtain the hardware 562 | address. If 'clock_seq' is given, it is used as the sequence number; 563 | otherwise a random 14-bit sequence number is chosen.""" 564 | 565 | # When the system provides a version-1 UUID generator, use it (but don't 566 | # use UuidCreate here because its UUIDs don't conform to RFC 4122). 567 | if _uuid_generate_time and node is clock_seq is None: 568 | _buffer = ctypes.create_string_buffer(16) 569 | _uuid_generate_time(_buffer) 570 | return UUID(bytes=bytes_(_buffer.raw)) 571 | 572 | global _last_timestamp 573 | import time 574 | nanoseconds = int(time.time() * 1e9) 575 | # 0x01b21dd213814000 is the number of 100-ns intervals between the 576 | # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. 577 | timestamp = int(nanoseconds/100) + 0x01b21dd213814000 578 | if _last_timestamp is not None and timestamp <= _last_timestamp: 579 | timestamp = _last_timestamp + 1 580 | _last_timestamp = timestamp 581 | if clock_seq is None: 582 | import random 583 | clock_seq = random.getrandbits(14) # instead of stable storage 584 | time_low = timestamp & 0xffffffff 585 | time_mid = (timestamp >> 32) & 0xffff 586 | time_hi_version = (timestamp >> 48) & 0x0fff 587 | clock_seq_low = clock_seq & 0xff 588 | clock_seq_hi_variant = (clock_seq >> 8) & 0x3f 589 | if node is None: 590 | node = getnode() 591 | return UUID(fields=(time_low, time_mid, time_hi_version, 592 | clock_seq_hi_variant, clock_seq_low, node), version=1) 593 | 594 | def uuid3(namespace, name): 595 | """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" 596 | from hashlib import md5 597 | hash = md5(namespace.bytes + bytes(name, "utf-8")).digest() 598 | return UUID(bytes=hash[:16], version=3) 599 | 600 | def uuid4(): 601 | """Generate a random UUID.""" 602 | return UUID(bytes=os.urandom(16), version=4) 603 | 604 | def uuid5(namespace, name): 605 | """Generate a UUID from the SHA-1 hash of a namespace UUID and a name.""" 606 | from hashlib import sha1 607 | hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest() 608 | return UUID(bytes=hash[:16], version=5) 609 | 610 | # The following standard UUIDs are for use with uuid3() or uuid5(). 611 | 612 | NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8') 613 | NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8') 614 | NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8') 615 | NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8') 616 | -------------------------------------------------------------------------------- /tensorflow_cpp/ann_model_loader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ann_model_loader.h" 5 | //#include 6 | 7 | using namespace tensorflow; 8 | 9 | namespace tf_model { 10 | 11 | /** 12 | * ANNFeatureAdapter Implementation 13 | * */ 14 | ANNFeatureAdapter::ANNFeatureAdapter() { 15 | 16 | } 17 | 18 | ANNFeatureAdapter::~ANNFeatureAdapter() { 19 | 20 | } 21 | 22 | /* 23 | * @brief: Feature Adapter: convert 1-D double vector to Tensor, shape [1, ndim] 24 | * @param: std::string tname, tensor name; 25 | * @parma: std::vector>>*, input vector; 26 | * */ 27 | void ANNFeatureAdapter::assign(std::string tname,double data[224][224][3],int width,int height,int deep) { //传入三维度向量 28 | //将三维度向量数据赋值到网络节点上 29 | if (width == 0 || height==0 || deep==0) { 30 | std::cout << "WARNING: Input Vec size is 0 ..." << std::endl; 31 | return; 32 | } 33 | // Create New tensor and set value 34 | Tensor x(tensorflow::DT_FLOAT, tensorflow::TensorShape({1,width, height,deep})); // 创造节点,维度为224,224,3,1,增加一个维度为了适应pb模型 35 | auto x_map = x.tensor(); //创建4个维度空间的节点 36 | 37 | for (int i = 0; i < width; i++) { 38 | for (int ii = 0; ii < height; ii++) { 39 | for (int iii = 0; iii < deep; iii++) { 40 | x_map(0,i,ii,iii) = data[i][ii][iii]; // *(data + height*deep * i + ii * deep + iii); // 这句话有待验证 41 | } 42 | } 43 | } 44 | // Append to input 45 | input.push_back(std::pair(tname, x)); //将网络节点名和数据进行绑定 46 | } 47 | 48 | /** 49 | * ANN Model Loader Implementation 50 | * */ 51 | ANNModelLoader::ANNModelLoader() { 52 | 53 | } 54 | 55 | ANNModelLoader::~ANNModelLoader() { 56 | 57 | } 58 | 59 | /** 60 | * @brief: load the graph and add to Session 61 | * @param: Session* session, add the graph to the session 62 | * @param: model_path absolute path to exported protobuf file *.pb 63 | * */ 64 | 65 | int ANNModelLoader::load(tensorflow::Session* session, const std::string model_path) { 66 | //Read the pb file into the grapgdef member 67 | tensorflow::Status status_load = ReadBinaryProto(Env::Default(), model_path, &graphdef); 68 | if (!status_load.ok()) { 69 | std::cout << "ERROR: Loading model failed..." << model_path << std::endl; 70 | std::cout << status_load.ToString() << "\n"; 71 | return -1; 72 | } 73 | 74 | // Add the graph to the session 75 | tensorflow::Status status_create = session->Create(graphdef); 76 | if (!status_create.ok()) { 77 | std::cout << "ERROR: Creating graph in session failed..." << status_create.ToString() << std::endl; 78 | return -1; 79 | } 80 | return 0; 81 | } 82 | 83 | /** 84 | * @brief: Making new prediction 85 | * @param: Session* session 86 | * @param: FeatureAdapterBase, common interface of input feature 87 | * @param: std::string, output_node, tensorname of output node 88 | * @param: double, prediction values 89 | * */ 90 | 91 | int ANNModelLoader::predict(tensorflow::Session* session, const FeatureAdapterBase& input_feature, 92 | const std::string output_node, double* prediction) { 93 | // The session will initialize the outputs 94 | std::vector outputs; //shape [batch_size] 95 | 96 | // @input: vector >, feed_dict 97 | // @output_node: std::string, name of the output node op, defined in the protobuf file 98 | tensorflow::Status status = session->Run(input_feature.input, {output_node}, {}, &outputs); 99 | if (!status.ok()) { 100 | std::cout << "ERROR: prediction failed..." << status.ToString() << std::endl; 101 | return -1; 102 | } 103 | 104 | 105 | 106 | 107 | 108 | 109 | //获取输出结果 110 | std::cout << "Output tensor size:" << outputs.size() << std::endl; //输出结果的维度 111 | for (std::size_t i = 0; i < outputs.size(); i++) { 112 | std::cout << outputs[i].DebugString(); //输出结果每个分量 113 | } 114 | std::cout << std::endl; 115 | 116 | Tensor t = outputs[0]; // Fetch the first tensor 117 | int ndim = t.shape().dims(); // Get the dimension of the tensor 118 | auto tmap = t.tensor(); // Tensor Shape: [样本个数, 分类个数] 119 | int output_dim = t.shape().dim_size(1); // Get the target_class_num from 1st dimension 120 | std::vector tout; 121 | 122 | // 取输出概率最大的一个分量作为最终分类,计算类标号和概率 123 | int output_class_id = -1; 124 | double output_prob = 0.0; 125 | for (int j = 0; j < output_dim; j++) { 126 | std::cout << "Class " << j << " prob:" << tmap(0, j) << "," << std::endl; 127 | if (tmap(0, j) >= output_prob) { 128 | output_class_id = j; 129 | output_prob = tmap(0, j); 130 | } 131 | } 132 | 133 | // 打印日志 134 | std::cout << "Final class id: " << output_class_id << std::endl; 135 | std::cout << "Final value is: " << output_prob << std::endl; 136 | 137 | (*prediction) = output_prob; // 返回预测所属分类的概率 138 | return 0; 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /tensorflow_cpp/ann_model_loader.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTENSORFLOW_ANN_MODEL_LOADER_H 2 | #define CPPTENSORFLOW_ANN_MODEL_LOADER_H 3 | 4 | #include "model_loader_base.h" 5 | #include "tensorflow/core/public/session.h" 6 | #include "tensorflow/core/platform/env.h" 7 | 8 | using namespace tensorflow; 9 | 10 | namespace tf_model { 11 | 12 | /** 13 | * @brief: Model Loader for Feed Forward Neural Network 14 | * */ 15 | class ANNFeatureAdapter: public FeatureAdapterBase { 16 | public: 17 | 18 | ANNFeatureAdapter(); 19 | 20 | ~ANNFeatureAdapter(); 21 | 22 | void assign(std::string tname, double data[224][224][3],int width,int height,int deep) override; // (tensor_name, tensor) 23 | 24 | }; 25 | 26 | class ANNModelLoader: public ModelLoaderBase { 27 | public: 28 | ANNModelLoader(); 29 | 30 | ~ANNModelLoader(); 31 | 32 | int load(tensorflow::Session*, const std::string) override; //Load graph file and new session 33 | 34 | int predict(tensorflow::Session*, const FeatureAdapterBase&, const std::string, double*) override; 35 | 36 | }; 37 | 38 | } 39 | 40 | 41 | #endif //CPPTENSORFLOW_ANN_MODEL_LOADER_H 42 | -------------------------------------------------------------------------------- /tensorflow_cpp/load.py: -------------------------------------------------------------------------------- 1 | 2 | # 只是读取和生成文件,并不能识别网络是否正确 3 | from tensorflow.python.platform import gfile 4 | import tensorflow as tf 5 | model = 'quantized_graph.pb' 6 | model = 'frozen_graph.pb' 7 | graph = tf.get_default_graph() 8 | graph_def = graph.as_graph_def() 9 | graph_def.ParseFromString(gfile.FastGFile(model, 'rb').read()) 10 | tf.import_graph_def(graph_def, name='graph') 11 | print(graph_def) 12 | 13 | #with tf.gfile.FastGFile('expert-graph.pb', mode='wb') as f: 14 | # f.write(graph_def.SerializeToString()) 15 | 16 | -------------------------------------------------------------------------------- /tensorflow_cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include // 这个放在前面 才能不被后面的错误使用 3 | #include 4 | #include 5 | #include "tensorflow/core/public/session.h" 6 | #include "tensorflow/core/platform/env.h" 7 | #include "ann_model_loader.h" 8 | 9 | using namespace cv; 10 | using namespace tensorflow; 11 | using namespace std; 12 | 13 | int main(int argc, char* argv[]) { 14 | 15 | //python中代码 16 | //pil_image = pil_image.resize(_IMAGE_SIZE,Image.ANTIALIAS) - np.array([123, 117, 104]) # 重置图片大小,才能送入到模型入口.pb模型文件的入口为224,224,3 17 | //pil_image = np.expand_dims(pil_image[:, :, ::-1], axis=0) # 增加一个维度 18 | 19 | 20 | if (argc != 5) { 21 | std::cout << "WARNING: Input Args missing" << std::endl; 22 | return 0; 23 | } 24 | std::string image_path = argv[1]; //图片文件地址 25 | std::string model_path = argv[2]; // pb模型文件地址 26 | std::string input_tensor_name = argv[3]; // 模型中输入节点的名称 //输入节点名称 会去pb模型中匹配,可以先用load.py查看节点信息 27 | std::string output_tensor_name = argv[4]; // 模型中输出节点的名称 //输出节点的名称 会去pb模型中匹配,可以先用load.py查看节点信息 28 | 29 | //vsafety/data:0 输入节点名称 30 | //vsafety/fc2_joint8/fc2_joint8:0 输出节点名称 31 | //safety_ns.pb的模型输入data 输入节点 32 | //safety_ns.pb的模型输出prob 输出节点 33 | //实验模型输入节点名称"input" 34 | //实验模型输出节点名称"MobilenetV1/Predictions/Reshape_1" 35 | 36 | 37 | //读入图像 38 | Mat srcImage=imread(image_path,CV_LOAD_IMAGE_COLOR); //加载图片, 通道数为3 39 | if(srcImage.empty()) 40 | { 41 | printf("can not load image \n"); 42 | return -1; 43 | } 44 | std::cout<<"图片维度:"<(row, col)[0]-123; // 减掉经验值,使得标准化 58 | data[row][col][1]=dstImage.at(row, col)[1]-117; // 减掉经验值,使得标准化 59 | data[row][col][2]=dstImage.at(row, col)[2]-104; // 减掉经验值,使得标准化 60 | // std::cout<<"红:"< 4 | #include 5 | #include "tensorflow/core/public/session.h" 6 | #include "tensorflow/core/platform/env.h" 7 | 8 | using namespace tensorflow; 9 | 10 | namespace tf_model { 11 | 12 | /** 13 | * Base Class for feature adapter, common interface convert input format to tensors 14 | * */ 15 | class FeatureAdapterBase{ 16 | public: 17 | FeatureAdapterBase() {}; 18 | 19 | virtual ~FeatureAdapterBase() {}; 20 | 21 | virtual void assign(std::string, double[224][224][3],int,int,int) = 0; // 节点名称和节点数据向量 22 | 23 | std::vector > input; 24 | 25 | }; 26 | 27 | class ModelLoaderBase { 28 | public: 29 | 30 | ModelLoaderBase() {}; 31 | 32 | virtual ~ModelLoaderBase() {}; 33 | 34 | virtual int load(tensorflow::Session*, const std::string) = 0; //pure virutal function load method 35 | 36 | virtual int predict(tensorflow::Session*, const FeatureAdapterBase&, const std::string, double*) = 0; 37 | 38 | tensorflow::GraphDef graphdef; //Graph Definition for current model 39 | 40 | }; 41 | 42 | } 43 | 44 | #endif //CPPTENSORFLOW_MODEL_LOADER_BASE_H 45 | -------------------------------------------------------------------------------- /tensorflow_cpp/readme: -------------------------------------------------------------------------------- 1 | tensorflow c++接口,python训练模型,c++调用 2 | 3 | 教程可参考:https://blog.csdn.net/luanpeng825485697/article/details/81152615 4 | -------------------------------------------------------------------------------- /ttypes.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | 7 | from thrift.Thrift import * 8 | 9 | from thrift.transport import TTransport 10 | from thrift.protocol import TBinaryProtocol 11 | try: 12 | from thrift.protocol import fastbinary 13 | except: 14 | fastbinary = None 15 | 16 | 17 | class TCell(object): 18 | """ 19 | TCell - Used to transport a cell value (byte[]) and the timestamp it was 20 | stored with together as a result for get and getRow methods. This promotes 21 | the timestamp of a cell to a first-class value, making it easy to take 22 | note of temporal data. Cell is used all the way from HStore up to HTable. 23 | 24 | Attributes: 25 | - value 26 | - timestamp 27 | """ 28 | 29 | thrift_spec = ( 30 | None, # 0 31 | (1, TType.STRING, 'value', None, None, ), # 1 32 | (2, TType.I64, 'timestamp', None, None, ), # 2 33 | ) 34 | 35 | def __init__(self, value=None, timestamp=None,): 36 | self.value = value 37 | self.timestamp = timestamp 38 | 39 | def read(self, iprot): 40 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 41 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 42 | return 43 | iprot.readStructBegin() 44 | while True: 45 | (fname, ftype, fid) = iprot.readFieldBegin() 46 | if ftype == TType.STOP: 47 | break 48 | if fid == 1: 49 | if ftype == TType.STRING: 50 | self.value = iprot.readString(); 51 | else: 52 | iprot.skip(ftype) 53 | elif fid == 2: 54 | if ftype == TType.I64: 55 | self.timestamp = iprot.readI64(); 56 | else: 57 | iprot.skip(ftype) 58 | else: 59 | iprot.skip(ftype) 60 | iprot.readFieldEnd() 61 | iprot.readStructEnd() 62 | 63 | def write(self, oprot): 64 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 65 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 66 | return 67 | oprot.writeStructBegin('TCell') 68 | if self.value != None: 69 | oprot.writeFieldBegin('value', TType.STRING, 1) 70 | oprot.writeString(self.value) 71 | oprot.writeFieldEnd() 72 | if self.timestamp != None: 73 | oprot.writeFieldBegin('timestamp', TType.I64, 2) 74 | oprot.writeI64(self.timestamp) 75 | oprot.writeFieldEnd() 76 | oprot.writeFieldStop() 77 | oprot.writeStructEnd() 78 | 79 | def __repr__(self): 80 | L = ['%s=%r' % (key, value) 81 | for key, value in self.__dict__.items()] 82 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 83 | 84 | def __eq__(self, other): 85 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 86 | 87 | def __ne__(self, other): 88 | return not (self == other) 89 | 90 | class ColumnDescriptor(object): 91 | """ 92 | An HColumnDescriptor contains information about a column family 93 | such as the number of versions, compression settings, etc. It is 94 | used as input when creating a table or adding a column. 95 | 96 | Attributes: 97 | - name 98 | - maxVersions 99 | - compression 100 | - inMemory 101 | - bloomFilterType 102 | - bloomFilterVectorSize 103 | - bloomFilterNbHashes 104 | - blockCacheEnabled 105 | - timeToLive 106 | """ 107 | 108 | thrift_spec = ( 109 | None, # 0 110 | (1, TType.STRING, 'name', None, None, ), # 1 111 | (2, TType.I32, 'maxVersions', None, 3, ), # 2 112 | (3, TType.STRING, 'compression', None, "NONE", ), # 3 113 | (4, TType.BOOL, 'inMemory', None, False, ), # 4 114 | (5, TType.STRING, 'bloomFilterType', None, "NONE", ), # 5 115 | (6, TType.I32, 'bloomFilterVectorSize', None, 0, ), # 6 116 | (7, TType.I32, 'bloomFilterNbHashes', None, 0, ), # 7 117 | (8, TType.BOOL, 'blockCacheEnabled', None, False, ), # 8 118 | (9, TType.I32, 'timeToLive', None, -1, ), # 9 119 | ) 120 | 121 | def __init__(self, name=None, maxVersions=thrift_spec[2][4], compression=thrift_spec[3][4], inMemory=thrift_spec[4][4], bloomFilterType=thrift_spec[5][4], bloomFilterVectorSize=thrift_spec[6][4], bloomFilterNbHashes=thrift_spec[7][4], blockCacheEnabled=thrift_spec[8][4], timeToLive=thrift_spec[9][4],): 122 | self.name = name 123 | self.maxVersions = maxVersions 124 | self.compression = compression 125 | self.inMemory = inMemory 126 | self.bloomFilterType = bloomFilterType 127 | self.bloomFilterVectorSize = bloomFilterVectorSize 128 | self.bloomFilterNbHashes = bloomFilterNbHashes 129 | self.blockCacheEnabled = blockCacheEnabled 130 | self.timeToLive = timeToLive 131 | 132 | def read(self, iprot): 133 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 134 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 135 | return 136 | iprot.readStructBegin() 137 | while True: 138 | (fname, ftype, fid) = iprot.readFieldBegin() 139 | if ftype == TType.STOP: 140 | break 141 | if fid == 1: 142 | if ftype == TType.STRING: 143 | self.name = iprot.readString(); 144 | else: 145 | iprot.skip(ftype) 146 | elif fid == 2: 147 | if ftype == TType.I32: 148 | self.maxVersions = iprot.readI32(); 149 | else: 150 | iprot.skip(ftype) 151 | elif fid == 3: 152 | if ftype == TType.STRING: 153 | self.compression = iprot.readString(); 154 | else: 155 | iprot.skip(ftype) 156 | elif fid == 4: 157 | if ftype == TType.BOOL: 158 | self.inMemory = iprot.readBool(); 159 | else: 160 | iprot.skip(ftype) 161 | elif fid == 5: 162 | if ftype == TType.STRING: 163 | self.bloomFilterType = iprot.readString(); 164 | else: 165 | iprot.skip(ftype) 166 | elif fid == 6: 167 | if ftype == TType.I32: 168 | self.bloomFilterVectorSize = iprot.readI32(); 169 | else: 170 | iprot.skip(ftype) 171 | elif fid == 7: 172 | if ftype == TType.I32: 173 | self.bloomFilterNbHashes = iprot.readI32(); 174 | else: 175 | iprot.skip(ftype) 176 | elif fid == 8: 177 | if ftype == TType.BOOL: 178 | self.blockCacheEnabled = iprot.readBool(); 179 | else: 180 | iprot.skip(ftype) 181 | elif fid == 9: 182 | if ftype == TType.I32: 183 | self.timeToLive = iprot.readI32(); 184 | else: 185 | iprot.skip(ftype) 186 | else: 187 | iprot.skip(ftype) 188 | iprot.readFieldEnd() 189 | iprot.readStructEnd() 190 | 191 | def write(self, oprot): 192 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 193 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 194 | return 195 | oprot.writeStructBegin('ColumnDescriptor') 196 | if self.name != None: 197 | oprot.writeFieldBegin('name', TType.STRING, 1) 198 | oprot.writeString(self.name) 199 | oprot.writeFieldEnd() 200 | if self.maxVersions != None: 201 | oprot.writeFieldBegin('maxVersions', TType.I32, 2) 202 | oprot.writeI32(self.maxVersions) 203 | oprot.writeFieldEnd() 204 | if self.compression != None: 205 | oprot.writeFieldBegin('compression', TType.STRING, 3) 206 | oprot.writeString(self.compression) 207 | oprot.writeFieldEnd() 208 | if self.inMemory != None: 209 | oprot.writeFieldBegin('inMemory', TType.BOOL, 4) 210 | oprot.writeBool(self.inMemory) 211 | oprot.writeFieldEnd() 212 | if self.bloomFilterType != None: 213 | oprot.writeFieldBegin('bloomFilterType', TType.STRING, 5) 214 | oprot.writeString(self.bloomFilterType) 215 | oprot.writeFieldEnd() 216 | if self.bloomFilterVectorSize != None: 217 | oprot.writeFieldBegin('bloomFilterVectorSize', TType.I32, 6) 218 | oprot.writeI32(self.bloomFilterVectorSize) 219 | oprot.writeFieldEnd() 220 | if self.bloomFilterNbHashes != None: 221 | oprot.writeFieldBegin('bloomFilterNbHashes', TType.I32, 7) 222 | oprot.writeI32(self.bloomFilterNbHashes) 223 | oprot.writeFieldEnd() 224 | if self.blockCacheEnabled != None: 225 | oprot.writeFieldBegin('blockCacheEnabled', TType.BOOL, 8) 226 | oprot.writeBool(self.blockCacheEnabled) 227 | oprot.writeFieldEnd() 228 | if self.timeToLive != None: 229 | oprot.writeFieldBegin('timeToLive', TType.I32, 9) 230 | oprot.writeI32(self.timeToLive) 231 | oprot.writeFieldEnd() 232 | oprot.writeFieldStop() 233 | oprot.writeStructEnd() 234 | 235 | def __repr__(self): 236 | L = ['%s=%r' % (key, value) 237 | for key, value in self.__dict__.items()] 238 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 239 | 240 | def __eq__(self, other): 241 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 242 | 243 | def __ne__(self, other): 244 | return not (self == other) 245 | 246 | class TRegionInfo(object): 247 | """ 248 | A TRegionInfo contains information about an HTable region. 249 | 250 | Attributes: 251 | - startKey 252 | - endKey 253 | - id 254 | - name 255 | - version 256 | """ 257 | 258 | thrift_spec = ( 259 | None, # 0 260 | (1, TType.STRING, 'startKey', None, None, ), # 1 261 | (2, TType.STRING, 'endKey', None, None, ), # 2 262 | (3, TType.I64, 'id', None, None, ), # 3 263 | (4, TType.STRING, 'name', None, None, ), # 4 264 | (5, TType.BYTE, 'version', None, None, ), # 5 265 | ) 266 | 267 | def __init__(self, startKey=None, endKey=None, id=None, name=None, version=None,): 268 | self.startKey = startKey 269 | self.endKey = endKey 270 | self.id = id 271 | self.name = name 272 | self.version = version 273 | 274 | def read(self, iprot): 275 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 276 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 277 | return 278 | iprot.readStructBegin() 279 | while True: 280 | (fname, ftype, fid) = iprot.readFieldBegin() 281 | if ftype == TType.STOP: 282 | break 283 | if fid == 1: 284 | if ftype == TType.STRING: 285 | self.startKey = iprot.readString(); 286 | else: 287 | iprot.skip(ftype) 288 | elif fid == 2: 289 | if ftype == TType.STRING: 290 | self.endKey = iprot.readString(); 291 | else: 292 | iprot.skip(ftype) 293 | elif fid == 3: 294 | if ftype == TType.I64: 295 | self.id = iprot.readI64(); 296 | else: 297 | iprot.skip(ftype) 298 | elif fid == 4: 299 | if ftype == TType.STRING: 300 | self.name = iprot.readString(); 301 | else: 302 | iprot.skip(ftype) 303 | elif fid == 5: 304 | if ftype == TType.BYTE: 305 | self.version = iprot.readByte(); 306 | else: 307 | iprot.skip(ftype) 308 | else: 309 | iprot.skip(ftype) 310 | iprot.readFieldEnd() 311 | iprot.readStructEnd() 312 | 313 | def write(self, oprot): 314 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 315 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 316 | return 317 | oprot.writeStructBegin('TRegionInfo') 318 | if self.startKey != None: 319 | oprot.writeFieldBegin('startKey', TType.STRING, 1) 320 | oprot.writeString(self.startKey) 321 | oprot.writeFieldEnd() 322 | if self.endKey != None: 323 | oprot.writeFieldBegin('endKey', TType.STRING, 2) 324 | oprot.writeString(self.endKey) 325 | oprot.writeFieldEnd() 326 | if self.id != None: 327 | oprot.writeFieldBegin('id', TType.I64, 3) 328 | oprot.writeI64(self.id) 329 | oprot.writeFieldEnd() 330 | if self.name != None: 331 | oprot.writeFieldBegin('name', TType.STRING, 4) 332 | oprot.writeString(self.name) 333 | oprot.writeFieldEnd() 334 | if self.version != None: 335 | oprot.writeFieldBegin('version', TType.BYTE, 5) 336 | oprot.writeByte(self.version) 337 | oprot.writeFieldEnd() 338 | oprot.writeFieldStop() 339 | oprot.writeStructEnd() 340 | 341 | def __repr__(self): 342 | L = ['%s=%r' % (key, value) 343 | for key, value in self.__dict__.items()] 344 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 345 | 346 | def __eq__(self, other): 347 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 348 | 349 | def __ne__(self, other): 350 | return not (self == other) 351 | 352 | class Mutation(object): 353 | """ 354 | A Mutation object is used to either update or delete a column-value. 355 | 356 | Attributes: 357 | - isDelete 358 | - column 359 | - value 360 | """ 361 | 362 | thrift_spec = ( 363 | None, # 0 364 | (1, TType.BOOL, 'isDelete', None, False, ), # 1 365 | (2, TType.STRING, 'column', None, None, ), # 2 366 | (3, TType.STRING, 'value', None, None, ), # 3 367 | ) 368 | 369 | def __init__(self, isDelete=thrift_spec[1][4], column=None, value=None,): 370 | self.isDelete = isDelete 371 | self.column = column 372 | self.value = value 373 | 374 | def read(self, iprot): 375 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 376 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 377 | return 378 | iprot.readStructBegin() 379 | while True: 380 | (fname, ftype, fid) = iprot.readFieldBegin() 381 | if ftype == TType.STOP: 382 | break 383 | if fid == 1: 384 | if ftype == TType.BOOL: 385 | self.isDelete = iprot.readBool(); 386 | else: 387 | iprot.skip(ftype) 388 | elif fid == 2: 389 | if ftype == TType.STRING: 390 | self.column = iprot.readString(); 391 | else: 392 | iprot.skip(ftype) 393 | elif fid == 3: 394 | if ftype == TType.STRING: 395 | self.value = iprot.readString(); 396 | else: 397 | iprot.skip(ftype) 398 | else: 399 | iprot.skip(ftype) 400 | iprot.readFieldEnd() 401 | iprot.readStructEnd() 402 | 403 | def write(self, oprot): 404 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 405 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 406 | return 407 | oprot.writeStructBegin('Mutation') 408 | if self.isDelete != None: 409 | oprot.writeFieldBegin('isDelete', TType.BOOL, 1) 410 | oprot.writeBool(self.isDelete) 411 | oprot.writeFieldEnd() 412 | if self.column != None: 413 | oprot.writeFieldBegin('column', TType.STRING, 2) 414 | oprot.writeString(self.column) 415 | oprot.writeFieldEnd() 416 | if self.value != None: 417 | oprot.writeFieldBegin('value', TType.STRING, 3) 418 | oprot.writeString(self.value) 419 | oprot.writeFieldEnd() 420 | oprot.writeFieldStop() 421 | oprot.writeStructEnd() 422 | 423 | def __repr__(self): 424 | L = ['%s=%r' % (key, value) 425 | for key, value in self.__dict__.items()] 426 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 427 | 428 | def __eq__(self, other): 429 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 430 | 431 | def __ne__(self, other): 432 | return not (self == other) 433 | 434 | class BatchMutation(object): 435 | """ 436 | A BatchMutation object is used to apply a number of Mutations to a single row. 437 | 438 | Attributes: 439 | - row 440 | - mutations 441 | """ 442 | 443 | thrift_spec = ( 444 | None, # 0 445 | (1, TType.STRING, 'row', None, None, ), # 1 446 | (2, TType.LIST, 'mutations', (TType.STRUCT,(Mutation, Mutation.thrift_spec)), None, ), # 2 447 | ) 448 | 449 | def __init__(self, row=None, mutations=None,): 450 | self.row = row 451 | self.mutations = mutations 452 | 453 | def read(self, iprot): 454 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 455 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 456 | return 457 | iprot.readStructBegin() 458 | while True: 459 | (fname, ftype, fid) = iprot.readFieldBegin() 460 | if ftype == TType.STOP: 461 | break 462 | if fid == 1: 463 | if ftype == TType.STRING: 464 | self.row = iprot.readString(); 465 | else: 466 | iprot.skip(ftype) 467 | elif fid == 2: 468 | if ftype == TType.LIST: 469 | self.mutations = [] 470 | (_etype3, _size0) = iprot.readListBegin() 471 | for _i4 in range(_size0): 472 | _elem5 = Mutation() 473 | _elem5.read(iprot) 474 | self.mutations.append(_elem5) 475 | iprot.readListEnd() 476 | else: 477 | iprot.skip(ftype) 478 | else: 479 | iprot.skip(ftype) 480 | iprot.readFieldEnd() 481 | iprot.readStructEnd() 482 | 483 | def write(self, oprot): 484 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 485 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 486 | return 487 | oprot.writeStructBegin('BatchMutation') 488 | if self.row != None: 489 | oprot.writeFieldBegin('row', TType.STRING, 1) 490 | oprot.writeString(self.row) 491 | oprot.writeFieldEnd() 492 | if self.mutations != None: 493 | oprot.writeFieldBegin('mutations', TType.LIST, 2) 494 | oprot.writeListBegin(TType.STRUCT, len(self.mutations)) 495 | for iter6 in self.mutations: 496 | iter6.write(oprot) 497 | oprot.writeListEnd() 498 | oprot.writeFieldEnd() 499 | oprot.writeFieldStop() 500 | oprot.writeStructEnd() 501 | 502 | def __repr__(self): 503 | L = ['%s=%r' % (key, value) 504 | for key, value in self.__dict__.items()] 505 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 506 | 507 | def __eq__(self, other): 508 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 509 | 510 | def __ne__(self, other): 511 | return not (self == other) 512 | 513 | class TRowResult(object): 514 | """ 515 | Holds row name and then a map of columns to cells. 516 | 517 | Attributes: 518 | - row 519 | - columns 520 | """ 521 | 522 | thrift_spec = ( 523 | None, # 0 524 | (1, TType.STRING, 'row', None, None, ), # 1 525 | (2, TType.MAP, 'columns', (TType.STRING,None,TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 2 526 | ) 527 | 528 | def __init__(self, row=None, columns=None,): 529 | self.row = row 530 | self.columns = columns 531 | 532 | def read(self, iprot): 533 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 534 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 535 | return 536 | iprot.readStructBegin() 537 | while True: 538 | (fname, ftype, fid) = iprot.readFieldBegin() 539 | if ftype == TType.STOP: 540 | break 541 | if fid == 1: 542 | if ftype == TType.STRING: 543 | self.row = iprot.readString(); 544 | else: 545 | iprot.skip(ftype) 546 | elif fid == 2: 547 | if ftype == TType.MAP: 548 | self.columns = {} 549 | (_ktype8, _vtype9, _size7 ) = iprot.readMapBegin() 550 | for _i11 in range(_size7): 551 | _key12 = iprot.readString(); 552 | _val13 = TCell() 553 | _val13.read(iprot) 554 | self.columns[_key12] = _val13 555 | iprot.readMapEnd() 556 | else: 557 | iprot.skip(ftype) 558 | else: 559 | iprot.skip(ftype) 560 | iprot.readFieldEnd() 561 | iprot.readStructEnd() 562 | 563 | def write(self, oprot): 564 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 565 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 566 | return 567 | oprot.writeStructBegin('TRowResult') 568 | if self.row != None: 569 | oprot.writeFieldBegin('row', TType.STRING, 1) 570 | oprot.writeString(self.row) 571 | oprot.writeFieldEnd() 572 | if self.columns != None: 573 | oprot.writeFieldBegin('columns', TType.MAP, 2) 574 | oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.columns)) 575 | for kiter14,viter15 in self.columns.items(): 576 | oprot.writeString(kiter14) 577 | viter15.write(oprot) 578 | oprot.writeMapEnd() 579 | oprot.writeFieldEnd() 580 | oprot.writeFieldStop() 581 | oprot.writeStructEnd() 582 | 583 | def __repr__(self): 584 | L = ['%s=%r' % (key, value) 585 | for key, value in self.__dict__.items()] 586 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 587 | 588 | def __eq__(self, other): 589 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 590 | 591 | def __ne__(self, other): 592 | return not (self == other) 593 | 594 | class IOError(Exception): 595 | """ 596 | An IOError exception signals that an error occurred communicating 597 | to the Hbase master or an Hbase region server. Also used to return 598 | more general Hbase error conditions. 599 | 600 | Attributes: 601 | - message 602 | """ 603 | 604 | thrift_spec = ( 605 | None, # 0 606 | (1, TType.STRING, 'message', None, None, ), # 1 607 | ) 608 | 609 | def __init__(self, message=None,): 610 | self.message = message 611 | 612 | def read(self, iprot): 613 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 614 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 615 | return 616 | iprot.readStructBegin() 617 | while True: 618 | (fname, ftype, fid) = iprot.readFieldBegin() 619 | if ftype == TType.STOP: 620 | break 621 | if fid == 1: 622 | if ftype == TType.STRING: 623 | self.message = iprot.readString(); 624 | else: 625 | iprot.skip(ftype) 626 | else: 627 | iprot.skip(ftype) 628 | iprot.readFieldEnd() 629 | iprot.readStructEnd() 630 | 631 | def write(self, oprot): 632 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 633 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 634 | return 635 | oprot.writeStructBegin('IOError') 636 | if self.message != None: 637 | oprot.writeFieldBegin('message', TType.STRING, 1) 638 | oprot.writeString(self.message) 639 | oprot.writeFieldEnd() 640 | oprot.writeFieldStop() 641 | oprot.writeStructEnd() 642 | 643 | def __str__(self): 644 | return repr(self) 645 | 646 | def __repr__(self): 647 | L = ['%s=%r' % (key, value) 648 | for key, value in self.__dict__.items()] 649 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 650 | 651 | def __eq__(self, other): 652 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 653 | 654 | def __ne__(self, other): 655 | return not (self == other) 656 | 657 | class IllegalArgument(Exception): 658 | """ 659 | An IllegalArgument exception indicates an illegal or invalid 660 | argument was passed into a procedure. 661 | 662 | Attributes: 663 | - message 664 | """ 665 | 666 | thrift_spec = ( 667 | None, # 0 668 | (1, TType.STRING, 'message', None, None, ), # 1 669 | ) 670 | 671 | def __init__(self, message=None,): 672 | self.message = message 673 | 674 | def read(self, iprot): 675 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 676 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 677 | return 678 | iprot.readStructBegin() 679 | while True: 680 | (fname, ftype, fid) = iprot.readFieldBegin() 681 | if ftype == TType.STOP: 682 | break 683 | if fid == 1: 684 | if ftype == TType.STRING: 685 | self.message = iprot.readString(); 686 | else: 687 | iprot.skip(ftype) 688 | else: 689 | iprot.skip(ftype) 690 | iprot.readFieldEnd() 691 | iprot.readStructEnd() 692 | 693 | def write(self, oprot): 694 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 695 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 696 | return 697 | oprot.writeStructBegin('IllegalArgument') 698 | if self.message != None: 699 | oprot.writeFieldBegin('message', TType.STRING, 1) 700 | oprot.writeString(self.message) 701 | oprot.writeFieldEnd() 702 | oprot.writeFieldStop() 703 | oprot.writeStructEnd() 704 | 705 | def __str__(self): 706 | return repr(self) 707 | 708 | def __repr__(self): 709 | L = ['%s=%r' % (key, value) 710 | for key, value in self.__dict__.items()] 711 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 712 | 713 | def __eq__(self, other): 714 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 715 | 716 | def __ne__(self, other): 717 | return not (self == other) 718 | 719 | class AlreadyExists(Exception): 720 | """ 721 | An AlreadyExists exceptions signals that a table with the specified 722 | name already exists 723 | 724 | Attributes: 725 | - message 726 | """ 727 | 728 | thrift_spec = ( 729 | None, # 0 730 | (1, TType.STRING, 'message', None, None, ), # 1 731 | ) 732 | 733 | def __init__(self, message=None,): 734 | self.message = message 735 | 736 | def read(self, iprot): 737 | if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: 738 | fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) 739 | return 740 | iprot.readStructBegin() 741 | while True: 742 | (fname, ftype, fid) = iprot.readFieldBegin() 743 | if ftype == TType.STOP: 744 | break 745 | if fid == 1: 746 | if ftype == TType.STRING: 747 | self.message = iprot.readString(); 748 | else: 749 | iprot.skip(ftype) 750 | else: 751 | iprot.skip(ftype) 752 | iprot.readFieldEnd() 753 | iprot.readStructEnd() 754 | 755 | def write(self, oprot): 756 | if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: 757 | oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) 758 | return 759 | oprot.writeStructBegin('AlreadyExists') 760 | if self.message != None: 761 | oprot.writeFieldBegin('message', TType.STRING, 1) 762 | oprot.writeString(self.message) 763 | oprot.writeFieldEnd() 764 | oprot.writeFieldStop() 765 | oprot.writeStructEnd() 766 | 767 | def __str__(self): 768 | return repr(self) 769 | 770 | def __repr__(self): 771 | L = ['%s=%r' % (key, value) 772 | for key, value in self.__dict__.items()] 773 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 774 | 775 | def __eq__(self, other): 776 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 777 | 778 | def __ne__(self, other): 779 | return not (self == other) 780 | 781 | --------------------------------------------------------------------------------