diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7e259a324e..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "configman"] - path = configman - url = git://github.com/mozilla/configman.git -[submodule "SocorroSearchService"] - path = SocorroSearchService - url = git://github.com/mozilla/SocorroSearchService.git diff --git a/Makefile b/Makefile index ff132d680d..89cb22bedf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX=/data/socorro ABS_PREFIX = $(shell readlink -f $(PREFIX)) VIRTUALENV=$(CURDIR)/socorro-virtualenv -PYTHONPATH = ".:thirdparty" +PYTHONPATH = "." NOSE = $(VIRTUALENV)/bin/nosetests socorro -s --with-xunit SETUPDB = $(VIRTUALENV)/bin/python ./socorro/external/postgresql/setupdb_app.py COVEROPTS = --with-coverage --cover-package=socorro @@ -9,7 +9,7 @@ COVERAGE = $(VIRTUALENV)/bin/coverage PYLINT = $(VIRTUALENV)/bin/pylint CITEXT="/usr/share/postgresql/9.0/contrib/citext.sql" -.PHONY: all test phpunit install reinstall install-socorro install-web virtualenv coverage lint clean minidump_stackwalk java_analysis +.PHONY: all test phpunit install reinstall install-socorro install-web virtualenv coverage lint clean minidump_stackwalk java_analysis thirdparty all: test @@ -25,10 +25,14 @@ test: setup-test phpunit phpunit: phpunit webapp-php/tests/ -install: java_analysis reinstall +thirdparty: + # install production dependencies + $(VIRTUALENV)/bin/pip install --use-mirrors --download-cache=pip-cache/ --ignore-installed --install-option="--prefix=`pwd`/thirdparty" --install-option="--install-lib=`pwd`/thirdparty" -r requirements/prod.txt -# this a dev-only option, `java_analysis` needs to be run at least once in the checkout (or after `make clean`) -reinstall: install-socorro install-web install-submodules virtualenv +install: java_analysis thirdparty reinstall + +# this a dev-only option, `make install` needs to be run at least once in the checkout (or after `make clean`) +reinstall: install-socorro install-web # record current git revision in install dir git rev-parse HEAD > $(PREFIX)/revision.txt REV=`cat $(PREFIX)/revision.txt` && sed -ibak "s/CURRENT_SOCORRO_REVISION/$$REV/" $(PREFIX)/htdocs/application/config/revision.php @@ -38,9 +42,9 @@ install-socorro: # create base directories mkdir -p $(PREFIX)/htdocs mkdir -p $(PREFIX)/application + # copy to install directory rsync -a thirdparty $(PREFIX) - rsync -a socorro-virtualenv/lib/python2.6/site-packages/ $(PREFIX)/thirdparty/ - rsync -a socorro $(PREFIX)/application + rsync -a socorro $(PREFIX)/application rsync -a scripts $(PREFIX)/application rsync -a tools $(PREFIX)/application rsync -a sql $(PREFIX)/application @@ -48,6 +52,7 @@ install-socorro: rsync -a scripts/stackwalk.sh $(PREFIX)/stackwalk/bin/ rsync -a analysis/build/lib/socorro-analysis-job.jar $(PREFIX)/analysis/ rsync -a analysis/bin/modulelist.sh $(PREFIX)/analysis/ + # copy default config files cd $(PREFIX)/application/scripts/config; for file in *.py.dist; do cp $$file `basename $$file .dist`; done install-web: @@ -57,15 +62,9 @@ install-web: cd $(PREFIX)/htdocs/application/config; for file in *.php-dist; do cp $$file `basename $$file -dist`; done cd $(PREFIX)/htdocs; cp htaccess-dist .htaccess -install-submodules: - # clone submodule dependencies - git submodule update --init --recursive - cd configman; python setup.py install --install-lib=$(ABS_PREFIX)/application - virtualenv: virtualenv $(VIRTUALENV) - $(VIRTUALENV)/bin/pip install -r requirements.txt - cd configman; $(VIRTUALENV)/bin/python setup.py install + $(VIRTUALENV)/bin/pip install --use-mirrors --download-cache=./pip-cache -r requirements/dev.txt coverage: setup-test phpunit rm -f coverage.xml @@ -77,8 +76,8 @@ lint: clean: find ./socorro/ -type f -name "*.pyc" -exec rm {} \; - find ./thirdparty/ -type f -name "*.pyc" -exec rm {} \; - rm -rf ./google-breakpad/ ./builds/ ./breakpad/ ./stackwalk + rm -rf ./thirdparty/* + rm -rf ./google-breakpad/ ./builds/ ./breakpad/ ./stackwalk ./pip-cache rm -rf ./breakpad.tar.gz cd analysis && ant clean diff --git a/configman b/configman deleted file mode 160000 index 3d74ae9084..0000000000 --- a/configman +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3d74ae9084b53f021d723a8becaa119234a804bc diff --git a/puppet/manifests/classes/socorro-base.pp b/puppet/manifests/classes/socorro-base.pp index 33936d7d1e..9071b528ca 100644 --- a/puppet/manifests/classes/socorro-base.pp +++ b/puppet/manifests/classes/socorro-base.pp @@ -89,12 +89,6 @@ ensure => file; } - exec { - '/usr/bin/pip install isodate': - require => Package['python-pip'], - creates => '/usr/local/lib/python2.6/dist-packages/isodate'; - } - exec { '/usr/bin/apt-get update && touch /tmp/apt-get-update': alias => 'apt-get-update', @@ -103,8 +97,8 @@ package { ['rsyslog', 'libcurl4-openssl-dev', 'libxslt1-dev', 'build-essential', - 'supervisor', 'ant', 'python-software-properties', 'python-pip', - 'curl', 'git-core', 'openjdk-6-jdk']: + 'supervisor', 'ant', 'python-software-properties', 'curl', 'git-core', + 'openjdk-6-jdk']: ensure => latest, require => Exec['apt-get-update']; } @@ -168,8 +162,7 @@ # default => "puppet://$server/modules/socorro/prod/etc-logrotated/socorro", # }; package { - ['python-psycopg2', 'python-simplejson', 'subversion', 'libpq-dev', - 'python-virtualenv', 'python-dev']: + ['subversion', 'libpq-dev', 'python-virtualenv', 'python-dev']: ensure => latest, require => Exec['apt-get-update']; } diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ae22a35c86..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -nose -psycopg2 -simplejson -coverage -web.py -pylint -poster -mock -lxml -isodate -configobj -statsd diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000000..ab265c30aa --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,5 @@ +-r prod.txt +coverage==3.5.2b1 +nose==1.1.2 +mock==0.8.0 +poster==0.8.1 diff --git a/requirements/prod.txt b/requirements/prod.txt new file mode 100644 index 0000000000..e155ed4abf --- /dev/null +++ b/requirements/prod.txt @@ -0,0 +1,11 @@ +# configman moves too fast for pypi right now +git+git://github.com/mozilla/configman@3d74ae9#egg=configman +configobj==4.7.2 +hbase-thrift==0.20.4 +isodate==0.4.7 +lxml==2.3.4 +psycopg2==2.0.13 +simplejson==2.5.0 +statsd==0.5.0 +thrift==0.8.0 +web.py==0.36 diff --git a/thirdparty/.gitignore b/thirdparty/.gitignore new file mode 100644 index 0000000000..72e8ffc0db --- /dev/null +++ b/thirdparty/.gitignore @@ -0,0 +1 @@ +* diff --git a/thirdparty/README.txt b/thirdparty/README.txt deleted file mode 100644 index 0ed4548826..0000000000 --- a/thirdparty/README.txt +++ /dev/null @@ -1,10 +0,0 @@ -This thirdparty directory should only be used for libraries which we -cannot deploy and manage automatically. Another valid reason is machine -generated code. - -When a library is not longer released in a craptastic manner, we -should remove it from here and make it a deployment dependency. - -I'm looking at you Apache Incubation Thrift version 0.1 - -*** DO NOT EDIT ANY SOURCE CODE UNDER *** diff --git a/thirdparty/hbase/__init__.py b/thirdparty/hbase/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/thirdparty/hbase/hbase.py b/thirdparty/hbase/hbase.py deleted file mode 100644 index 7ea85afb41..0000000000 --- a/thirdparty/hbase/hbase.py +++ /dev/null @@ -1,7555 +0,0 @@ -# -# Autogenerated by Thrift -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# - -from thrift.Thrift import * -from ttypes import * -from thrift.Thrift import TProcessor -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - - -class Iface: - def enableTable(self, tableName): - """ - Brings a table on-line (enables it) - @param tableName name of the table - - Parameters: - - tableName - """ - pass - - def disableTable(self, tableName): - """ - Disables a table (takes it off-line) If it is being served, the master - will tell the servers to stop serving it. - @param tableName name of the table - - Parameters: - - tableName - """ - pass - - def isTableEnabled(self, tableName): - """ - @param tableName name of table to check - @return true if table is on-line - - Parameters: - - tableName - """ - pass - - def compact(self, tableNameOrRegionName): - """ - Parameters: - - tableNameOrRegionName - """ - pass - - def majorCompact(self, tableNameOrRegionName): - """ - Parameters: - - tableNameOrRegionName - """ - pass - - def getTableNames(self, ): - """ - List all the userspace tables. - @return - returns a list of names - """ - pass - - def getColumnDescriptors(self, tableName): - """ - List all the column families assoicated with a table. - @param tableName table name - @return list of column family descriptors - - Parameters: - - tableName - """ - pass - - def getTableRegions(self, tableName): - """ - List the regions associated with a table. - @param tableName table name - @return list of region descriptors - - Parameters: - - tableName - """ - pass - - def createTable(self, tableName, columnFamilies): - """ - Create a table with the specified column families. The name - field for each ColumnDescriptor must be set and must end in a - colon (:). All other fields are optional and will get default - values if not explicitly specified. - - @param tableName name of table to create - @param columnFamilies list of column family descriptors - - @throws IllegalArgument if an input parameter is invalid - @throws AlreadyExists if the table name already exists - - Parameters: - - tableName - - columnFamilies - """ - pass - - def deleteTable(self, tableName): - """ - Deletes a table - @param tableName name of table to delete - @throws IOError if table doesn't exist on server or there was some other - problem - - Parameters: - - tableName - """ - pass - - def get(self, tableName, row, column): - """ - Get a single TCell for the specified table, row, and column at the - latest timestamp. Returns an empty list if no such value exists. - - @param tableName name of table - @param row row key - @param column column name - @return value for specified row/column - - Parameters: - - tableName - - row - - column - """ - pass - - def getVer(self, tableName, row, column, numVersions): - """ - Get the specified number of versions for the specified table, - row, and column. - - @param tableName name of table - @param row row key - @param column column name - @param numVersions number of versions to retrieve - @return list of cells for specified row/column - - Parameters: - - tableName - - row - - column - - numVersions - """ - pass - - def getVerTs(self, tableName, row, column, timestamp, numVersions): - """ - Get the specified number of versions for the specified table, - row, and column. Only versions less than or equal to the specified - timestamp will be returned. - - @param tableName name of table - @param row row key - @param column column name - @param timestamp timestamp - @param numVersions number of versions to retrieve - @return list of cells for specified row/column - - Parameters: - - tableName - - row - - column - - timestamp - - numVersions - """ - pass - - def getRow(self, tableName, row): - """ - Get all the data for the specified table and row at the latest - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - """ - pass - - def getRowWithColumns(self, tableName, row, columns): - """ - Get the specified columns for the specified table and row at the latest - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @param columns List of columns to return, null for all columns - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - columns - """ - pass - - def getRowTs(self, tableName, row, timestamp): - """ - Get all the data for the specified table and row at the specified - timestamp. Returns an empty list if the row does not exist. - - @param tableName of table - @param row row key - @param timestamp timestamp - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - timestamp - """ - pass - - def getRowWithColumnsTs(self, tableName, row, columns, timestamp): - """ - Get the specified columns for the specified table and row at the specified - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @param columns List of columns to return, null for all columns - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - columns - - timestamp - """ - pass - - def mutateRow(self, tableName, row, mutations): - """ - Apply a series of mutations (updates/deletes) to a row in a - single transaction. If an exception is thrown, then the - transaction is aborted. Default current timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param row row key - @param mutations list of mutation commands - - Parameters: - - tableName - - row - - mutations - """ - pass - - def mutateRowTs(self, tableName, row, mutations, timestamp): - """ - Apply a series of mutations (updates/deletes) to a row in a - single transaction. If an exception is thrown, then the - transaction is aborted. The specified timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param row row key - @param mutations list of mutation commands - @param timestamp timestamp - - Parameters: - - tableName - - row - - mutations - - timestamp - """ - pass - - def mutateRows(self, tableName, rowBatches): - """ - Apply a series of batches (each a series of mutations on a single row) - in a single transaction. If an exception is thrown, then the - transaction is aborted. Default current timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param rowBatches list of row batches - - Parameters: - - tableName - - rowBatches - """ - pass - - def mutateRowsTs(self, tableName, rowBatches, timestamp): - """ - Apply a series of batches (each a series of mutations on a single row) - in a single transaction. If an exception is thrown, then the - transaction is aborted. The specified timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param rowBatches list of row batches - @param timestamp timestamp - - Parameters: - - tableName - - rowBatches - - timestamp - """ - pass - - def atomicIncrement(self, tableName, row, column, value): - """ - Atomically increment the column value specified. Returns the next value post increment. - @param tableName name of table - @param row row to increment - @param column name of column - @param value amount to increment by - - Parameters: - - tableName - - row - - column - - value - """ - pass - - def deleteAll(self, tableName, row, column): - """ - Delete all cells that match the passed row and column. - - @param tableName name of table - @param row Row to update - @param column name of column whose value is to be deleted - - Parameters: - - tableName - - row - - column - """ - pass - - def deleteAllTs(self, tableName, row, column, timestamp): - """ - Delete all cells that match the passed row and column and whose - timestamp is equal-to or older than the passed timestamp. - - @param tableName name of table - @param row Row to update - @param column name of column whose value is to be deleted - @param timestamp timestamp - - Parameters: - - tableName - - row - - column - - timestamp - """ - pass - - def deleteAllRow(self, tableName, row): - """ - Completely delete the row's cells. - - @param tableName name of table - @param row key of the row to be completely deleted. - - Parameters: - - tableName - - row - """ - pass - - def deleteAllRowTs(self, tableName, row, timestamp): - """ - Completely delete the row's cells marked with a timestamp - equal-to or older than the passed timestamp. - - @param tableName name of table - @param row key of the row to be completely deleted. - @param timestamp timestamp - - Parameters: - - tableName - - row - - timestamp - """ - pass - - def scannerOpen(self, tableName, startRow, columns): - """ - Get a scanner on the current table starting at the specified row and - ending at the last row in the table. Return the specified columns. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - columns - """ - pass - - def scannerOpenWithStop(self, tableName, startRow, stopRow, columns): - """ - Get a scanner on the current table starting and stopping at the - specified rows. ending at the last row in the table. Return the - specified columns. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param stopRow row to stop scanning on. This row is *not* included in the - scanner's results - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - stopRow - - columns - """ - pass - - def scannerOpenWithPrefix(self, tableName, startAndPrefix, columns): - """ - Open a scanner for a given prefix. That is all rows will have the specified - prefix. No other rows will be returned. - - @param tableName name of table - @param startAndPrefix the prefix (and thus start row) of the keys you want - @param columns the columns you want returned - @return scanner id to use with other scanner calls - - Parameters: - - tableName - - startAndPrefix - - columns - """ - pass - - def scannerOpenTs(self, tableName, startRow, columns, timestamp): - """ - Get a scanner on the current table starting at the specified row and - ending at the last row in the table. Return the specified columns. - Only values with the specified timestamp are returned. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param timestamp timestamp - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - columns - - timestamp - """ - pass - - def scannerOpenWithStopTs(self, tableName, startRow, stopRow, columns, timestamp): - """ - Get a scanner on the current table starting and stopping at the - specified rows. ending at the last row in the table. Return the - specified columns. Only values with the specified timestamp are - returned. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param stopRow row to stop scanning on. This row is *not* included - in the scanner's results - @param timestamp timestamp - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - stopRow - - columns - - timestamp - """ - pass - - def scannerGet(self, id): - """ - Returns the scanner's current row value and advances to the next - row in the table. When there are no more rows in the table, or a key - greater-than-or-equal-to the scanner's specified stopRow is reached, - an empty list is returned. - - @param id id of a scanner returned by scannerOpen - @return a TRowResult containing the current row and a map of the columns to TCells. - @throws IllegalArgument if ScannerID is invalid - @throws NotFound when the scanner reaches the end - - Parameters: - - id - """ - pass - - def scannerGetList(self, id, nbRows): - """ - Returns, starting at the scanner's current row value nbRows worth of - rows and advances to the next row in the table. When there are no more - rows in the table, or a key greater-than-or-equal-to the scanner's - specified stopRow is reached, an empty list is returned. - - @param id id of a scanner returned by scannerOpen - @param nbRows number of results to regturn - @return a TRowResult containing the current row and a map of the columns to TCells. - @throws IllegalArgument if ScannerID is invalid - @throws NotFound when the scanner reaches the end - - Parameters: - - id - - nbRows - """ - pass - - def scannerClose(self, id): - """ - Closes the server-state associated with an open scanner. - - @param id id of a scanner returned by scannerOpen - @throws IllegalArgument if ScannerID is invalid - - Parameters: - - id - """ - pass - - -class Client(Iface): - def __init__(self, iprot, oprot=None): - self._iprot = self._oprot = iprot - if oprot != None: - self._oprot = oprot - self._seqid = 0 - - def enableTable(self, tableName): - """ - Brings a table on-line (enables it) - @param tableName name of the table - - Parameters: - - tableName - """ - self.send_enableTable(tableName) - self.recv_enableTable() - - def send_enableTable(self, tableName): - self._oprot.writeMessageBegin('enableTable', TMessageType.CALL, self._seqid) - args = enableTable_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_enableTable(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = enableTable_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def disableTable(self, tableName): - """ - Disables a table (takes it off-line) If it is being served, the master - will tell the servers to stop serving it. - @param tableName name of the table - - Parameters: - - tableName - """ - self.send_disableTable(tableName) - self.recv_disableTable() - - def send_disableTable(self, tableName): - self._oprot.writeMessageBegin('disableTable', TMessageType.CALL, self._seqid) - args = disableTable_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_disableTable(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = disableTable_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def isTableEnabled(self, tableName): - """ - @param tableName name of table to check - @return true if table is on-line - - Parameters: - - tableName - """ - self.send_isTableEnabled(tableName) - return self.recv_isTableEnabled() - - def send_isTableEnabled(self, tableName): - self._oprot.writeMessageBegin('isTableEnabled', TMessageType.CALL, self._seqid) - args = isTableEnabled_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_isTableEnabled(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = isTableEnabled_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "isTableEnabled failed: unknown result"); - - def compact(self, tableNameOrRegionName): - """ - Parameters: - - tableNameOrRegionName - """ - self.send_compact(tableNameOrRegionName) - self.recv_compact() - - def send_compact(self, tableNameOrRegionName): - self._oprot.writeMessageBegin('compact', TMessageType.CALL, self._seqid) - args = compact_args() - args.tableNameOrRegionName = tableNameOrRegionName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_compact(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = compact_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def majorCompact(self, tableNameOrRegionName): - """ - Parameters: - - tableNameOrRegionName - """ - self.send_majorCompact(tableNameOrRegionName) - self.recv_majorCompact() - - def send_majorCompact(self, tableNameOrRegionName): - self._oprot.writeMessageBegin('majorCompact', TMessageType.CALL, self._seqid) - args = majorCompact_args() - args.tableNameOrRegionName = tableNameOrRegionName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_majorCompact(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = majorCompact_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def getTableNames(self, ): - """ - List all the userspace tables. - @return - returns a list of names - """ - self.send_getTableNames() - return self.recv_getTableNames() - - def send_getTableNames(self, ): - self._oprot.writeMessageBegin('getTableNames', TMessageType.CALL, self._seqid) - args = getTableNames_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getTableNames(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getTableNames_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableNames failed: unknown result"); - - def getColumnDescriptors(self, tableName): - """ - List all the column families assoicated with a table. - @param tableName table name - @return list of column family descriptors - - Parameters: - - tableName - """ - self.send_getColumnDescriptors(tableName) - return self.recv_getColumnDescriptors() - - def send_getColumnDescriptors(self, tableName): - self._oprot.writeMessageBegin('getColumnDescriptors', TMessageType.CALL, self._seqid) - args = getColumnDescriptors_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getColumnDescriptors(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getColumnDescriptors_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getColumnDescriptors failed: unknown result"); - - def getTableRegions(self, tableName): - """ - List the regions associated with a table. - @param tableName table name - @return list of region descriptors - - Parameters: - - tableName - """ - self.send_getTableRegions(tableName) - return self.recv_getTableRegions() - - def send_getTableRegions(self, tableName): - self._oprot.writeMessageBegin('getTableRegions', TMessageType.CALL, self._seqid) - args = getTableRegions_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getTableRegions(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getTableRegions_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableRegions failed: unknown result"); - - def createTable(self, tableName, columnFamilies): - """ - Create a table with the specified column families. The name - field for each ColumnDescriptor must be set and must end in a - colon (:). All other fields are optional and will get default - values if not explicitly specified. - - @param tableName name of table to create - @param columnFamilies list of column family descriptors - - @throws IllegalArgument if an input parameter is invalid - @throws AlreadyExists if the table name already exists - - Parameters: - - tableName - - columnFamilies - """ - self.send_createTable(tableName, columnFamilies) - self.recv_createTable() - - def send_createTable(self, tableName, columnFamilies): - self._oprot.writeMessageBegin('createTable', TMessageType.CALL, self._seqid) - args = createTable_args() - args.tableName = tableName - args.columnFamilies = columnFamilies - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_createTable(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = createTable_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - if result.exist != None: - raise result.exist - return - - def deleteTable(self, tableName): - """ - Deletes a table - @param tableName name of table to delete - @throws IOError if table doesn't exist on server or there was some other - problem - - Parameters: - - tableName - """ - self.send_deleteTable(tableName) - self.recv_deleteTable() - - def send_deleteTable(self, tableName): - self._oprot.writeMessageBegin('deleteTable', TMessageType.CALL, self._seqid) - args = deleteTable_args() - args.tableName = tableName - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteTable(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteTable_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def get(self, tableName, row, column): - """ - Get a single TCell for the specified table, row, and column at the - latest timestamp. Returns an empty list if no such value exists. - - @param tableName name of table - @param row row key - @param column column name - @return value for specified row/column - - Parameters: - - tableName - - row - - column - """ - self.send_get(tableName, row, column) - return self.recv_get() - - def send_get(self, tableName, row, column): - self._oprot.writeMessageBegin('get', TMessageType.CALL, self._seqid) - args = get_args() - args.tableName = tableName - args.row = row - args.column = column - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_get(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = get_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "get failed: unknown result"); - - def getVer(self, tableName, row, column, numVersions): - """ - Get the specified number of versions for the specified table, - row, and column. - - @param tableName name of table - @param row row key - @param column column name - @param numVersions number of versions to retrieve - @return list of cells for specified row/column - - Parameters: - - tableName - - row - - column - - numVersions - """ - self.send_getVer(tableName, row, column, numVersions) - return self.recv_getVer() - - def send_getVer(self, tableName, row, column, numVersions): - self._oprot.writeMessageBegin('getVer', TMessageType.CALL, self._seqid) - args = getVer_args() - args.tableName = tableName - args.row = row - args.column = column - args.numVersions = numVersions - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getVer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getVer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getVer failed: unknown result"); - - def getVerTs(self, tableName, row, column, timestamp, numVersions): - """ - Get the specified number of versions for the specified table, - row, and column. Only versions less than or equal to the specified - timestamp will be returned. - - @param tableName name of table - @param row row key - @param column column name - @param timestamp timestamp - @param numVersions number of versions to retrieve - @return list of cells for specified row/column - - Parameters: - - tableName - - row - - column - - timestamp - - numVersions - """ - self.send_getVerTs(tableName, row, column, timestamp, numVersions) - return self.recv_getVerTs() - - def send_getVerTs(self, tableName, row, column, timestamp, numVersions): - self._oprot.writeMessageBegin('getVerTs', TMessageType.CALL, self._seqid) - args = getVerTs_args() - args.tableName = tableName - args.row = row - args.column = column - args.timestamp = timestamp - args.numVersions = numVersions - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getVerTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getVerTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getVerTs failed: unknown result"); - - def getRow(self, tableName, row): - """ - Get all the data for the specified table and row at the latest - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - """ - self.send_getRow(tableName, row) - return self.recv_getRow() - - def send_getRow(self, tableName, row): - self._oprot.writeMessageBegin('getRow', TMessageType.CALL, self._seqid) - args = getRow_args() - args.tableName = tableName - args.row = row - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getRow(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getRow_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getRow failed: unknown result"); - - def getRowWithColumns(self, tableName, row, columns): - """ - Get the specified columns for the specified table and row at the latest - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @param columns List of columns to return, null for all columns - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - columns - """ - self.send_getRowWithColumns(tableName, row, columns) - return self.recv_getRowWithColumns() - - def send_getRowWithColumns(self, tableName, row, columns): - self._oprot.writeMessageBegin('getRowWithColumns', TMessageType.CALL, self._seqid) - args = getRowWithColumns_args() - args.tableName = tableName - args.row = row - args.columns = columns - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getRowWithColumns(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getRowWithColumns_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumns failed: unknown result"); - - def getRowTs(self, tableName, row, timestamp): - """ - Get all the data for the specified table and row at the specified - timestamp. Returns an empty list if the row does not exist. - - @param tableName of table - @param row row key - @param timestamp timestamp - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - timestamp - """ - self.send_getRowTs(tableName, row, timestamp) - return self.recv_getRowTs() - - def send_getRowTs(self, tableName, row, timestamp): - self._oprot.writeMessageBegin('getRowTs', TMessageType.CALL, self._seqid) - args = getRowTs_args() - args.tableName = tableName - args.row = row - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getRowTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getRowTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowTs failed: unknown result"); - - def getRowWithColumnsTs(self, tableName, row, columns, timestamp): - """ - Get the specified columns for the specified table and row at the specified - timestamp. Returns an empty list if the row does not exist. - - @param tableName name of table - @param row row key - @param columns List of columns to return, null for all columns - @return TRowResult containing the row and map of columns to TCells - - Parameters: - - tableName - - row - - columns - - timestamp - """ - self.send_getRowWithColumnsTs(tableName, row, columns, timestamp) - return self.recv_getRowWithColumnsTs() - - def send_getRowWithColumnsTs(self, tableName, row, columns, timestamp): - self._oprot.writeMessageBegin('getRowWithColumnsTs', TMessageType.CALL, self._seqid) - args = getRowWithColumnsTs_args() - args.tableName = tableName - args.row = row - args.columns = columns - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getRowWithColumnsTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getRowWithColumnsTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumnsTs failed: unknown result"); - - def mutateRow(self, tableName, row, mutations): - """ - Apply a series of mutations (updates/deletes) to a row in a - single transaction. If an exception is thrown, then the - transaction is aborted. Default current timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param row row key - @param mutations list of mutation commands - - Parameters: - - tableName - - row - - mutations - """ - self.send_mutateRow(tableName, row, mutations) - self.recv_mutateRow() - - def send_mutateRow(self, tableName, row, mutations): - self._oprot.writeMessageBegin('mutateRow', TMessageType.CALL, self._seqid) - args = mutateRow_args() - args.tableName = tableName - args.row = row - args.mutations = mutations - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_mutateRow(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = mutateRow_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - return - - def mutateRowTs(self, tableName, row, mutations, timestamp): - """ - Apply a series of mutations (updates/deletes) to a row in a - single transaction. If an exception is thrown, then the - transaction is aborted. The specified timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param row row key - @param mutations list of mutation commands - @param timestamp timestamp - - Parameters: - - tableName - - row - - mutations - - timestamp - """ - self.send_mutateRowTs(tableName, row, mutations, timestamp) - self.recv_mutateRowTs() - - def send_mutateRowTs(self, tableName, row, mutations, timestamp): - self._oprot.writeMessageBegin('mutateRowTs', TMessageType.CALL, self._seqid) - args = mutateRowTs_args() - args.tableName = tableName - args.row = row - args.mutations = mutations - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_mutateRowTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = mutateRowTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - return - - def mutateRows(self, tableName, rowBatches): - """ - Apply a series of batches (each a series of mutations on a single row) - in a single transaction. If an exception is thrown, then the - transaction is aborted. Default current timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param rowBatches list of row batches - - Parameters: - - tableName - - rowBatches - """ - self.send_mutateRows(tableName, rowBatches) - self.recv_mutateRows() - - def send_mutateRows(self, tableName, rowBatches): - self._oprot.writeMessageBegin('mutateRows', TMessageType.CALL, self._seqid) - args = mutateRows_args() - args.tableName = tableName - args.rowBatches = rowBatches - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_mutateRows(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = mutateRows_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - return - - def mutateRowsTs(self, tableName, rowBatches, timestamp): - """ - Apply a series of batches (each a series of mutations on a single row) - in a single transaction. If an exception is thrown, then the - transaction is aborted. The specified timestamp is used, and - all entries will have an identical timestamp. - - @param tableName name of table - @param rowBatches list of row batches - @param timestamp timestamp - - Parameters: - - tableName - - rowBatches - - timestamp - """ - self.send_mutateRowsTs(tableName, rowBatches, timestamp) - self.recv_mutateRowsTs() - - def send_mutateRowsTs(self, tableName, rowBatches, timestamp): - self._oprot.writeMessageBegin('mutateRowsTs', TMessageType.CALL, self._seqid) - args = mutateRowsTs_args() - args.tableName = tableName - args.rowBatches = rowBatches - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_mutateRowsTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = mutateRowsTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - return - - def atomicIncrement(self, tableName, row, column, value): - """ - Atomically increment the column value specified. Returns the next value post increment. - @param tableName name of table - @param row row to increment - @param column name of column - @param value amount to increment by - - Parameters: - - tableName - - row - - column - - value - """ - self.send_atomicIncrement(tableName, row, column, value) - return self.recv_atomicIncrement() - - def send_atomicIncrement(self, tableName, row, column, value): - self._oprot.writeMessageBegin('atomicIncrement', TMessageType.CALL, self._seqid) - args = atomicIncrement_args() - args.tableName = tableName - args.row = row - args.column = column - args.value = value - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_atomicIncrement(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = atomicIncrement_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - raise TApplicationException(TApplicationException.MISSING_RESULT, "atomicIncrement failed: unknown result"); - - def deleteAll(self, tableName, row, column): - """ - Delete all cells that match the passed row and column. - - @param tableName name of table - @param row Row to update - @param column name of column whose value is to be deleted - - Parameters: - - tableName - - row - - column - """ - self.send_deleteAll(tableName, row, column) - self.recv_deleteAll() - - def send_deleteAll(self, tableName, row, column): - self._oprot.writeMessageBegin('deleteAll', TMessageType.CALL, self._seqid) - args = deleteAll_args() - args.tableName = tableName - args.row = row - args.column = column - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteAll(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteAll_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def deleteAllTs(self, tableName, row, column, timestamp): - """ - Delete all cells that match the passed row and column and whose - timestamp is equal-to or older than the passed timestamp. - - @param tableName name of table - @param row Row to update - @param column name of column whose value is to be deleted - @param timestamp timestamp - - Parameters: - - tableName - - row - - column - - timestamp - """ - self.send_deleteAllTs(tableName, row, column, timestamp) - self.recv_deleteAllTs() - - def send_deleteAllTs(self, tableName, row, column, timestamp): - self._oprot.writeMessageBegin('deleteAllTs', TMessageType.CALL, self._seqid) - args = deleteAllTs_args() - args.tableName = tableName - args.row = row - args.column = column - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteAllTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteAllTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def deleteAllRow(self, tableName, row): - """ - Completely delete the row's cells. - - @param tableName name of table - @param row key of the row to be completely deleted. - - Parameters: - - tableName - - row - """ - self.send_deleteAllRow(tableName, row) - self.recv_deleteAllRow() - - def send_deleteAllRow(self, tableName, row): - self._oprot.writeMessageBegin('deleteAllRow', TMessageType.CALL, self._seqid) - args = deleteAllRow_args() - args.tableName = tableName - args.row = row - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteAllRow(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteAllRow_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def deleteAllRowTs(self, tableName, row, timestamp): - """ - Completely delete the row's cells marked with a timestamp - equal-to or older than the passed timestamp. - - @param tableName name of table - @param row key of the row to be completely deleted. - @param timestamp timestamp - - Parameters: - - tableName - - row - - timestamp - """ - self.send_deleteAllRowTs(tableName, row, timestamp) - self.recv_deleteAllRowTs() - - def send_deleteAllRowTs(self, tableName, row, timestamp): - self._oprot.writeMessageBegin('deleteAllRowTs', TMessageType.CALL, self._seqid) - args = deleteAllRowTs_args() - args.tableName = tableName - args.row = row - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteAllRowTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteAllRowTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - return - - def scannerOpen(self, tableName, startRow, columns): - """ - Get a scanner on the current table starting at the specified row and - ending at the last row in the table. Return the specified columns. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - columns - """ - self.send_scannerOpen(tableName, startRow, columns) - return self.recv_scannerOpen() - - def send_scannerOpen(self, tableName, startRow, columns): - self._oprot.writeMessageBegin('scannerOpen', TMessageType.CALL, self._seqid) - args = scannerOpen_args() - args.tableName = tableName - args.startRow = startRow - args.columns = columns - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerOpen(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerOpen_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpen failed: unknown result"); - - def scannerOpenWithStop(self, tableName, startRow, stopRow, columns): - """ - Get a scanner on the current table starting and stopping at the - specified rows. ending at the last row in the table. Return the - specified columns. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param stopRow row to stop scanning on. This row is *not* included in the - scanner's results - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - stopRow - - columns - """ - self.send_scannerOpenWithStop(tableName, startRow, stopRow, columns) - return self.recv_scannerOpenWithStop() - - def send_scannerOpenWithStop(self, tableName, startRow, stopRow, columns): - self._oprot.writeMessageBegin('scannerOpenWithStop', TMessageType.CALL, self._seqid) - args = scannerOpenWithStop_args() - args.tableName = tableName - args.startRow = startRow - args.stopRow = stopRow - args.columns = columns - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerOpenWithStop(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerOpenWithStop_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithStop failed: unknown result"); - - def scannerOpenWithPrefix(self, tableName, startAndPrefix, columns): - """ - Open a scanner for a given prefix. That is all rows will have the specified - prefix. No other rows will be returned. - - @param tableName name of table - @param startAndPrefix the prefix (and thus start row) of the keys you want - @param columns the columns you want returned - @return scanner id to use with other scanner calls - - Parameters: - - tableName - - startAndPrefix - - columns - """ - self.send_scannerOpenWithPrefix(tableName, startAndPrefix, columns) - return self.recv_scannerOpenWithPrefix() - - def send_scannerOpenWithPrefix(self, tableName, startAndPrefix, columns): - self._oprot.writeMessageBegin('scannerOpenWithPrefix', TMessageType.CALL, self._seqid) - args = scannerOpenWithPrefix_args() - args.tableName = tableName - args.startAndPrefix = startAndPrefix - args.columns = columns - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerOpenWithPrefix(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerOpenWithPrefix_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithPrefix failed: unknown result"); - - def scannerOpenTs(self, tableName, startRow, columns, timestamp): - """ - Get a scanner on the current table starting at the specified row and - ending at the last row in the table. Return the specified columns. - Only values with the specified timestamp are returned. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param timestamp timestamp - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - columns - - timestamp - """ - self.send_scannerOpenTs(tableName, startRow, columns, timestamp) - return self.recv_scannerOpenTs() - - def send_scannerOpenTs(self, tableName, startRow, columns, timestamp): - self._oprot.writeMessageBegin('scannerOpenTs', TMessageType.CALL, self._seqid) - args = scannerOpenTs_args() - args.tableName = tableName - args.startRow = startRow - args.columns = columns - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerOpenTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerOpenTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenTs failed: unknown result"); - - def scannerOpenWithStopTs(self, tableName, startRow, stopRow, columns, timestamp): - """ - Get a scanner on the current table starting and stopping at the - specified rows. ending at the last row in the table. Return the - specified columns. Only values with the specified timestamp are - returned. - - @param columns columns to scan. If column name is a column family, all - columns of the specified column family are returned. Its also possible - to pass a regex in the column qualifier. - @param tableName name of table - @param startRow starting row in table to scan. send "" (empty string) to - start at the first row. - @param stopRow row to stop scanning on. This row is *not* included - in the scanner's results - @param timestamp timestamp - - @return scanner id to be used with other scanner procedures - - Parameters: - - tableName - - startRow - - stopRow - - columns - - timestamp - """ - self.send_scannerOpenWithStopTs(tableName, startRow, stopRow, columns, timestamp) - return self.recv_scannerOpenWithStopTs() - - def send_scannerOpenWithStopTs(self, tableName, startRow, stopRow, columns, timestamp): - self._oprot.writeMessageBegin('scannerOpenWithStopTs', TMessageType.CALL, self._seqid) - args = scannerOpenWithStopTs_args() - args.tableName = tableName - args.startRow = startRow - args.stopRow = stopRow - args.columns = columns - args.timestamp = timestamp - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerOpenWithStopTs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerOpenWithStopTs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithStopTs failed: unknown result"); - - def scannerGet(self, id): - """ - Returns the scanner's current row value and advances to the next - row in the table. When there are no more rows in the table, or a key - greater-than-or-equal-to the scanner's specified stopRow is reached, - an empty list is returned. - - @param id id of a scanner returned by scannerOpen - @return a TRowResult containing the current row and a map of the columns to TCells. - @throws IllegalArgument if ScannerID is invalid - @throws NotFound when the scanner reaches the end - - Parameters: - - id - """ - self.send_scannerGet(id) - return self.recv_scannerGet() - - def send_scannerGet(self, id): - self._oprot.writeMessageBegin('scannerGet', TMessageType.CALL, self._seqid) - args = scannerGet_args() - args.id = id - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerGet(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerGet_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerGet failed: unknown result"); - - def scannerGetList(self, id, nbRows): - """ - Returns, starting at the scanner's current row value nbRows worth of - rows and advances to the next row in the table. When there are no more - rows in the table, or a key greater-than-or-equal-to the scanner's - specified stopRow is reached, an empty list is returned. - - @param id id of a scanner returned by scannerOpen - @param nbRows number of results to regturn - @return a TRowResult containing the current row and a map of the columns to TCells. - @throws IllegalArgument if ScannerID is invalid - @throws NotFound when the scanner reaches the end - - Parameters: - - id - - nbRows - """ - self.send_scannerGetList(id, nbRows) - return self.recv_scannerGetList() - - def send_scannerGetList(self, id, nbRows): - self._oprot.writeMessageBegin('scannerGetList', TMessageType.CALL, self._seqid) - args = scannerGetList_args() - args.id = id - args.nbRows = nbRows - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerGetList(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerGetList_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerGetList failed: unknown result"); - - def scannerClose(self, id): - """ - Closes the server-state associated with an open scanner. - - @param id id of a scanner returned by scannerOpen - @throws IllegalArgument if ScannerID is invalid - - Parameters: - - id - """ - self.send_scannerClose(id) - self.recv_scannerClose() - - def send_scannerClose(self, id): - self._oprot.writeMessageBegin('scannerClose', TMessageType.CALL, self._seqid) - args = scannerClose_args() - args.id = id - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_scannerClose(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = scannerClose_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.io != None: - raise result.io - if result.ia != None: - raise result.ia - return - - -class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["enableTable"] = Processor.process_enableTable - self._processMap["disableTable"] = Processor.process_disableTable - self._processMap["isTableEnabled"] = Processor.process_isTableEnabled - self._processMap["compact"] = Processor.process_compact - self._processMap["majorCompact"] = Processor.process_majorCompact - self._processMap["getTableNames"] = Processor.process_getTableNames - self._processMap["getColumnDescriptors"] = Processor.process_getColumnDescriptors - self._processMap["getTableRegions"] = Processor.process_getTableRegions - self._processMap["createTable"] = Processor.process_createTable - self._processMap["deleteTable"] = Processor.process_deleteTable - self._processMap["get"] = Processor.process_get - self._processMap["getVer"] = Processor.process_getVer - self._processMap["getVerTs"] = Processor.process_getVerTs - self._processMap["getRow"] = Processor.process_getRow - self._processMap["getRowWithColumns"] = Processor.process_getRowWithColumns - self._processMap["getRowTs"] = Processor.process_getRowTs - self._processMap["getRowWithColumnsTs"] = Processor.process_getRowWithColumnsTs - self._processMap["mutateRow"] = Processor.process_mutateRow - self._processMap["mutateRowTs"] = Processor.process_mutateRowTs - self._processMap["mutateRows"] = Processor.process_mutateRows - self._processMap["mutateRowsTs"] = Processor.process_mutateRowsTs - self._processMap["atomicIncrement"] = Processor.process_atomicIncrement - self._processMap["deleteAll"] = Processor.process_deleteAll - self._processMap["deleteAllTs"] = Processor.process_deleteAllTs - self._processMap["deleteAllRow"] = Processor.process_deleteAllRow - self._processMap["deleteAllRowTs"] = Processor.process_deleteAllRowTs - self._processMap["scannerOpen"] = Processor.process_scannerOpen - self._processMap["scannerOpenWithStop"] = Processor.process_scannerOpenWithStop - self._processMap["scannerOpenWithPrefix"] = Processor.process_scannerOpenWithPrefix - self._processMap["scannerOpenTs"] = Processor.process_scannerOpenTs - self._processMap["scannerOpenWithStopTs"] = Processor.process_scannerOpenWithStopTs - self._processMap["scannerGet"] = Processor.process_scannerGet - self._processMap["scannerGetList"] = Processor.process_scannerGetList - self._processMap["scannerClose"] = Processor.process_scannerClose - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - self._processMap[name](self, seqid, iprot, oprot) - return True - - def process_enableTable(self, seqid, iprot, oprot): - args = enableTable_args() - args.read(iprot) - iprot.readMessageEnd() - result = enableTable_result() - try: - self._handler.enableTable(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("enableTable", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_disableTable(self, seqid, iprot, oprot): - args = disableTable_args() - args.read(iprot) - iprot.readMessageEnd() - result = disableTable_result() - try: - self._handler.disableTable(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("disableTable", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_isTableEnabled(self, seqid, iprot, oprot): - args = isTableEnabled_args() - args.read(iprot) - iprot.readMessageEnd() - result = isTableEnabled_result() - try: - result.success = self._handler.isTableEnabled(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("isTableEnabled", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_compact(self, seqid, iprot, oprot): - args = compact_args() - args.read(iprot) - iprot.readMessageEnd() - result = compact_result() - try: - self._handler.compact(args.tableNameOrRegionName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("compact", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_majorCompact(self, seqid, iprot, oprot): - args = majorCompact_args() - args.read(iprot) - iprot.readMessageEnd() - result = majorCompact_result() - try: - self._handler.majorCompact(args.tableNameOrRegionName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("majorCompact", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getTableNames(self, seqid, iprot, oprot): - args = getTableNames_args() - args.read(iprot) - iprot.readMessageEnd() - result = getTableNames_result() - try: - result.success = self._handler.getTableNames() - except IOError, io: - result.io = io - oprot.writeMessageBegin("getTableNames", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getColumnDescriptors(self, seqid, iprot, oprot): - args = getColumnDescriptors_args() - args.read(iprot) - iprot.readMessageEnd() - result = getColumnDescriptors_result() - try: - result.success = self._handler.getColumnDescriptors(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getColumnDescriptors", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getTableRegions(self, seqid, iprot, oprot): - args = getTableRegions_args() - args.read(iprot) - iprot.readMessageEnd() - result = getTableRegions_result() - try: - result.success = self._handler.getTableRegions(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getTableRegions", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_createTable(self, seqid, iprot, oprot): - args = createTable_args() - args.read(iprot) - iprot.readMessageEnd() - result = createTable_result() - try: - self._handler.createTable(args.tableName, args.columnFamilies) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - except AlreadyExists, exist: - result.exist = exist - oprot.writeMessageBegin("createTable", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deleteTable(self, seqid, iprot, oprot): - args = deleteTable_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteTable_result() - try: - self._handler.deleteTable(args.tableName) - except IOError, io: - result.io = io - oprot.writeMessageBegin("deleteTable", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_get(self, seqid, iprot, oprot): - args = get_args() - args.read(iprot) - iprot.readMessageEnd() - result = get_result() - try: - result.success = self._handler.get(args.tableName, args.row, args.column) - except IOError, io: - result.io = io - oprot.writeMessageBegin("get", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getVer(self, seqid, iprot, oprot): - args = getVer_args() - args.read(iprot) - iprot.readMessageEnd() - result = getVer_result() - try: - result.success = self._handler.getVer(args.tableName, args.row, args.column, args.numVersions) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getVer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getVerTs(self, seqid, iprot, oprot): - args = getVerTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = getVerTs_result() - try: - result.success = self._handler.getVerTs(args.tableName, args.row, args.column, args.timestamp, args.numVersions) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getVerTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getRow(self, seqid, iprot, oprot): - args = getRow_args() - args.read(iprot) - iprot.readMessageEnd() - result = getRow_result() - try: - result.success = self._handler.getRow(args.tableName, args.row) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getRow", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getRowWithColumns(self, seqid, iprot, oprot): - args = getRowWithColumns_args() - args.read(iprot) - iprot.readMessageEnd() - result = getRowWithColumns_result() - try: - result.success = self._handler.getRowWithColumns(args.tableName, args.row, args.columns) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getRowWithColumns", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getRowTs(self, seqid, iprot, oprot): - args = getRowTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = getRowTs_result() - try: - result.success = self._handler.getRowTs(args.tableName, args.row, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getRowTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getRowWithColumnsTs(self, seqid, iprot, oprot): - args = getRowWithColumnsTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = getRowWithColumnsTs_result() - try: - result.success = self._handler.getRowWithColumnsTs(args.tableName, args.row, args.columns, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("getRowWithColumnsTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_mutateRow(self, seqid, iprot, oprot): - args = mutateRow_args() - args.read(iprot) - iprot.readMessageEnd() - result = mutateRow_result() - try: - self._handler.mutateRow(args.tableName, args.row, args.mutations) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("mutateRow", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_mutateRowTs(self, seqid, iprot, oprot): - args = mutateRowTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = mutateRowTs_result() - try: - self._handler.mutateRowTs(args.tableName, args.row, args.mutations, args.timestamp) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("mutateRowTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_mutateRows(self, seqid, iprot, oprot): - args = mutateRows_args() - args.read(iprot) - iprot.readMessageEnd() - result = mutateRows_result() - try: - self._handler.mutateRows(args.tableName, args.rowBatches) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("mutateRows", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_mutateRowsTs(self, seqid, iprot, oprot): - args = mutateRowsTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = mutateRowsTs_result() - try: - self._handler.mutateRowsTs(args.tableName, args.rowBatches, args.timestamp) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("mutateRowsTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_atomicIncrement(self, seqid, iprot, oprot): - args = atomicIncrement_args() - args.read(iprot) - iprot.readMessageEnd() - result = atomicIncrement_result() - try: - result.success = self._handler.atomicIncrement(args.tableName, args.row, args.column, args.value) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("atomicIncrement", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deleteAll(self, seqid, iprot, oprot): - args = deleteAll_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteAll_result() - try: - self._handler.deleteAll(args.tableName, args.row, args.column) - except IOError, io: - result.io = io - oprot.writeMessageBegin("deleteAll", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deleteAllTs(self, seqid, iprot, oprot): - args = deleteAllTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteAllTs_result() - try: - self._handler.deleteAllTs(args.tableName, args.row, args.column, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("deleteAllTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deleteAllRow(self, seqid, iprot, oprot): - args = deleteAllRow_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteAllRow_result() - try: - self._handler.deleteAllRow(args.tableName, args.row) - except IOError, io: - result.io = io - oprot.writeMessageBegin("deleteAllRow", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deleteAllRowTs(self, seqid, iprot, oprot): - args = deleteAllRowTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteAllRowTs_result() - try: - self._handler.deleteAllRowTs(args.tableName, args.row, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("deleteAllRowTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerOpen(self, seqid, iprot, oprot): - args = scannerOpen_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerOpen_result() - try: - result.success = self._handler.scannerOpen(args.tableName, args.startRow, args.columns) - except IOError, io: - result.io = io - oprot.writeMessageBegin("scannerOpen", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerOpenWithStop(self, seqid, iprot, oprot): - args = scannerOpenWithStop_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerOpenWithStop_result() - try: - result.success = self._handler.scannerOpenWithStop(args.tableName, args.startRow, args.stopRow, args.columns) - except IOError, io: - result.io = io - oprot.writeMessageBegin("scannerOpenWithStop", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerOpenWithPrefix(self, seqid, iprot, oprot): - args = scannerOpenWithPrefix_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerOpenWithPrefix_result() - try: - result.success = self._handler.scannerOpenWithPrefix(args.tableName, args.startAndPrefix, args.columns) - except IOError, io: - result.io = io - oprot.writeMessageBegin("scannerOpenWithPrefix", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerOpenTs(self, seqid, iprot, oprot): - args = scannerOpenTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerOpenTs_result() - try: - result.success = self._handler.scannerOpenTs(args.tableName, args.startRow, args.columns, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("scannerOpenTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerOpenWithStopTs(self, seqid, iprot, oprot): - args = scannerOpenWithStopTs_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerOpenWithStopTs_result() - try: - result.success = self._handler.scannerOpenWithStopTs(args.tableName, args.startRow, args.stopRow, args.columns, args.timestamp) - except IOError, io: - result.io = io - oprot.writeMessageBegin("scannerOpenWithStopTs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerGet(self, seqid, iprot, oprot): - args = scannerGet_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerGet_result() - try: - result.success = self._handler.scannerGet(args.id) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("scannerGet", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerGetList(self, seqid, iprot, oprot): - args = scannerGetList_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerGetList_result() - try: - result.success = self._handler.scannerGetList(args.id, args.nbRows) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("scannerGetList", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_scannerClose(self, seqid, iprot, oprot): - args = scannerClose_args() - args.read(iprot) - iprot.readMessageEnd() - result = scannerClose_result() - try: - self._handler.scannerClose(args.id) - except IOError, io: - result.io = io - except IllegalArgument, ia: - result.ia = ia - oprot.writeMessageBegin("scannerClose", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - -# HELPER FUNCTIONS AND STRUCTURES - -class enableTable_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('enableTable_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class enableTable_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('enableTable_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class disableTable_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('disableTable_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class disableTable_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('disableTable_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class isTableEnabled_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('isTableEnabled_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class isTableEnabled_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.BOOL: - self.success = iprot.readBool(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('isTableEnabled_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.BOOL, 0) - oprot.writeBool(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class compact_args: - """ - Attributes: - - tableNameOrRegionName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableNameOrRegionName', None, None, ), # 1 - ) - - def __init__(self, tableNameOrRegionName=None,): - self.tableNameOrRegionName = tableNameOrRegionName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableNameOrRegionName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('compact_args') - if self.tableNameOrRegionName != None: - oprot.writeFieldBegin('tableNameOrRegionName', TType.STRING, 1) - oprot.writeString(self.tableNameOrRegionName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class compact_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('compact_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class majorCompact_args: - """ - Attributes: - - tableNameOrRegionName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableNameOrRegionName', None, None, ), # 1 - ) - - def __init__(self, tableNameOrRegionName=None,): - self.tableNameOrRegionName = tableNameOrRegionName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableNameOrRegionName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('majorCompact_args') - if self.tableNameOrRegionName != None: - oprot.writeFieldBegin('tableNameOrRegionName', TType.STRING, 1) - oprot.writeString(self.tableNameOrRegionName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class majorCompact_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('majorCompact_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getTableNames_args: - - thrift_spec = ( - ) - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getTableNames_args') - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getTableNames_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype19, _size16) = iprot.readListBegin() - for _i20 in xrange(_size16): - _elem21 = iprot.readString(); - self.success.append(_elem21) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getTableNames_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRING, len(self.success)) - for iter22 in self.success: - oprot.writeString(iter22) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getColumnDescriptors_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getColumnDescriptors_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getColumnDescriptors_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(ColumnDescriptor, ColumnDescriptor.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.MAP: - self.success = {} - (_ktype24, _vtype25, _size23 ) = iprot.readMapBegin() - for _i27 in xrange(_size23): - _key28 = iprot.readString(); - _val29 = ColumnDescriptor() - _val29.read(iprot) - self.success[_key28] = _val29 - iprot.readMapEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getColumnDescriptors_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.MAP, 0) - oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.success)) - for kiter30,viter31 in self.success.items(): - oprot.writeString(kiter30) - viter31.write(oprot) - oprot.writeMapEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getTableRegions_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getTableRegions_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getTableRegions_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRegionInfo, TRegionInfo.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype35, _size32) = iprot.readListBegin() - for _i36 in xrange(_size32): - _elem37 = TRegionInfo() - _elem37.read(iprot) - self.success.append(_elem37) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getTableRegions_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter38 in self.success: - iter38.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class createTable_args: - """ - Attributes: - - tableName - - columnFamilies - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.LIST, 'columnFamilies', (TType.STRUCT,(ColumnDescriptor, ColumnDescriptor.thrift_spec)), None, ), # 2 - ) - - def __init__(self, tableName=None, columnFamilies=None,): - self.tableName = tableName - self.columnFamilies = columnFamilies - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.columnFamilies = [] - (_etype42, _size39) = iprot.readListBegin() - for _i43 in xrange(_size39): - _elem44 = ColumnDescriptor() - _elem44.read(iprot) - self.columnFamilies.append(_elem44) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('createTable_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.columnFamilies != None: - oprot.writeFieldBegin('columnFamilies', TType.LIST, 2) - oprot.writeListBegin(TType.STRUCT, len(self.columnFamilies)) - for iter45 in self.columnFamilies: - iter45.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class createTable_result: - """ - Attributes: - - io - - ia - - exist - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'exist', (AlreadyExists, AlreadyExists.thrift_spec), None, ), # 3 - ) - - def __init__(self, io=None, ia=None, exist=None,): - self.io = io - self.ia = ia - self.exist = exist - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.exist = AlreadyExists() - self.exist.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('createTable_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - if self.exist != None: - oprot.writeFieldBegin('exist', TType.STRUCT, 3) - self.exist.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteTable_args: - """ - Attributes: - - tableName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - ) - - def __init__(self, tableName=None,): - self.tableName = tableName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteTable_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteTable_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteTable_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_args: - """ - Attributes: - - tableName - - row - - column - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, column=None,): - self.tableName = tableName - self.row = row - self.column = column - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype49, _size46) = iprot.readListBegin() - for _i50 in xrange(_size46): - _elem51 = TCell() - _elem51.read(iprot) - self.success.append(_elem51) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter52 in self.success: - iter52.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getVer_args: - """ - Attributes: - - tableName - - row - - column - - numVersions - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - (4, TType.I32, 'numVersions', None, None, ), # 4 - ) - - def __init__(self, tableName=None, row=None, column=None, numVersions=None,): - self.tableName = tableName - self.row = row - self.column = column - self.numVersions = numVersions - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I32: - self.numVersions = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getVer_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - if self.numVersions != None: - oprot.writeFieldBegin('numVersions', TType.I32, 4) - oprot.writeI32(self.numVersions) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getVer_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype56, _size53) = iprot.readListBegin() - for _i57 in xrange(_size53): - _elem58 = TCell() - _elem58.read(iprot) - self.success.append(_elem58) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getVer_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter59 in self.success: - iter59.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getVerTs_args: - """ - Attributes: - - tableName - - row - - column - - timestamp - - numVersions - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - (4, TType.I64, 'timestamp', None, None, ), # 4 - (5, TType.I32, 'numVersions', None, None, ), # 5 - ) - - def __init__(self, tableName=None, row=None, column=None, timestamp=None, numVersions=None,): - self.tableName = tableName - self.row = row - self.column = column - self.timestamp = timestamp - self.numVersions = numVersions - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - elif fid == 5: - if ftype == TType.I32: - self.numVersions = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getVerTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 4) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - if self.numVersions != None: - oprot.writeFieldBegin('numVersions', TType.I32, 5) - oprot.writeI32(self.numVersions) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getVerTs_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype63, _size60) = iprot.readListBegin() - for _i64 in xrange(_size60): - _elem65 = TCell() - _elem65.read(iprot) - self.success.append(_elem65) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getVerTs_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter66 in self.success: - iter66.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRow_args: - """ - Attributes: - - tableName - - row - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - ) - - def __init__(self, tableName=None, row=None,): - self.tableName = tableName - self.row = row - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRow_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRow_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype70, _size67) = iprot.readListBegin() - for _i71 in xrange(_size67): - _elem72 = TRowResult() - _elem72.read(iprot) - self.success.append(_elem72) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRow_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter73 in self.success: - iter73.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowWithColumns_args: - """ - Attributes: - - tableName - - row - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.LIST, 'columns', (TType.STRING,None), None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, columns=None,): - self.tableName = tableName - self.row = row - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.columns = [] - (_etype77, _size74) = iprot.readListBegin() - for _i78 in xrange(_size74): - _elem79 = iprot.readString(); - self.columns.append(_elem79) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowWithColumns_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 3) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter80 in self.columns: - oprot.writeString(iter80) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowWithColumns_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype84, _size81) = iprot.readListBegin() - for _i85 in xrange(_size81): - _elem86 = TRowResult() - _elem86.read(iprot) - self.success.append(_elem86) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowWithColumns_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter87 in self.success: - iter87.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowTs_args: - """ - Attributes: - - tableName - - row - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.I64, 'timestamp', None, None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, timestamp=None,): - self.tableName = tableName - self.row = row - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 3) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowTs_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype91, _size88) = iprot.readListBegin() - for _i92 in xrange(_size88): - _elem93 = TRowResult() - _elem93.read(iprot) - self.success.append(_elem93) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowTs_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter94 in self.success: - iter94.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowWithColumnsTs_args: - """ - Attributes: - - tableName - - row - - columns - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.LIST, 'columns', (TType.STRING,None), None, ), # 3 - (4, TType.I64, 'timestamp', None, None, ), # 4 - ) - - def __init__(self, tableName=None, row=None, columns=None, timestamp=None,): - self.tableName = tableName - self.row = row - self.columns = columns - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.columns = [] - (_etype98, _size95) = iprot.readListBegin() - for _i99 in xrange(_size95): - _elem100 = iprot.readString(); - self.columns.append(_elem100) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowWithColumnsTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 3) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter101 in self.columns: - oprot.writeString(iter101) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 4) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class getRowWithColumnsTs_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype105, _size102) = iprot.readListBegin() - for _i106 in xrange(_size102): - _elem107 = TRowResult() - _elem107.read(iprot) - self.success.append(_elem107) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getRowWithColumnsTs_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter108 in self.success: - iter108.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRow_args: - """ - Attributes: - - tableName - - row - - mutations - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.LIST, 'mutations', (TType.STRUCT,(Mutation, Mutation.thrift_spec)), None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, mutations=None,): - self.tableName = tableName - self.row = row - self.mutations = mutations - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.mutations = [] - (_etype112, _size109) = iprot.readListBegin() - for _i113 in xrange(_size109): - _elem114 = Mutation() - _elem114.read(iprot) - self.mutations.append(_elem114) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRow_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.mutations != None: - oprot.writeFieldBegin('mutations', TType.LIST, 3) - oprot.writeListBegin(TType.STRUCT, len(self.mutations)) - for iter115 in self.mutations: - iter115.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRow_result: - """ - Attributes: - - io - - ia - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, io=None, ia=None,): - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRow_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRowTs_args: - """ - Attributes: - - tableName - - row - - mutations - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.LIST, 'mutations', (TType.STRUCT,(Mutation, Mutation.thrift_spec)), None, ), # 3 - (4, TType.I64, 'timestamp', None, None, ), # 4 - ) - - def __init__(self, tableName=None, row=None, mutations=None, timestamp=None,): - self.tableName = tableName - self.row = row - self.mutations = mutations - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.mutations = [] - (_etype119, _size116) = iprot.readListBegin() - for _i120 in xrange(_size116): - _elem121 = Mutation() - _elem121.read(iprot) - self.mutations.append(_elem121) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRowTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.mutations != None: - oprot.writeFieldBegin('mutations', TType.LIST, 3) - oprot.writeListBegin(TType.STRUCT, len(self.mutations)) - for iter122 in self.mutations: - iter122.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 4) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRowTs_result: - """ - Attributes: - - io - - ia - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, io=None, ia=None,): - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRowTs_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRows_args: - """ - Attributes: - - tableName - - rowBatches - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.LIST, 'rowBatches', (TType.STRUCT,(BatchMutation, BatchMutation.thrift_spec)), None, ), # 2 - ) - - def __init__(self, tableName=None, rowBatches=None,): - self.tableName = tableName - self.rowBatches = rowBatches - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.rowBatches = [] - (_etype126, _size123) = iprot.readListBegin() - for _i127 in xrange(_size123): - _elem128 = BatchMutation() - _elem128.read(iprot) - self.rowBatches.append(_elem128) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRows_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.rowBatches != None: - oprot.writeFieldBegin('rowBatches', TType.LIST, 2) - oprot.writeListBegin(TType.STRUCT, len(self.rowBatches)) - for iter129 in self.rowBatches: - iter129.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRows_result: - """ - Attributes: - - io - - ia - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, io=None, ia=None,): - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRows_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRowsTs_args: - """ - Attributes: - - tableName - - rowBatches - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.LIST, 'rowBatches', (TType.STRUCT,(BatchMutation, BatchMutation.thrift_spec)), None, ), # 2 - (3, TType.I64, 'timestamp', None, None, ), # 3 - ) - - def __init__(self, tableName=None, rowBatches=None, timestamp=None,): - self.tableName = tableName - self.rowBatches = rowBatches - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.rowBatches = [] - (_etype133, _size130) = iprot.readListBegin() - for _i134 in xrange(_size130): - _elem135 = BatchMutation() - _elem135.read(iprot) - self.rowBatches.append(_elem135) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRowsTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.rowBatches != None: - oprot.writeFieldBegin('rowBatches', TType.LIST, 2) - oprot.writeListBegin(TType.STRUCT, len(self.rowBatches)) - for iter136 in self.rowBatches: - iter136.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 3) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class mutateRowsTs_result: - """ - Attributes: - - io - - ia - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, io=None, ia=None,): - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('mutateRowsTs_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class atomicIncrement_args: - """ - Attributes: - - tableName - - row - - column - - value - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - (4, TType.I64, 'value', None, None, ), # 4 - ) - - def __init__(self, tableName=None, row=None, column=None, value=None,): - self.tableName = tableName - self.row = row - self.column = column - self.value = value - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.value = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('atomicIncrement_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - if self.value != None: - oprot.writeFieldBegin('value', TType.I64, 4) - oprot.writeI64(self.value) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class atomicIncrement_result: - """ - Attributes: - - success - - io - - ia - """ - - thrift_spec = ( - (0, TType.I64, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, success=None, io=None, ia=None,): - self.success = success - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I64: - self.success = iprot.readI64(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('atomicIncrement_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I64, 0) - oprot.writeI64(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAll_args: - """ - Attributes: - - tableName - - row - - column - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, column=None,): - self.tableName = tableName - self.row = row - self.column = column - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAll_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAll_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAll_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllTs_args: - """ - Attributes: - - tableName - - row - - column - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.STRING, 'column', None, None, ), # 3 - (4, TType.I64, 'timestamp', None, None, ), # 4 - ) - - def __init__(self, tableName=None, row=None, column=None, timestamp=None,): - self.tableName = tableName - self.row = row - self.column = column - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 3) - oprot.writeString(self.column) - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 4) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllTs_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllTs_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllRow_args: - """ - Attributes: - - tableName - - row - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - ) - - def __init__(self, tableName=None, row=None,): - self.tableName = tableName - self.row = row - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllRow_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllRow_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllRow_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllRowTs_args: - """ - Attributes: - - tableName - - row - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'row', None, None, ), # 2 - (3, TType.I64, 'timestamp', None, None, ), # 3 - ) - - def __init__(self, tableName=None, row=None, timestamp=None,): - self.tableName = tableName - self.row = row - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllRowTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 2) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 3) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class deleteAllRowTs_result: - """ - Attributes: - - io - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, io=None,): - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('deleteAllRowTs_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpen_args: - """ - Attributes: - - tableName - - startRow - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'startRow', None, None, ), # 2 - (3, TType.LIST, 'columns', (TType.STRING,None), None, ), # 3 - ) - - def __init__(self, tableName=None, startRow=None, columns=None,): - self.tableName = tableName - self.startRow = startRow - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.startRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.columns = [] - (_etype140, _size137) = iprot.readListBegin() - for _i141 in xrange(_size137): - _elem142 = iprot.readString(); - self.columns.append(_elem142) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpen_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.startRow != None: - oprot.writeFieldBegin('startRow', TType.STRING, 2) - oprot.writeString(self.startRow) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 3) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter143 in self.columns: - oprot.writeString(iter143) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpen_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpen_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithStop_args: - """ - Attributes: - - tableName - - startRow - - stopRow - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'startRow', None, None, ), # 2 - (3, TType.STRING, 'stopRow', None, None, ), # 3 - (4, TType.LIST, 'columns', (TType.STRING,None), None, ), # 4 - ) - - def __init__(self, tableName=None, startRow=None, stopRow=None, columns=None,): - self.tableName = tableName - self.startRow = startRow - self.stopRow = stopRow - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.startRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.stopRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.LIST: - self.columns = [] - (_etype147, _size144) = iprot.readListBegin() - for _i148 in xrange(_size144): - _elem149 = iprot.readString(); - self.columns.append(_elem149) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithStop_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.startRow != None: - oprot.writeFieldBegin('startRow', TType.STRING, 2) - oprot.writeString(self.startRow) - oprot.writeFieldEnd() - if self.stopRow != None: - oprot.writeFieldBegin('stopRow', TType.STRING, 3) - oprot.writeString(self.stopRow) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 4) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter150 in self.columns: - oprot.writeString(iter150) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithStop_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithStop_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithPrefix_args: - """ - Attributes: - - tableName - - startAndPrefix - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'startAndPrefix', None, None, ), # 2 - (3, TType.LIST, 'columns', (TType.STRING,None), None, ), # 3 - ) - - def __init__(self, tableName=None, startAndPrefix=None, columns=None,): - self.tableName = tableName - self.startAndPrefix = startAndPrefix - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.startAndPrefix = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.columns = [] - (_etype154, _size151) = iprot.readListBegin() - for _i155 in xrange(_size151): - _elem156 = iprot.readString(); - self.columns.append(_elem156) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithPrefix_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.startAndPrefix != None: - oprot.writeFieldBegin('startAndPrefix', TType.STRING, 2) - oprot.writeString(self.startAndPrefix) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 3) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter157 in self.columns: - oprot.writeString(iter157) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithPrefix_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithPrefix_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenTs_args: - """ - Attributes: - - tableName - - startRow - - columns - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'startRow', None, None, ), # 2 - (3, TType.LIST, 'columns', (TType.STRING,None), None, ), # 3 - (4, TType.I64, 'timestamp', None, None, ), # 4 - ) - - def __init__(self, tableName=None, startRow=None, columns=None, timestamp=None,): - self.tableName = tableName - self.startRow = startRow - self.columns = columns - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.startRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.columns = [] - (_etype161, _size158) = iprot.readListBegin() - for _i162 in xrange(_size158): - _elem163 = iprot.readString(); - self.columns.append(_elem163) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.startRow != None: - oprot.writeFieldBegin('startRow', TType.STRING, 2) - oprot.writeString(self.startRow) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 3) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter164 in self.columns: - oprot.writeString(iter164) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 4) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenTs_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenTs_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithStopTs_args: - """ - Attributes: - - tableName - - startRow - - stopRow - - columns - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'tableName', None, None, ), # 1 - (2, TType.STRING, 'startRow', None, None, ), # 2 - (3, TType.STRING, 'stopRow', None, None, ), # 3 - (4, TType.LIST, 'columns', (TType.STRING,None), None, ), # 4 - (5, TType.I64, 'timestamp', None, None, ), # 5 - ) - - def __init__(self, tableName=None, startRow=None, stopRow=None, columns=None, timestamp=None,): - self.tableName = tableName - self.startRow = startRow - self.stopRow = stopRow - self.columns = columns - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.tableName = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.startRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.stopRow = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.LIST: - self.columns = [] - (_etype168, _size165) = iprot.readListBegin() - for _i169 in xrange(_size165): - _elem170 = iprot.readString(); - self.columns.append(_elem170) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 5: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithStopTs_args') - if self.tableName != None: - oprot.writeFieldBegin('tableName', TType.STRING, 1) - oprot.writeString(self.tableName) - oprot.writeFieldEnd() - if self.startRow != None: - oprot.writeFieldBegin('startRow', TType.STRING, 2) - oprot.writeString(self.startRow) - oprot.writeFieldEnd() - if self.stopRow != None: - oprot.writeFieldBegin('stopRow', TType.STRING, 3) - oprot.writeString(self.stopRow) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 4) - oprot.writeListBegin(TType.STRING, len(self.columns)) - for iter171 in self.columns: - oprot.writeString(iter171) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 5) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerOpenWithStopTs_result: - """ - Attributes: - - success - - io - """ - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, io=None,): - self.success = success - self.io = io - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerOpenWithStopTs_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerGet_args: - """ - Attributes: - - id - """ - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'id', None, None, ), # 1 - ) - - def __init__(self, id=None,): - self.id = id - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I32: - self.id = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerGet_args') - if self.id != None: - oprot.writeFieldBegin('id', TType.I32, 1) - oprot.writeI32(self.id) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerGet_result: - """ - Attributes: - - success - - io - - ia - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, success=None, io=None, ia=None,): - self.success = success - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype175, _size172) = iprot.readListBegin() - for _i176 in xrange(_size172): - _elem177 = TRowResult() - _elem177.read(iprot) - self.success.append(_elem177) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerGet_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter178 in self.success: - iter178.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerGetList_args: - """ - Attributes: - - id - - nbRows - """ - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'id', None, None, ), # 1 - (2, TType.I32, 'nbRows', None, None, ), # 2 - ) - - def __init__(self, id=None, nbRows=None,): - self.id = id - self.nbRows = nbRows - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I32: - self.id = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I32: - self.nbRows = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerGetList_args') - if self.id != None: - oprot.writeFieldBegin('id', TType.I32, 1) - oprot.writeI32(self.id) - oprot.writeFieldEnd() - if self.nbRows != None: - oprot.writeFieldBegin('nbRows', TType.I32, 2) - oprot.writeI32(self.nbRows) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerGetList_result: - """ - Attributes: - - success - - io - - ia - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(TRowResult, TRowResult.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, success=None, io=None, ia=None,): - self.success = success - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype182, _size179) = iprot.readListBegin() - for _i183 in xrange(_size179): - _elem184 = TRowResult() - _elem184.read(iprot) - self.success.append(_elem184) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerGetList_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter185 in self.success: - iter185.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerClose_args: - """ - Attributes: - - id - """ - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'id', None, None, ), # 1 - ) - - def __init__(self, id=None,): - self.id = id - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I32: - self.id = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerClose_args') - if self.id != None: - oprot.writeFieldBegin('id', TType.I32, 1) - oprot.writeI32(self.id) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class scannerClose_result: - """ - Attributes: - - io - - ia - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'io', (IOError, IOError.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ia', (IllegalArgument, IllegalArgument.thrift_spec), None, ), # 2 - ) - - def __init__(self, io=None, ia=None,): - self.io = io - self.ia = ia - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.io = IOError() - self.io.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ia = IllegalArgument() - self.ia.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('scannerClose_result') - if self.io != None: - oprot.writeFieldBegin('io', TType.STRUCT, 1) - self.io.write(oprot) - oprot.writeFieldEnd() - if self.ia != None: - oprot.writeFieldBegin('ia', TType.STRUCT, 2) - self.ia.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - - diff --git a/thirdparty/hbase/ttypes.py b/thirdparty/hbase/ttypes.py deleted file mode 100644 index 335e609478..0000000000 --- a/thirdparty/hbase/ttypes.py +++ /dev/null @@ -1,780 +0,0 @@ -# -# Autogenerated by Thrift -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# - -from thrift.Thrift import * - -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - - -class TCell: - """ - TCell - Used to transport a cell value (byte[]) and the timestamp it was - stored with together as a result for get and getRow methods. This promotes - the timestamp of a cell to a first-class value, making it easy to take - note of temporal data. Cell is used all the way from HStore up to HTable. - - Attributes: - - value - - timestamp - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'value', None, None, ), # 1 - (2, TType.I64, 'timestamp', None, None, ), # 2 - ) - - def __init__(self, value=None, timestamp=None,): - self.value = value - self.timestamp = timestamp - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.value = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I64: - self.timestamp = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('TCell') - if self.value != None: - oprot.writeFieldBegin('value', TType.STRING, 1) - oprot.writeString(self.value) - oprot.writeFieldEnd() - if self.timestamp != None: - oprot.writeFieldBegin('timestamp', TType.I64, 2) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class ColumnDescriptor: - """ - An HColumnDescriptor contains information about a column family - such as the number of versions, compression settings, etc. It is - used as input when creating a table or adding a column. - - Attributes: - - name - - maxVersions - - compression - - inMemory - - bloomFilterType - - bloomFilterVectorSize - - bloomFilterNbHashes - - blockCacheEnabled - - timeToLive - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.I32, 'maxVersions', None, 3, ), # 2 - (3, TType.STRING, 'compression', None, "NONE", ), # 3 - (4, TType.BOOL, 'inMemory', None, False, ), # 4 - (5, TType.STRING, 'bloomFilterType', None, "NONE", ), # 5 - (6, TType.I32, 'bloomFilterVectorSize', None, 0, ), # 6 - (7, TType.I32, 'bloomFilterNbHashes', None, 0, ), # 7 - (8, TType.BOOL, 'blockCacheEnabled', None, False, ), # 8 - (9, TType.I32, 'timeToLive', None, -1, ), # 9 - ) - - 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],): - self.name = name - self.maxVersions = maxVersions - self.compression = compression - self.inMemory = inMemory - self.bloomFilterType = bloomFilterType - self.bloomFilterVectorSize = bloomFilterVectorSize - self.bloomFilterNbHashes = bloomFilterNbHashes - self.blockCacheEnabled = blockCacheEnabled - self.timeToLive = timeToLive - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.name = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I32: - self.maxVersions = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.compression = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.BOOL: - self.inMemory = iprot.readBool(); - else: - iprot.skip(ftype) - elif fid == 5: - if ftype == TType.STRING: - self.bloomFilterType = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 6: - if ftype == TType.I32: - self.bloomFilterVectorSize = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 7: - if ftype == TType.I32: - self.bloomFilterNbHashes = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 8: - if ftype == TType.BOOL: - self.blockCacheEnabled = iprot.readBool(); - else: - iprot.skip(ftype) - elif fid == 9: - if ftype == TType.I32: - self.timeToLive = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('ColumnDescriptor') - if self.name != None: - oprot.writeFieldBegin('name', TType.STRING, 1) - oprot.writeString(self.name) - oprot.writeFieldEnd() - if self.maxVersions != None: - oprot.writeFieldBegin('maxVersions', TType.I32, 2) - oprot.writeI32(self.maxVersions) - oprot.writeFieldEnd() - if self.compression != None: - oprot.writeFieldBegin('compression', TType.STRING, 3) - oprot.writeString(self.compression) - oprot.writeFieldEnd() - if self.inMemory != None: - oprot.writeFieldBegin('inMemory', TType.BOOL, 4) - oprot.writeBool(self.inMemory) - oprot.writeFieldEnd() - if self.bloomFilterType != None: - oprot.writeFieldBegin('bloomFilterType', TType.STRING, 5) - oprot.writeString(self.bloomFilterType) - oprot.writeFieldEnd() - if self.bloomFilterVectorSize != None: - oprot.writeFieldBegin('bloomFilterVectorSize', TType.I32, 6) - oprot.writeI32(self.bloomFilterVectorSize) - oprot.writeFieldEnd() - if self.bloomFilterNbHashes != None: - oprot.writeFieldBegin('bloomFilterNbHashes', TType.I32, 7) - oprot.writeI32(self.bloomFilterNbHashes) - oprot.writeFieldEnd() - if self.blockCacheEnabled != None: - oprot.writeFieldBegin('blockCacheEnabled', TType.BOOL, 8) - oprot.writeBool(self.blockCacheEnabled) - oprot.writeFieldEnd() - if self.timeToLive != None: - oprot.writeFieldBegin('timeToLive', TType.I32, 9) - oprot.writeI32(self.timeToLive) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class TRegionInfo: - """ - A TRegionInfo contains information about an HTable region. - - Attributes: - - startKey - - endKey - - id - - name - - version - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'startKey', None, None, ), # 1 - (2, TType.STRING, 'endKey', None, None, ), # 2 - (3, TType.I64, 'id', None, None, ), # 3 - (4, TType.STRING, 'name', None, None, ), # 4 - (5, TType.BYTE, 'version', None, None, ), # 5 - ) - - def __init__(self, startKey=None, endKey=None, id=None, name=None, version=None,): - self.startKey = startKey - self.endKey = endKey - self.id = id - self.name = name - self.version = version - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.startKey = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.endKey = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I64: - self.id = iprot.readI64(); - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.STRING: - self.name = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 5: - if ftype == TType.BYTE: - self.version = iprot.readByte(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('TRegionInfo') - if self.startKey != None: - oprot.writeFieldBegin('startKey', TType.STRING, 1) - oprot.writeString(self.startKey) - oprot.writeFieldEnd() - if self.endKey != None: - oprot.writeFieldBegin('endKey', TType.STRING, 2) - oprot.writeString(self.endKey) - oprot.writeFieldEnd() - if self.id != None: - oprot.writeFieldBegin('id', TType.I64, 3) - oprot.writeI64(self.id) - oprot.writeFieldEnd() - if self.name != None: - oprot.writeFieldBegin('name', TType.STRING, 4) - oprot.writeString(self.name) - oprot.writeFieldEnd() - if self.version != None: - oprot.writeFieldBegin('version', TType.BYTE, 5) - oprot.writeByte(self.version) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class Mutation: - """ - A Mutation object is used to either update or delete a column-value. - - Attributes: - - isDelete - - column - - value - """ - - thrift_spec = ( - None, # 0 - (1, TType.BOOL, 'isDelete', None, False, ), # 1 - (2, TType.STRING, 'column', None, None, ), # 2 - (3, TType.STRING, 'value', None, None, ), # 3 - ) - - def __init__(self, isDelete=thrift_spec[1][4], column=None, value=None,): - self.isDelete = isDelete - self.column = column - self.value = value - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.BOOL: - self.isDelete = iprot.readBool(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.column = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.value = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Mutation') - if self.isDelete != None: - oprot.writeFieldBegin('isDelete', TType.BOOL, 1) - oprot.writeBool(self.isDelete) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRING, 2) - oprot.writeString(self.column) - oprot.writeFieldEnd() - if self.value != None: - oprot.writeFieldBegin('value', TType.STRING, 3) - oprot.writeString(self.value) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class BatchMutation: - """ - A BatchMutation object is used to apply a number of Mutations to a single row. - - Attributes: - - row - - mutations - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'row', None, None, ), # 1 - (2, TType.LIST, 'mutations', (TType.STRUCT,(Mutation, Mutation.thrift_spec)), None, ), # 2 - ) - - def __init__(self, row=None, mutations=None,): - self.row = row - self.mutations = mutations - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.mutations = [] - (_etype3, _size0) = iprot.readListBegin() - for _i4 in xrange(_size0): - _elem5 = Mutation() - _elem5.read(iprot) - self.mutations.append(_elem5) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('BatchMutation') - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 1) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.mutations != None: - oprot.writeFieldBegin('mutations', TType.LIST, 2) - oprot.writeListBegin(TType.STRUCT, len(self.mutations)) - for iter6 in self.mutations: - iter6.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class TRowResult: - """ - Holds row name and then a map of columns to cells. - - Attributes: - - row - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'row', None, None, ), # 1 - (2, TType.MAP, 'columns', (TType.STRING,None,TType.STRUCT,(TCell, TCell.thrift_spec)), None, ), # 2 - ) - - def __init__(self, row=None, columns=None,): - self.row = row - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.row = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.MAP: - self.columns = {} - (_ktype8, _vtype9, _size7 ) = iprot.readMapBegin() - for _i11 in xrange(_size7): - _key12 = iprot.readString(); - _val13 = TCell() - _val13.read(iprot) - self.columns[_key12] = _val13 - iprot.readMapEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('TRowResult') - if self.row != None: - oprot.writeFieldBegin('row', TType.STRING, 1) - oprot.writeString(self.row) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.MAP, 2) - oprot.writeMapBegin(TType.STRING, TType.STRUCT, len(self.columns)) - for kiter14,viter15 in self.columns.items(): - oprot.writeString(kiter14) - viter15.write(oprot) - oprot.writeMapEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class IOError(Exception): - """ - An IOError exception signals that an error occurred communicating - to the Hbase master or an Hbase region server. Also used to return - more general Hbase error conditions. - - Attributes: - - message - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'message', None, None, ), # 1 - ) - - def __init__(self, message=None,): - self.message = message - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.message = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('IOError') - if self.message != None: - oprot.writeFieldBegin('message', TType.STRING, 1) - oprot.writeString(self.message) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __str__(self): - return repr(self) - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class IllegalArgument(Exception): - """ - An IllegalArgument exception indicates an illegal or invalid - argument was passed into a procedure. - - Attributes: - - message - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'message', None, None, ), # 1 - ) - - def __init__(self, message=None,): - self.message = message - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.message = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('IllegalArgument') - if self.message != None: - oprot.writeFieldBegin('message', TType.STRING, 1) - oprot.writeString(self.message) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __str__(self): - return repr(self) - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class AlreadyExists(Exception): - """ - An AlreadyExists exceptions signals that a table with the specified - name already exists - - Attributes: - - message - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'message', None, None, ), # 1 - ) - - def __init__(self, message=None,): - self.message = message - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.message = iprot.readString(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('AlreadyExists') - if self.message != None: - oprot.writeFieldBegin('message', TType.STRING, 1) - oprot.writeString(self.message) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def __str__(self): - return repr(self) - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - diff --git a/thirdparty/thrift/TSCons.py b/thirdparty/thrift/TSCons.py deleted file mode 100644 index 24046256cc..0000000000 --- a/thirdparty/thrift/TSCons.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from os import path -from SCons.Builder import Builder - -def scons_env(env, add=''): - opath = path.dirname(path.abspath('$TARGET')) - lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' - cppbuild = Builder(action = lstr) - env.Append(BUILDERS = {'ThriftCpp' : cppbuild}) - -def gen_cpp(env, dir, file): - scons_env(env) - suffixes = ['_types.h', '_types.cpp'] - targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) - return env.ThriftCpp(targets, dir+file+'.thrift') diff --git a/thirdparty/thrift/Thrift.py b/thirdparty/thrift/Thrift.py deleted file mode 100644 index 21d7aa4e51..0000000000 --- a/thirdparty/thrift/Thrift.py +++ /dev/null @@ -1,123 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -class TType: - STOP = 0 - VOID = 1 - BOOL = 2 - BYTE = 3 - I08 = 3 - DOUBLE = 4 - I16 = 6 - I32 = 8 - I64 = 10 - STRING = 11 - UTF7 = 11 - STRUCT = 12 - MAP = 13 - SET = 14 - LIST = 15 - UTF8 = 16 - UTF16 = 17 - -class TMessageType: - CALL = 1 - REPLY = 2 - EXCEPTION = 3 - ONEWAY = 4 - -class TProcessor: - - """Base class for procsessor, which works on two streams.""" - - def process(iprot, oprot): - pass - -class TException(Exception): - - """Base class for all thrift exceptions.""" - - def __init__(self, message=None): - Exception.__init__(self, message) - self.message = message - -class TApplicationException(TException): - - """Application level thrift exceptions.""" - - UNKNOWN = 0 - UNKNOWN_METHOD = 1 - INVALID_MESSAGE_TYPE = 2 - WRONG_METHOD_NAME = 3 - BAD_SEQUENCE_ID = 4 - MISSING_RESULT = 5 - - def __init__(self, type=UNKNOWN, message=None): - TException.__init__(self, message) - self.type = type - - def __str__(self): - if self.message: - return self.message - elif self.type == UNKNOWN_METHOD: - return 'Unknown method' - elif self.type == INVALID_MESSAGE_TYPE: - return 'Invalid message type' - elif self.type == WRONG_METHOD_NAME: - return 'Wrong method name' - elif self.type == BAD_SEQUENCE_ID: - return 'Bad sequence ID' - elif self.type == MISSING_RESULT: - return 'Missing result' - else: - return 'Default (unknown) TApplicationException' - - def read(self, iprot): - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.message = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I32: - self.type = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - oprot.writeStructBegin('TApplicationException') - if self.message != None: - oprot.writeFieldBegin('message', TType.STRING, 1) - oprot.writeString(self.message) - oprot.writeFieldEnd() - if self.type != None: - oprot.writeFieldBegin('type', TType.I32, 2) - oprot.writeI32(self.type) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() diff --git a/thirdparty/thrift/__init__.py b/thirdparty/thrift/__init__.py deleted file mode 100644 index 48d659c403..0000000000 --- a/thirdparty/thrift/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -__all__ = ['Thrift', 'TSCons'] diff --git a/thirdparty/thrift/protocol/TBinaryProtocol.py b/thirdparty/thrift/protocol/TBinaryProtocol.py deleted file mode 100644 index 50c6aa8963..0000000000 --- a/thirdparty/thrift/protocol/TBinaryProtocol.py +++ /dev/null @@ -1,259 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from TProtocol import * -from struct import pack, unpack - -class TBinaryProtocol(TProtocolBase): - - """Binary implementation of the Thrift protocol driver.""" - - # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be - # positive, converting this into a long. If we hardcode the int value - # instead it'll stay in 32 bit-land. - - # VERSION_MASK = 0xffff0000 - VERSION_MASK = -65536 - - # VERSION_1 = 0x80010000 - VERSION_1 = -2147418112 - - TYPE_MASK = 0x000000ff - - def __init__(self, trans, strictRead=False, strictWrite=True): - TProtocolBase.__init__(self, trans) - self.strictRead = strictRead - self.strictWrite = strictWrite - - def writeMessageBegin(self, name, type, seqid): - if self.strictWrite: - self.writeI32(TBinaryProtocol.VERSION_1 | type) - self.writeString(name) - self.writeI32(seqid) - else: - self.writeString(name) - self.writeByte(type) - self.writeI32(seqid) - - def writeMessageEnd(self): - pass - - def writeStructBegin(self, name): - pass - - def writeStructEnd(self): - pass - - def writeFieldBegin(self, name, type, id): - self.writeByte(type) - self.writeI16(id) - - def writeFieldEnd(self): - pass - - def writeFieldStop(self): - self.writeByte(TType.STOP); - - def writeMapBegin(self, ktype, vtype, size): - self.writeByte(ktype) - self.writeByte(vtype) - self.writeI32(size) - - def writeMapEnd(self): - pass - - def writeListBegin(self, etype, size): - self.writeByte(etype) - self.writeI32(size) - - def writeListEnd(self): - pass - - def writeSetBegin(self, etype, size): - self.writeByte(etype) - self.writeI32(size) - - def writeSetEnd(self): - pass - - def writeBool(self, bool): - if bool: - self.writeByte(1) - else: - self.writeByte(0) - - def writeByte(self, byte): - buff = pack("!b", byte) - self.trans.write(buff) - - def writeI16(self, i16): - buff = pack("!h", i16) - self.trans.write(buff) - - def writeI32(self, i32): - buff = pack("!i", i32) - self.trans.write(buff) - - def writeI64(self, i64): - buff = pack("!q", i64) - self.trans.write(buff) - - def writeDouble(self, dub): - buff = pack("!d", dub) - self.trans.write(buff) - - def writeString(self, str): - self.writeI32(len(str)) - self.trans.write(str) - - def readMessageBegin(self): - sz = self.readI32() - if sz < 0: - version = sz & TBinaryProtocol.VERSION_MASK - if version != TBinaryProtocol.VERSION_1: - raise TProtocolException(type=TProtocolException.BAD_VERSION, message='Bad version in readMessageBegin: %d' % (sz)) - type = sz & TBinaryProtocol.TYPE_MASK - name = self.readString() - seqid = self.readI32() - else: - if self.strictRead: - raise TProtocolException(type=TProtocolException.BAD_VERSION, message='No protocol version header') - name = self.trans.readAll(sz) - type = self.readByte() - seqid = self.readI32() - return (name, type, seqid) - - def readMessageEnd(self): - pass - - def readStructBegin(self): - pass - - def readStructEnd(self): - pass - - def readFieldBegin(self): - type = self.readByte() - if type == TType.STOP: - return (None, type, 0) - id = self.readI16() - return (None, type, id) - - def readFieldEnd(self): - pass - - def readMapBegin(self): - ktype = self.readByte() - vtype = self.readByte() - size = self.readI32() - return (ktype, vtype, size) - - def readMapEnd(self): - pass - - def readListBegin(self): - etype = self.readByte() - size = self.readI32() - return (etype, size) - - def readListEnd(self): - pass - - def readSetBegin(self): - etype = self.readByte() - size = self.readI32() - return (etype, size) - - def readSetEnd(self): - pass - - def readBool(self): - byte = self.readByte() - if byte == 0: - return False - return True - - def readByte(self): - buff = self.trans.readAll(1) - val, = unpack('!b', buff) - return val - - def readI16(self): - buff = self.trans.readAll(2) - val, = unpack('!h', buff) - return val - - def readI32(self): - buff = self.trans.readAll(4) - val, = unpack('!i', buff) - return val - - def readI64(self): - buff = self.trans.readAll(8) - val, = unpack('!q', buff) - return val - - def readDouble(self): - buff = self.trans.readAll(8) - val, = unpack('!d', buff) - return val - - def readString(self): - len = self.readI32() - str = self.trans.readAll(len) - return str - - -class TBinaryProtocolFactory: - def __init__(self, strictRead=False, strictWrite=True): - self.strictRead = strictRead - self.strictWrite = strictWrite - - def getProtocol(self, trans): - prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite) - return prot - - -class TBinaryProtocolAccelerated(TBinaryProtocol): - - """C-Accelerated version of TBinaryProtocol. - - This class does not override any of TBinaryProtocol's methods, - but the generated code recognizes it directly and will call into - our C module to do the encoding, bypassing this object entirely. - We inherit from TBinaryProtocol so that the normal TBinaryProtocol - encoding can happen if the fastbinary module doesn't work for some - reason. (TODO(dreiss): Make this happen sanely in more cases.) - - In order to take advantage of the C module, just use - TBinaryProtocolAccelerated instead of TBinaryProtocol. - - NOTE: This code was contributed by an external developer. - The internal Thrift team has reviewed and tested it, - but we cannot guarantee that it is production-ready. - Please feel free to report bugs and/or success stories - to the public mailing list. - """ - - pass - - -class TBinaryProtocolAcceleratedFactory: - def getProtocol(self, trans): - return TBinaryProtocolAccelerated(trans) diff --git a/thirdparty/thrift/protocol/TProtocol.py b/thirdparty/thrift/protocol/TProtocol.py deleted file mode 100644 index be3cb1403c..0000000000 --- a/thirdparty/thrift/protocol/TProtocol.py +++ /dev/null @@ -1,205 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from thrift.Thrift import * - -class TProtocolException(TException): - - """Custom Protocol Exception class""" - - UNKNOWN = 0 - INVALID_DATA = 1 - NEGATIVE_SIZE = 2 - SIZE_LIMIT = 3 - BAD_VERSION = 4 - - def __init__(self, type=UNKNOWN, message=None): - TException.__init__(self, message) - self.type = type - -class TProtocolBase: - - """Base class for Thrift protocol driver.""" - - def __init__(self, trans): - self.trans = trans - - def writeMessageBegin(self, name, type, seqid): - pass - - def writeMessageEnd(self): - pass - - def writeStructBegin(self, name): - pass - - def writeStructEnd(self): - pass - - def writeFieldBegin(self, name, type, id): - pass - - def writeFieldEnd(self): - pass - - def writeFieldStop(self): - pass - - def writeMapBegin(self, ktype, vtype, size): - pass - - def writeMapEnd(self): - pass - - def writeListBegin(self, etype, size): - pass - - def writeListEnd(self): - pass - - def writeSetBegin(self, etype, size): - pass - - def writeSetEnd(self): - pass - - def writeBool(self, bool): - pass - - def writeByte(self, byte): - pass - - def writeI16(self, i16): - pass - - def writeI32(self, i32): - pass - - def writeI64(self, i64): - pass - - def writeDouble(self, dub): - pass - - def writeString(self, str): - pass - - def readMessageBegin(self): - pass - - def readMessageEnd(self): - pass - - def readStructBegin(self): - pass - - def readStructEnd(self): - pass - - def readFieldBegin(self): - pass - - def readFieldEnd(self): - pass - - def readMapBegin(self): - pass - - def readMapEnd(self): - pass - - def readListBegin(self): - pass - - def readListEnd(self): - pass - - def readSetBegin(self): - pass - - def readSetEnd(self): - pass - - def readBool(self): - pass - - def readByte(self): - pass - - def readI16(self): - pass - - def readI32(self): - pass - - def readI64(self): - pass - - def readDouble(self): - pass - - def readString(self): - pass - - def skip(self, type): - if type == TType.STOP: - return - elif type == TType.BOOL: - self.readBool() - elif type == TType.BYTE: - self.readByte() - elif type == TType.I16: - self.readI16() - elif type == TType.I32: - self.readI32() - elif type == TType.I64: - self.readI64() - elif type == TType.DOUBLE: - self.readDouble() - elif type == TType.STRING: - self.readString() - elif type == TType.STRUCT: - name = self.readStructBegin() - while True: - (name, type, id) = self.readFieldBegin() - if type == TType.STOP: - break - self.skip(type) - self.readFieldEnd() - self.readStructEnd() - elif type == TType.MAP: - (ktype, vtype, size) = self.readMapBegin() - for i in range(size): - self.skip(ktype) - self.skip(vtype) - self.readMapEnd() - elif type == TType.SET: - (etype, size) = self.readSetBegin() - for i in range(size): - self.skip(etype) - self.readSetEnd() - elif type == TType.LIST: - (etype, size) = self.readListBegin() - for i in range(size): - self.skip(etype) - self.readListEnd() - -class TProtocolFactory: - def getProtocol(self, trans): - pass diff --git a/thirdparty/thrift/protocol/__init__.py b/thirdparty/thrift/protocol/__init__.py deleted file mode 100644 index 01bfe18e59..0000000000 --- a/thirdparty/thrift/protocol/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -__all__ = ['TProtocol', 'TBinaryProtocol', 'fastbinary'] diff --git a/thirdparty/thrift/server/THttpServer.py b/thirdparty/thrift/server/THttpServer.py deleted file mode 100644 index 21fc314184..0000000000 --- a/thirdparty/thrift/server/THttpServer.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -import BaseHTTPServer - -from thrift.server import TServer -from thrift.transport import TTransport - -class THttpServer(TServer.TServer): - """A simple HTTP-based Thrift server - - This class is not very performant, but it is useful (for example) for - acting as a mock version of an Apache-based PHP Thrift endpoint.""" - - def __init__(self, processor, server_address, - inputProtocolFactory, outputProtocolFactory = None): - """Set up protocol factories and HTTP server. - - See BaseHTTPServer for server_address. - See TServer for protocol factories.""" - - if outputProtocolFactory is None: - outputProtocolFactory = inputProtocolFactory - - TServer.TServer.__init__(self, processor, None, None, None, - inputProtocolFactory, outputProtocolFactory) - - thttpserver = self - - class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler): - def do_POST(self): - # Don't care about the request path. - self.send_response(200) - self.send_header("content-type", "application/x-thrift") - self.end_headers() - - itrans = TTransport.TFileObjectTransport(self.rfile) - otrans = TTransport.TFileObjectTransport(self.wfile) - iprot = thttpserver.inputProtocolFactory.getProtocol(itrans) - oprot = thttpserver.outputProtocolFactory.getProtocol(otrans) - thttpserver.processor.process(iprot, oprot) - otrans.flush() - - self.httpd = BaseHTTPServer.HTTPServer(server_address, RequestHander) - - def serve(self): - self.httpd.serve_forever() diff --git a/thirdparty/thrift/server/TNonblockingServer.py b/thirdparty/thrift/server/TNonblockingServer.py deleted file mode 100644 index 29105da0d3..0000000000 --- a/thirdparty/thrift/server/TNonblockingServer.py +++ /dev/null @@ -1,310 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -"""Implementation of non-blocking server. - -The main idea of the server is reciving and sending requests -only from main thread. - -It also makes thread pool server in tasks terms, not connections. -""" -import threading -import socket -import Queue -import select -import struct -import logging - -from thrift.transport import TTransport -from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory - -__all__ = ['TNonblockingServer'] - -class Worker(threading.Thread): - """Worker is a small helper to process incoming connection.""" - def __init__(self, queue): - threading.Thread.__init__(self) - self.queue = queue - - def run(self): - """Process queries from task queue, stop if processor is None.""" - while True: - try: - processor, iprot, oprot, otrans, callback = self.queue.get() - if processor is None: - break - processor.process(iprot, oprot) - callback(True, otrans.getvalue()) - except Exception: - logging.exception("Exception while processing request") - callback(False, '') - -WAIT_LEN = 0 -WAIT_MESSAGE = 1 -WAIT_PROCESS = 2 -SEND_ANSWER = 3 -CLOSED = 4 - -def locked(func): - "Decorator which locks self.lock." - def nested(self, *args, **kwargs): - self.lock.acquire() - try: - return func(self, *args, **kwargs) - finally: - self.lock.release() - return nested - -def socket_exception(func): - "Decorator close object on socket.error." - def read(self, *args, **kwargs): - try: - return func(self, *args, **kwargs) - except socket.error: - self.close() - return read - -class Connection: - """Basic class is represented connection. - - It can be in state: - WAIT_LEN --- connection is reading request len. - WAIT_MESSAGE --- connection is reading request. - WAIT_PROCESS --- connection has just read whole request and - waits for call ready routine. - SEND_ANSWER --- connection is sending answer string (including length - of answer). - CLOSED --- socket was closed and connection should be deleted. - """ - def __init__(self, new_socket, wake_up): - self.socket = new_socket - self.socket.setblocking(False) - self.status = WAIT_LEN - self.len = 0 - self.message = '' - self.lock = threading.Lock() - self.wake_up = wake_up - - def _read_len(self): - """Reads length of request. - - It's really paranoic routine and it may be replaced by - self.socket.recv(4).""" - read = self.socket.recv(4 - len(self.message)) - if len(read) == 0: - # if we read 0 bytes and self.message is empty, it means client close - # connection - if len(self.message) != 0: - logging.error("can't read frame size from socket") - self.close() - return - self.message += read - if len(self.message) == 4: - self.len, = struct.unpack('!i', self.message) - if self.len < 0: - logging.error("negative frame size, it seems client"\ - " doesn't use FramedTransport") - self.close() - elif self.len == 0: - logging.error("empty frame, it's really strange") - self.close() - else: - self.message = '' - self.status = WAIT_MESSAGE - - @socket_exception - def read(self): - """Reads data from stream and switch state.""" - assert self.status in (WAIT_LEN, WAIT_MESSAGE) - if self.status == WAIT_LEN: - self._read_len() - # go back to the main loop here for simplicity instead of - # falling through, even though there is a good chance that - # the message is already available - elif self.status == WAIT_MESSAGE: - read = self.socket.recv(self.len - len(self.message)) - if len(read) == 0: - logging.error("can't read frame from socket (get %d of %d bytes)" % - (len(self.message), self.len)) - self.close() - return - self.message += read - if len(self.message) == self.len: - self.status = WAIT_PROCESS - - @socket_exception - def write(self): - """Writes data from socket and switch state.""" - assert self.status == SEND_ANSWER - sent = self.socket.send(self.message) - if sent == len(self.message): - self.status = WAIT_LEN - self.message = '' - self.len = 0 - else: - self.message = self.message[sent:] - - @locked - def ready(self, all_ok, message): - """Callback function for switching state and waking up main thread. - - This function is the only function witch can be called asynchronous. - - The ready can switch Connection to three states: - WAIT_LEN if request was oneway. - SEND_ANSWER if request was processed in normal way. - CLOSED if request throws unexpected exception. - - The one wakes up main thread. - """ - assert self.status == WAIT_PROCESS - if not all_ok: - self.close() - self.wake_up() - return - self.len = '' - if len(message) == 0: - # it was a oneway request, do not write answer - self.message = '' - self.status = WAIT_LEN - else: - self.message = struct.pack('!i', len(message)) + message - self.status = SEND_ANSWER - self.wake_up() - - @locked - def is_writeable(self): - "Returns True if connection should be added to write list of select." - return self.status == SEND_ANSWER - - # it's not necessary, but... - @locked - def is_readable(self): - "Returns True if connection should be added to read list of select." - return self.status in (WAIT_LEN, WAIT_MESSAGE) - - @locked - def is_closed(self): - "Returns True if connection is closed." - return self.status == CLOSED - - def fileno(self): - "Returns the file descriptor of the associated socket." - return self.socket.fileno() - - def close(self): - "Closes connection" - self.status = CLOSED - self.socket.close() - -class TNonblockingServer: - """Non-blocking server.""" - def __init__(self, processor, lsocket, inputProtocolFactory=None, - outputProtocolFactory=None, threads=10): - self.processor = processor - self.socket = lsocket - self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory() - self.out_protocol = outputProtocolFactory or self.in_protocol - self.threads = int(threads) - self.clients = {} - self.tasks = Queue.Queue() - self._read, self._write = socket.socketpair() - self.prepared = False - - def setNumThreads(self, num): - """Set the number of worker threads that should be created.""" - # implement ThreadPool interface - assert not self.prepared, "You can't change number of threads for working server" - self.threads = num - - def prepare(self): - """Prepares server for serve requests.""" - self.socket.listen() - for _ in xrange(self.threads): - thread = Worker(self.tasks) - thread.setDaemon(True) - thread.start() - self.prepared = True - - def wake_up(self): - """Wake up main thread. - - The server usualy waits in select call in we should terminate one. - The simplest way is using socketpair. - - Select always wait to read from the first socket of socketpair. - - In this case, we can just write anything to the second socket from - socketpair.""" - self._write.send('1') - - def _select(self): - """Does select on open connections.""" - readable = [self.socket.handle.fileno(), self._read.fileno()] - writable = [] - for i, connection in self.clients.items(): - if connection.is_readable(): - readable.append(connection.fileno()) - if connection.is_writeable(): - writable.append(connection.fileno()) - if connection.is_closed(): - del self.clients[i] - return select.select(readable, writable, readable) - - def handle(self): - """Handle requests. - - WARNING! You must call prepare BEFORE calling handle. - """ - assert self.prepared, "You have to call prepare before handle" - rset, wset, xset = self._select() - for readable in rset: - if readable == self._read.fileno(): - # don't care i just need to clean readable flag - self._read.recv(1024) - elif readable == self.socket.handle.fileno(): - client = self.socket.accept().handle - self.clients[client.fileno()] = Connection(client, self.wake_up) - else: - connection = self.clients[readable] - connection.read() - if connection.status == WAIT_PROCESS: - itransport = TTransport.TMemoryBuffer(connection.message) - otransport = TTransport.TMemoryBuffer() - iprot = self.in_protocol.getProtocol(itransport) - oprot = self.out_protocol.getProtocol(otransport) - self.tasks.put([self.processor, iprot, oprot, - otransport, connection.ready]) - for writeable in wset: - self.clients[writeable].write() - for oob in xset: - self.clients[oob].close() - del self.clients[oob] - - def close(self): - """Closes the server.""" - for _ in xrange(self.threads): - self.tasks.put([None, None, None, None, None]) - self.socket.close() - self.prepared = False - - def serve(self): - """Serve forever.""" - self.prepare() - while True: - self.handle() diff --git a/thirdparty/thrift/server/TServer.py b/thirdparty/thrift/server/TServer.py deleted file mode 100644 index 6152911142..0000000000 --- a/thirdparty/thrift/server/TServer.py +++ /dev/null @@ -1,270 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -import logging -import sys -import os -import traceback -import threading -import Queue - -from thrift.Thrift import TProcessor -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol - -class TServer: - - """Base interface for a server, which must have a serve method.""" - - """ 3 constructors for all servers: - 1) (processor, serverTransport) - 2) (processor, serverTransport, transportFactory, protocolFactory) - 3) (processor, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory)""" - def __init__(self, *args): - if (len(args) == 2): - self.__initArgs__(args[0], args[1], - TTransport.TTransportFactoryBase(), - TTransport.TTransportFactoryBase(), - TBinaryProtocol.TBinaryProtocolFactory(), - TBinaryProtocol.TBinaryProtocolFactory()) - elif (len(args) == 4): - self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3]) - elif (len(args) == 6): - self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5]) - - def __initArgs__(self, processor, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory): - self.processor = processor - self.serverTransport = serverTransport - self.inputTransportFactory = inputTransportFactory - self.outputTransportFactory = outputTransportFactory - self.inputProtocolFactory = inputProtocolFactory - self.outputProtocolFactory = outputProtocolFactory - - def serve(self): - pass - -class TSimpleServer(TServer): - - """Simple single-threaded server that just pumps around one transport.""" - - def __init__(self, *args): - TServer.__init__(self, *args) - - def serve(self): - self.serverTransport.listen() - while True: - client = self.serverTransport.accept() - itrans = self.inputTransportFactory.getTransport(client) - otrans = self.outputTransportFactory.getTransport(client) - iprot = self.inputProtocolFactory.getProtocol(itrans) - oprot = self.outputProtocolFactory.getProtocol(otrans) - try: - while True: - self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: - pass - except Exception, x: - logging.exception(x) - - itrans.close() - otrans.close() - -class TThreadedServer(TServer): - - """Threaded server that spawns a new thread per each connection.""" - - def __init__(self, *args): - TServer.__init__(self, *args) - - def serve(self): - self.serverTransport.listen() - while True: - try: - client = self.serverTransport.accept() - t = threading.Thread(target = self.handle, args=(client,)) - t.start() - except KeyboardInterrupt: - raise - except Exception, x: - logging.exception(x) - - def handle(self, client): - itrans = self.inputTransportFactory.getTransport(client) - otrans = self.outputTransportFactory.getTransport(client) - iprot = self.inputProtocolFactory.getProtocol(itrans) - oprot = self.outputProtocolFactory.getProtocol(otrans) - try: - while True: - self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: - pass - except Exception, x: - logging.exception(x) - - itrans.close() - otrans.close() - -class TThreadPoolServer(TServer): - - """Server with a fixed size pool of threads which service requests.""" - - def __init__(self, *args): - TServer.__init__(self, *args) - self.clients = Queue.Queue() - self.threads = 10 - - def setNumThreads(self, num): - """Set the number of worker threads that should be created""" - self.threads = num - - def serveThread(self): - """Loop around getting clients from the shared queue and process them.""" - while True: - try: - client = self.clients.get() - self.serveClient(client) - except Exception, x: - logging.exception(x) - - def serveClient(self, client): - """Process input/output from a client for as long as possible""" - itrans = self.inputTransportFactory.getTransport(client) - otrans = self.outputTransportFactory.getTransport(client) - iprot = self.inputProtocolFactory.getProtocol(itrans) - oprot = self.outputProtocolFactory.getProtocol(otrans) - try: - while True: - self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: - pass - except Exception, x: - logging.exception(x) - - itrans.close() - otrans.close() - - def serve(self): - """Start a fixed number of worker threads and put client into a queue""" - for i in range(self.threads): - try: - t = threading.Thread(target = self.serveThread) - t.start() - except Exception, x: - logging.exception(x) - - # Pump the socket for clients - self.serverTransport.listen() - while True: - try: - client = self.serverTransport.accept() - self.clients.put(client) - except Exception, x: - logging.exception(x) - - -class TForkingServer(TServer): - - """A Thrift server that forks a new process for each request""" - """ - This is more scalable than the threaded server as it does not cause - GIL contention. - - Note that this has different semantics from the threading server. - Specifically, updates to shared variables will no longer be shared. - It will also not work on windows. - - This code is heavily inspired by SocketServer.ForkingMixIn in the - Python stdlib. - """ - - def __init__(self, *args): - TServer.__init__(self, *args) - self.children = [] - - def serve(self): - def try_close(file): - try: - file.close() - except IOError, e: - logging.warning(e, exc_info=True) - - - self.serverTransport.listen() - while True: - client = self.serverTransport.accept() - try: - pid = os.fork() - - if pid: # parent - # add before collect, otherwise you race w/ waitpid - self.children.append(pid) - self.collect_children() - - # Parent must close socket or the connection may not get - # closed promptly - itrans = self.inputTransportFactory.getTransport(client) - otrans = self.outputTransportFactory.getTransport(client) - try_close(itrans) - try_close(otrans) - else: - itrans = self.inputTransportFactory.getTransport(client) - otrans = self.outputTransportFactory.getTransport(client) - - iprot = self.inputProtocolFactory.getProtocol(itrans) - oprot = self.outputProtocolFactory.getProtocol(otrans) - - ecode = 0 - try: - try: - while True: - self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: - pass - except Exception, e: - logging.exception(e) - ecode = 1 - finally: - try_close(itrans) - try_close(otrans) - - os._exit(ecode) - - except TTransport.TTransportException, tx: - pass - except Exception, x: - logging.exception(x) - - - def collect_children(self): - while self.children: - try: - pid, status = os.waitpid(0, os.WNOHANG) - except os.error: - pid = None - - if pid: - self.children.remove(pid) - else: - break - - diff --git a/thirdparty/thrift/server/__init__.py b/thirdparty/thrift/server/__init__.py deleted file mode 100644 index 1bf6e254e7..0000000000 --- a/thirdparty/thrift/server/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -__all__ = ['TServer', 'TNonblockingServer'] diff --git a/thirdparty/thrift/transport/THttpClient.py b/thirdparty/thrift/transport/THttpClient.py deleted file mode 100644 index 5086032bef..0000000000 --- a/thirdparty/thrift/transport/THttpClient.py +++ /dev/null @@ -1,100 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from TTransport import * -from cStringIO import StringIO - -import urlparse -import httplib -import warnings - -class THttpClient(TTransportBase): - - """Http implementation of TTransport base.""" - - def __init__(self, uri_or_host, port=None, path=None): - """THttpClient supports two different types constructor parameters. - - THttpClient(host, port, path) - deprecated - THttpClient(uri) - - Only the second supports https.""" - - if port is not None: - warnings.warn("Please use the THttpClient('http://host:port/path') syntax", DeprecationWarning, stacklevel=2) - self.host = uri_or_host - self.port = port - assert path - self.path = path - self.scheme = 'http' - else: - parsed = urlparse.urlparse(uri_or_host) - self.scheme = parsed.scheme - assert self.scheme in ('http', 'https') - if self.scheme == 'http': - self.port = parsed.port or httplib.HTTP_PORT - elif self.scheme == 'https': - self.port = parsed.port or httplib.HTTPS_PORT - self.host = parsed.hostname - self.path = parsed.path - self.__wbuf = StringIO() - self.__http = None - - def open(self): - if self.scheme == 'http': - self.__http = httplib.HTTP(self.host, self.port) - else: - self.__http = httplib.HTTPS(self.host, self.port) - - def close(self): - self.__http.close() - self.__http = None - - def isOpen(self): - return self.__http != None - - def read(self, sz): - return self.__http.file.read(sz) - - def write(self, buf): - self.__wbuf.write(buf) - - def flush(self): - if self.isOpen(): - self.close() - self.open(); - - # Pull data out of buffer - data = self.__wbuf.getvalue() - self.__wbuf = StringIO() - - # HTTP request - self.__http.putrequest('POST', self.path) - - # Write headers - self.__http.putheader('Host', self.host) - self.__http.putheader('Content-Type', 'application/x-thrift') - self.__http.putheader('Content-Length', str(len(data))) - self.__http.endheaders() - - # Write payload - self.__http.send(data) - - # Get reply to flush the request - self.code, self.message, self.headers = self.__http.getreply() diff --git a/thirdparty/thrift/transport/TSocket.py b/thirdparty/thrift/transport/TSocket.py deleted file mode 100644 index 87119612ff..0000000000 --- a/thirdparty/thrift/transport/TSocket.py +++ /dev/null @@ -1,149 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from TTransport import * -import os -import errno -import socket - -class TSocketBase(TTransportBase): - def _resolveAddr(self): - if self._unix_socket is not None: - return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None, self._unix_socket)] - else: - return socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE | socket.AI_ADDRCONFIG) - - def close(self): - if self.handle: - self.handle.close() - self.handle = None - -class TSocket(TSocketBase): - """Socket implementation of TTransport base.""" - - def __init__(self, host='localhost', port=9090, unix_socket=None): - """Initialize a TSocket - - @param host(str) The host to connect to. - @param port(int) The (TCP) port to connect to. - @param unix_socket(str) The filename of a unix socket to connect to. - (host and port will be ignored.) - """ - - self.host = host - self.port = port - self.handle = None - self._unix_socket = unix_socket - self._timeout = None - - def setHandle(self, h): - self.handle = h - - def isOpen(self): - return self.handle != None - - def setTimeout(self, ms): - if ms is None: - self._timeout = None - else: - self._timeout = ms/1000.0 - - if (self.handle != None): - self.handle.settimeout(self._timeout) - - def open(self): - try: - res0 = self._resolveAddr() - for res in res0: - self.handle = socket.socket(res[0], res[1]) - self.handle.settimeout(self._timeout) - try: - self.handle.connect(res[4]) - except socket.error, e: - if res is not res0[-1]: - continue - else: - raise e - break - except socket.error, e: - if self._unix_socket: - message = 'Could not connect to socket %s' % self._unix_socket - else: - message = 'Could not connect to %s:%d' % (self.host, self.port) - raise TTransportException(type=TTransportException.NOT_OPEN, message=message) - - def read(self, sz): - buff = self.handle.recv(sz) - if len(buff) == 0: - raise TTransportException(type=TTransportException.END_OF_FILE, message='TSocket read 0 bytes') - return buff - - def write(self, buff): - if not self.handle: - raise TTransportException(type=TTransportException.NOT_OPEN, message='Transport not open') - sent = 0 - have = len(buff) - while sent < have: - plus = self.handle.send(buff) - if plus == 0: - raise TTransportException(type=TTransportException.END_OF_FILE, message='TSocket sent 0 bytes') - sent += plus - buff = buff[plus:] - - def flush(self): - pass - -class TServerSocket(TSocketBase, TServerTransportBase): - """Socket implementation of TServerTransport base.""" - - def __init__(self, port=9090, unix_socket=None): - self.host = None - self.port = port - self._unix_socket = unix_socket - self.handle = None - - def listen(self): - res0 = self._resolveAddr() - for res in res0: - if res[0] is socket.AF_INET6 or res is res0[-1]: - break - - # We need remove the old unix socket if the file exists and - # nobody is listening on it. - if self._unix_socket: - tmp = socket.socket(res[0], res[1]) - try: - tmp.connect(res[4]) - except socket.error, err: - eno, message = err.args - if eno == errno.ECONNREFUSED: - os.unlink(res[4]) - - self.handle = socket.socket(res[0], res[1]) - self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - if hasattr(self.handle, 'set_timeout'): - self.handle.set_timeout(None) - self.handle.bind(res[4]) - self.handle.listen(128) - - def accept(self): - client, addr = self.handle.accept() - result = TSocket() - result.setHandle(client) - return result diff --git a/thirdparty/thrift/transport/TTransport.py b/thirdparty/thrift/transport/TTransport.py deleted file mode 100644 index 9858bbe210..0000000000 --- a/thirdparty/thrift/transport/TTransport.py +++ /dev/null @@ -1,326 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from cStringIO import StringIO -from struct import pack,unpack -from thrift.Thrift import TException - -class TTransportException(TException): - - """Custom Transport Exception class""" - - UNKNOWN = 0 - NOT_OPEN = 1 - ALREADY_OPEN = 2 - TIMED_OUT = 3 - END_OF_FILE = 4 - - def __init__(self, type=UNKNOWN, message=None): - TException.__init__(self, message) - self.type = type - -class TTransportBase: - - """Base class for Thrift transport layer.""" - - def isOpen(self): - pass - - def open(self): - pass - - def close(self): - pass - - def read(self, sz): - pass - - def readAll(self, sz): - buff = '' - have = 0 - while (have < sz): - chunk = self.read(sz-have) - have += len(chunk) - buff += chunk - - if len(chunk) == 0: - raise EOFError() - - return buff - - def write(self, buf): - pass - - def flush(self): - pass - -# This class should be thought of as an interface. -class CReadableTransport: - """base class for transports that are readable from C""" - - # TODO(dreiss): Think about changing this interface to allow us to use - # a (Python, not c) StringIO instead, because it allows - # you to write after reading. - - # NOTE: This is a classic class, so properties will NOT work - # correctly for setting. - @property - def cstringio_buf(self): - """A cStringIO buffer that contains the current chunk we are reading.""" - pass - - def cstringio_refill(self, partialread, reqlen): - """Refills cstringio_buf. - - Returns the currently used buffer (which can but need not be the same as - the old cstringio_buf). partialread is what the C code has read from the - buffer, and should be inserted into the buffer before any more reads. The - return value must be a new, not borrowed reference. Something along the - lines of self._buf should be fine. - - If reqlen bytes can't be read, throw EOFError. - """ - pass - -class TServerTransportBase: - - """Base class for Thrift server transports.""" - - def listen(self): - pass - - def accept(self): - pass - - def close(self): - pass - -class TTransportFactoryBase: - - """Base class for a Transport Factory""" - - def getTransport(self, trans): - return trans - -class TBufferedTransportFactory: - - """Factory transport that builds buffered transports""" - - def getTransport(self, trans): - buffered = TBufferedTransport(trans) - return buffered - - -class TBufferedTransport(TTransportBase,CReadableTransport): - - """Class that wraps another transport and buffers its I/O.""" - - DEFAULT_BUFFER = 4096 - - def __init__(self, trans): - self.__trans = trans - self.__wbuf = StringIO() - self.__rbuf = StringIO("") - - def isOpen(self): - return self.__trans.isOpen() - - def open(self): - return self.__trans.open() - - def close(self): - return self.__trans.close() - - def read(self, sz): - ret = self.__rbuf.read(sz) - if len(ret) != 0: - return ret - - self.__rbuf = StringIO(self.__trans.read(max(sz, self.DEFAULT_BUFFER))) - return self.__rbuf.read(sz) - - def write(self, buf): - self.__wbuf.write(buf) - - def flush(self): - out = self.__wbuf.getvalue() - # reset wbuf before write/flush to preserve state on underlying failure - self.__wbuf = StringIO() - self.__trans.write(out) - self.__trans.flush() - - # Implement the CReadableTransport interface. - @property - def cstringio_buf(self): - return self.__rbuf - - def cstringio_refill(self, partialread, reqlen): - retstring = partialread - if reqlen < self.DEFAULT_BUFFER: - # try to make a read of as much as we can. - retstring += self.__trans.read(self.DEFAULT_BUFFER) - - # but make sure we do read reqlen bytes. - if len(retstring) < reqlen: - retstring += self.__trans.readAll(reqlen - len(retstring)) - - self.__rbuf = StringIO(retstring) - return self.__rbuf - -class TMemoryBuffer(TTransportBase, CReadableTransport): - """Wraps a cStringIO object as a TTransport. - - NOTE: Unlike the C++ version of this class, you cannot write to it - then immediately read from it. If you want to read from a - TMemoryBuffer, you must either pass a string to the constructor. - TODO(dreiss): Make this work like the C++ version. - """ - - def __init__(self, value=None): - """value -- a value to read from for stringio - - If value is set, this will be a transport for reading, - otherwise, it is for writing""" - if value is not None: - self._buffer = StringIO(value) - else: - self._buffer = StringIO() - - def isOpen(self): - return not self._buffer.closed - - def open(self): - pass - - def close(self): - self._buffer.close() - - def read(self, sz): - return self._buffer.read(sz) - - def write(self, buf): - self._buffer.write(buf) - - def flush(self): - pass - - def getvalue(self): - return self._buffer.getvalue() - - # Implement the CReadableTransport interface. - @property - def cstringio_buf(self): - return self._buffer - - def cstringio_refill(self, partialread, reqlen): - # only one shot at reading... - raise EOFError() - -class TFramedTransportFactory: - - """Factory transport that builds framed transports""" - - def getTransport(self, trans): - framed = TFramedTransport(trans) - return framed - - -class TFramedTransport(TTransportBase, CReadableTransport): - - """Class that wraps another transport and frames its I/O when writing.""" - - def __init__(self, trans,): - self.__trans = trans - self.__rbuf = StringIO() - self.__wbuf = StringIO() - - def isOpen(self): - return self.__trans.isOpen() - - def open(self): - return self.__trans.open() - - def close(self): - return self.__trans.close() - - def read(self, sz): - ret = self.__rbuf.read(sz) - if len(ret) != 0: - return ret - - self.readFrame() - return self.__rbuf.read(sz) - - def readFrame(self): - buff = self.__trans.readAll(4) - sz, = unpack('!i', buff) - self.__rbuf = StringIO(self.__trans.readAll(sz)) - - def write(self, buf): - self.__wbuf.write(buf) - - def flush(self): - wout = self.__wbuf.getvalue() - wsz = len(wout) - # reset wbuf before write/flush to preserve state on underlying failure - self.__wbuf = StringIO() - # N.B.: Doing this string concatenation is WAY cheaper than making - # two separate calls to the underlying socket object. Socket writes in - # Python turn out to be REALLY expensive, but it seems to do a pretty - # good job of managing string buffer operations without excessive copies - buf = pack("!i", wsz) + wout - self.__trans.write(buf) - self.__trans.flush() - - # Implement the CReadableTransport interface. - @property - def cstringio_buf(self): - return self.__rbuf - - def cstringio_refill(self, prefix, reqlen): - # self.__rbuf will already be empty here because fastbinary doesn't - # ask for a refill until the previous buffer is empty. Therefore, - # we can start reading new frames immediately. - while len(prefix) < reqlen: - self.readFrame() - prefix += self.__rbuf.getvalue() - self.__rbuf = StringIO(prefix) - return self.__rbuf - - -class TFileObjectTransport(TTransportBase): - """Wraps a file-like object to make it work as a Thrift transport.""" - - def __init__(self, fileobj): - self.fileobj = fileobj - - def isOpen(self): - return True - - def close(self): - self.fileobj.close() - - def read(self, sz): - return self.fileobj.read(sz) - - def write(self, buf): - self.fileobj.write(buf) - - def flush(self): - self.fileobj.flush() diff --git a/thirdparty/thrift/transport/TTwisted.py b/thirdparty/thrift/transport/TTwisted.py deleted file mode 100644 index a1ba1502d7..0000000000 --- a/thirdparty/thrift/transport/TTwisted.py +++ /dev/null @@ -1,181 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -from zope.interface import implements, Interface, Attribute -from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \ - connectionDone -from twisted.internet import defer -from twisted.protocols import basic -from twisted.python import log - - -from thrift.transport import TTransport -from cStringIO import StringIO - - -class TMessageSenderTransport(TTransport.TTransportBase): - - def __init__(self): - self.__wbuf = StringIO() - - def write(self, buf): - self.__wbuf.write(buf) - - def flush(self): - msg = self.__wbuf.getvalue() - self.__wbuf = StringIO() - self.sendMessage(msg) - - def sendMessage(self, message): - raise NotImplementedError - - -class TCallbackTransport(TMessageSenderTransport): - - def __init__(self, func): - TMessageSenderTransport.__init__(self) - self.func = func - - def sendMessage(self, message): - self.func(message) - - -class ThriftClientProtocol(basic.Int32StringReceiver): - - MAX_LENGTH = 2 ** 31 - 1 - - def __init__(self, client_class, iprot_factory, oprot_factory=None): - self._client_class = client_class - self._iprot_factory = iprot_factory - if oprot_factory is None: - self._oprot_factory = iprot_factory - else: - self._oprot_factory = oprot_factory - - self.recv_map = {} - self.started = defer.Deferred() - - def dispatch(self, msg): - self.sendString(msg) - - def connectionMade(self): - tmo = TCallbackTransport(self.dispatch) - self.client = self._client_class(tmo, self._oprot_factory) - self.started.callback(self.client) - - def connectionLost(self, reason=connectionDone): - for k,v in self.client._reqs.iteritems(): - tex = TTransport.TTransportException( - type=TTransport.TTransportException.END_OF_FILE, - message='Connection closed') - v.errback(tex) - - def stringReceived(self, frame): - tr = TTransport.TMemoryBuffer(frame) - iprot = self._iprot_factory.getProtocol(tr) - (fname, mtype, rseqid) = iprot.readMessageBegin() - - try: - method = self.recv_map[fname] - except KeyError: - method = getattr(self.client, 'recv_' + fname) - self.recv_map[fname] = method - - method(iprot, mtype, rseqid) - - -class ThriftServerProtocol(basic.Int32StringReceiver): - - MAX_LENGTH = 2 ** 31 - 1 - - def dispatch(self, msg): - self.sendString(msg) - - def processError(self, error): - self.transport.loseConnection() - - def processOk(self, _, tmo): - msg = tmo.getvalue() - - if len(msg) > 0: - self.dispatch(msg) - - def stringReceived(self, frame): - tmi = TTransport.TMemoryBuffer(frame) - tmo = TTransport.TMemoryBuffer() - - iprot = self.factory.iprot_factory.getProtocol(tmi) - oprot = self.factory.oprot_factory.getProtocol(tmo) - - d = self.factory.processor.process(iprot, oprot) - d.addCallbacks(self.processOk, self.processError, - callbackArgs=(tmo,)) - - -class IThriftServerFactory(Interface): - - processor = Attribute("Thrift processor") - - iprot_factory = Attribute("Input protocol factory") - - oprot_factory = Attribute("Output protocol factory") - - -class IThriftClientFactory(Interface): - - client_class = Attribute("Thrift client class") - - iprot_factory = Attribute("Input protocol factory") - - oprot_factory = Attribute("Output protocol factory") - - -class ThriftServerFactory(ServerFactory): - - implements(IThriftServerFactory) - - protocol = ThriftServerProtocol - - def __init__(self, processor, iprot_factory, oprot_factory=None): - self.processor = processor - self.iprot_factory = iprot_factory - if oprot_factory is None: - self.oprot_factory = iprot_factory - else: - self.oprot_factory = oprot_factory - - -class ThriftClientFactory(ClientFactory): - - implements(IThriftClientFactory) - - protocol = ThriftClientProtocol - - def __init__(self, client_class, iprot_factory, oprot_factory=None): - self.client_class = client_class - self.iprot_factory = iprot_factory - if oprot_factory is None: - self.oprot_factory = iprot_factory - else: - self.oprot_factory = oprot_factory - - def buildProtocol(self, addr): - p = self.protocol(self.client_class, self.iprot_factory, - self.oprot_factory) - p.factory = self - return p diff --git a/thirdparty/thrift/transport/__init__.py b/thirdparty/thrift/transport/__init__.py deleted file mode 100644 index 02c6048a96..0000000000 --- a/thirdparty/thrift/transport/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -__all__ = ['TTransport', 'TSocket', 'THttpClient'] diff --git a/thirdparty/web/__init__.py b/thirdparty/web/__init__.py deleted file mode 100644 index 337d9bf1be..0000000000 --- a/thirdparty/web/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -"""web.py: makes web apps (http://webpy.org)""" - -from __future__ import generators - -__version__ = "0.34" -__author__ = [ - "Aaron Swartz ", - "Anand Chitipothu " -] -__license__ = "public domain" -__contributors__ = "see http://webpy.org/changes" - -import utils, db, net, wsgi, http, webapi, httpserver, debugerror -import template, form - -import session - -from utils import * -from db import * -from net import * -from wsgi import * -from http import * -from webapi import * -from httpserver import * -from debugerror import * -from application import * -from browser import * -import test -try: - import webopenid as openid -except ImportError: - pass # requires openid module - diff --git a/thirdparty/web/application.py b/thirdparty/web/application.py deleted file mode 100755 index 990f98329b..0000000000 --- a/thirdparty/web/application.py +++ /dev/null @@ -1,670 +0,0 @@ -#!/usr/bin/python -""" -Web application -(from web.py) -""" -import webapi as web -import webapi, wsgi, utils -import debugerror -from utils import lstrips, safeunicode -import sys - -import urllib -import traceback -import itertools -import os -import re -import types -from exceptions import SystemExit - -try: - import wsgiref.handlers -except ImportError: - pass # don't break people with old Pythons - -__all__ = [ - "application", "auto_application", - "subdir_application", "subdomain_application", - "loadhook", "unloadhook", - "autodelegate" -] - -class application: - """ - Application to delegate requests based on path. - - >>> urls = ("/hello", "hello") - >>> app = application(urls, globals()) - >>> class hello: - ... def GET(self): return "hello" - >>> - >>> app.request("/hello").data - 'hello' - """ - def __init__(self, mapping=(), fvars={}, autoreload=None): - if autoreload is None: - autoreload = web.config.get('debug', False) - self.mapping = mapping - self.fvars = fvars - self.processors = [] - - self.add_processor(loadhook(self._load)) - self.add_processor(unloadhook(self._unload)) - - if autoreload: - def main_module_name(): - mod = sys.modules['__main__'] - file = getattr(mod, '__file__', None) # make sure this works even from python interpreter - return file and os.path.splitext(os.path.basename(file))[0] - - def modname(fvars): - """find name of the module name from fvars.""" - file, name = fvars.get('__file__'), fvars.get('__name__') - if file is None or name is None: - return None - - if name == '__main__': - # Since the __main__ module can't be reloaded, the module has - # to be imported using its file name. - name = main_module_name() - return name - - mapping_name = utils.dictfind(fvars, mapping) - module_name = modname(fvars) - - def reload_mapping(): - """loadhook to reload mapping and fvars.""" - mod = __import__(module_name) - mapping = getattr(mod, mapping_name, None) - if mapping: - self.fvars = mod.__dict__ - self.mapping = mapping - - self.add_processor(loadhook(Reloader())) - if mapping_name and module_name: - self.add_processor(loadhook(reload_mapping)) - - # load __main__ module usings its filename, so that it can be reloaded. - if main_module_name() and '__main__' in sys.argv: - try: - __import__(main_module_name()) - except ImportError: - pass - - def _load(self): - web.ctx.app_stack.append(self) - - def _unload(self): - web.ctx.app_stack = web.ctx.app_stack[:-1] - - if web.ctx.app_stack: - # this is a sub-application, revert ctx to earlier state. - oldctx = web.ctx.get('_oldctx') - if oldctx: - web.ctx.home = oldctx.home - web.ctx.homepath = oldctx.homepath - web.ctx.path = oldctx.path - web.ctx.fullpath = oldctx.fullpath - - def _cleanup(self): - #@@@ - # Since the CherryPy Webserver uses thread pool, the thread-local state is never cleared. - # This interferes with the other requests. - # clearing the thread-local storage to avoid that. - # see utils.ThreadedDict for details - import threading - t = threading.currentThread() - if hasattr(t, '_d'): - del t._d - - def add_mapping(self, pattern, classname): - self.mapping += (pattern, classname) - - def add_processor(self, processor): - """ - Adds a processor to the application. - - >>> urls = ("/(.*)", "echo") - >>> app = application(urls, globals()) - >>> class echo: - ... def GET(self, name): return name - ... - >>> - >>> def hello(handler): return "hello, " + handler() - ... - >>> app.add_processor(hello) - >>> app.request("/web.py").data - 'hello, web.py' - """ - self.processors.append(processor) - - def request(self, localpart='/', method='GET', data=None, - host="0.0.0.0:8080", headers=None, https=False, **kw): - """Makes request to this application for the specified path and method. - Response will be a storage object with data, status and headers. - - >>> urls = ("/hello", "hello") - >>> app = application(urls, globals()) - >>> class hello: - ... def GET(self): - ... web.header('Content-Type', 'text/plain') - ... return "hello" - ... - >>> response = app.request("/hello") - >>> response.data - 'hello' - >>> response.status - '200 OK' - >>> response.headers['Content-Type'] - 'text/plain' - - To use https, use https=True. - - >>> urls = ("/redirect", "redirect") - >>> app = application(urls, globals()) - >>> class redirect: - ... def GET(self): raise web.seeother("/foo") - ... - >>> response = app.request("/redirect") - >>> response.headers['Location'] - 'http://0.0.0.0:8080/foo' - >>> response = app.request("/redirect", https=True) - >>> response.headers['Location'] - 'https://0.0.0.0:8080/foo' - - The headers argument specifies HTTP headers as a mapping object - such as a dict. - - >>> urls = ('/ua', 'uaprinter') - >>> class uaprinter: - ... def GET(self): - ... return 'your user-agent is ' + web.ctx.env['HTTP_USER_AGENT'] - ... - >>> app = application(urls, globals()) - >>> app.request('/ua', headers = { - ... 'User-Agent': 'a small jumping bean/1.0 (compatible)' - ... }).data - 'your user-agent is a small jumping bean/1.0 (compatible)' - - """ - path, maybe_query = urllib.splitquery(localpart) - query = maybe_query or "" - - if 'env' in kw: - env = kw['env'] - else: - env = {} - env = dict(env, HTTP_HOST=host, REQUEST_METHOD=method, PATH_INFO=path, QUERY_STRING=query, HTTPS=str(https)) - headers = headers or {} - - for k, v in headers.items(): - env['HTTP_' + k.upper().replace('-', '_')] = v - - if 'HTTP_CONTENT_LENGTH' in env: - env['CONTENT_LENGTH'] = env.pop('HTTP_CONTENT_LENGTH') - - if 'HTTP_CONTENT_TYPE' in env: - env['CONTENT_TYPE'] = env.pop('HTTP_CONTENT_TYPE') - - if method in ["POST", "PUT"]: - data = data or '' - import StringIO - if isinstance(data, dict): - q = urllib.urlencode(data) - else: - q = data - env['wsgi.input'] = StringIO.StringIO(q) - if not env.get('CONTENT_TYPE', '').lower().startswith('multipart/') and 'CONTENT_LENGTH' not in env: - env['CONTENT_LENGTH'] = len(q) - response = web.storage() - def start_response(status, headers): - response.status = status - response.headers = dict(headers) - response.header_items = headers - response.data = "".join(self.wsgifunc()(env, start_response)) - return response - - def browser(self): - import browser - return browser.AppBrowser(self) - - def handle(self): - fn, args = self._match(self.mapping, web.ctx.path) - return self._delegate(fn, self.fvars, args) - - def handle_with_processors(self): - def process(processors): - try: - if processors: - p, processors = processors[0], processors[1:] - return p(lambda: process(processors)) - else: - return self.handle() - except web.HTTPError: - raise - except (KeyboardInterrupt, SystemExit): - raise - except: - print >> web.debug, traceback.format_exc() - raise self.internalerror() - - # processors must be applied in the resvere order. (??) - return process(self.processors) - - def wsgifunc(self, *middleware): - """Returns a WSGI-compatible function for this application.""" - def peep(iterator): - """Peeps into an iterator by doing an iteration - and returns an equivalent iterator. - """ - # wsgi requires the headers first - # so we need to do an iteration - # and save the result for later - try: - firstchunk = iterator.next() - except StopIteration: - firstchunk = '' - - return itertools.chain([firstchunk], iterator) - - def is_generator(x): return x and hasattr(x, 'next') - - def wsgi(env, start_resp): - # clear threadlocal to avoid inteference of previous requests - self._cleanup() - - self.load(env) - try: - # allow uppercase methods only - if web.ctx.method.upper() != web.ctx.method: - raise web.nomethod() - - result = self.handle_with_processors() - if is_generator(result): - result = peep(result) - else: - result = [result] - except web.HTTPError, e: - result = [e.data] - - result = web.utf8(iter(result)) - - status, headers = web.ctx.status, web.ctx.headers - start_resp(status, headers) - - def cleanup(): - self._cleanup() - yield '' # force this function to be a generator - - return itertools.chain(result, cleanup()) - - for m in middleware: - wsgi = m(wsgi) - - return wsgi - - def run(self, *middleware): - """ - Starts handling requests. If called in a CGI or FastCGI context, it will follow - that protocol. If called from the command line, it will start an HTTP - server on the port named in the first command line argument, or, if there - is no argument, on port 8080. - - `middleware` is a list of WSGI middleware which is applied to the resulting WSGI - function. - """ - return wsgi.runwsgi(self.wsgifunc(*middleware)) - - def cgirun(self, *middleware): - """ - Return a CGI handler. This is mostly useful with Google App Engine. - There you can just do: - - main = app.cgirun() - """ - wsgiapp = self.wsgifunc(*middleware) - - try: - from google.appengine.ext.webapp.util import run_wsgi_app - return run_wsgi_app(wsgiapp) - except ImportError: - # we're not running from within Google App Engine - return wsgiref.handlers.CGIHandler().run(wsgiapp) - - def load(self, env): - """Initializes ctx using env.""" - ctx = web.ctx - ctx.clear() - ctx.status = '200 OK' - ctx.headers = [] - ctx.output = '' - ctx.environ = ctx.env = env - ctx.host = env.get('HTTP_HOST') - - if env.get('wsgi.url_scheme') in ['http', 'https']: - ctx.protocol = env['wsgi.url_scheme'] - elif env.get('HTTPS', '').lower() in ['on', 'true', '1']: - ctx.protocol = 'https' - else: - ctx.protocol = 'http' - ctx.homedomain = ctx.protocol + '://' + env.get('HTTP_HOST', '[unknown]') - ctx.homepath = os.environ.get('REAL_SCRIPT_NAME', env.get('SCRIPT_NAME', '')) - ctx.home = ctx.homedomain + ctx.homepath - #@@ home is changed when the request is handled to a sub-application. - #@@ but the real home is required for doing absolute redirects. - ctx.realhome = ctx.home - ctx.ip = env.get('REMOTE_ADDR') - ctx.method = env.get('REQUEST_METHOD') - ctx.path = env.get('PATH_INFO') - # http://trac.lighttpd.net/trac/ticket/406 requires: - if env.get('SERVER_SOFTWARE', '').startswith('lighttpd/'): - ctx.path = lstrips(env.get('REQUEST_URI').split('?')[0], ctx.homepath) - # Apache and CherryPy webservers unquote the url but lighttpd doesn't. - # unquote explicitly for lighttpd to make ctx.path uniform across all servers. - ctx.path = urllib.unquote(ctx.path) - - if env.get('QUERY_STRING'): - ctx.query = '?' + env.get('QUERY_STRING', '') - else: - ctx.query = '' - - ctx.fullpath = ctx.path + ctx.query - - for k, v in ctx.iteritems(): - if isinstance(v, str): - ctx[k] = safeunicode(v) - - # status must always be str - ctx.status = '200 OK' - - ctx.app_stack = [] - - def _delegate(self, f, fvars, args=[]): - def handle_class(cls): - meth = web.ctx.method - if meth == 'HEAD' and not hasattr(cls, meth): - meth = 'GET' - if not hasattr(cls, meth): - raise web.nomethod(cls) - tocall = getattr(cls(), meth) - return tocall(*args) - - def is_class(o): return isinstance(o, (types.ClassType, type)) - - if f is None: - raise web.notfound() - elif isinstance(f, application): - return f.handle_with_processors() - elif is_class(f): - return handle_class(f) - elif isinstance(f, basestring): - if f.startswith('redirect '): - url = f.split(' ', 1)[1] - if web.ctx.method == "GET": - x = web.ctx.env.get('QUERY_STRING', '') - if x: - url += '?' + x - raise web.redirect(url) - elif '.' in f: - x = f.split('.') - mod, cls = '.'.join(x[:-1]), x[-1] - mod = __import__(mod, globals(), locals(), [""]) - cls = getattr(mod, cls) - else: - cls = fvars[f] - return handle_class(cls) - elif hasattr(f, '__call__'): - return f() - else: - return web.notfound() - - def _match(self, mapping, value): - for pat, what in utils.group(mapping, 2): - if isinstance(what, application): - if value.startswith(pat): - f = lambda: self._delegate_sub_application(pat, what) - return f, None - else: - continue - elif isinstance(what, basestring): - what, result = utils.re_subm('^' + pat + '$', what, value) - else: - result = utils.re_compile('^' + pat + '$').match(value) - - if result: # it's a match - return what, [x for x in result.groups()] - return None, None - - def _delegate_sub_application(self, dir, app): - """Deletes request to sub application `app` rooted at the directory `dir`. - The home, homepath, path and fullpath values in web.ctx are updated to mimic request - to the subapp and are restored after it is handled. - - @@Any issues with when used with yield? - """ - web.ctx._oldctx = web.storage(web.ctx) - web.ctx.home += dir - web.ctx.homepath += dir - web.ctx.path = web.ctx.path[len(dir):] - web.ctx.fullpath = web.ctx.fullpath[len(dir):] - return app.handle_with_processors() - - def get_parent_app(self): - if self in web.ctx.app_stack: - index = web.ctx.app_stack.index(self) - if index > 0: - return web.ctx.app_stack[index-1] - - def notfound(self): - """Returns HTTPError with '404 not found' message""" - parent = self.get_parent_app() - if parent: - return parent.notfound() - else: - return web._NotFound() - - def internalerror(self): - """Returns HTTPError with '500 internal error' message""" - parent = self.get_parent_app() - if parent: - return parent.internalerror() - elif web.config.get('debug'): - import debugerror - return debugerror.debugerror() - else: - return web._InternalError() - -class auto_application(application): - """Application similar to `application` but urls are constructed - automatiacally using metaclass. - - >>> app = auto_application() - >>> class hello(app.page): - ... def GET(self): return "hello, world" - ... - >>> class foo(app.page): - ... path = '/foo/.*' - ... def GET(self): return "foo" - >>> app.request("/hello").data - 'hello, world' - >>> app.request('/foo/bar').data - 'foo' - """ - def __init__(self): - application.__init__(self) - - class metapage(type): - def __init__(klass, name, bases, attrs): - type.__init__(klass, name, bases, attrs) - path = attrs.get('path', '/' + name) - - # path can be specified as None to ignore that class - # typically required to create a abstract base class. - if path is not None: - self.add_mapping(path, klass) - - class page: - path = None - __metaclass__ = metapage - - self.page = page - -# The application class already has the required functionality of subdir_application -subdir_application = application - -class subdomain_application(application): - """ - Application to delegate requests based on the host. - - >>> urls = ("/hello", "hello") - >>> app = application(urls, globals()) - >>> class hello: - ... def GET(self): return "hello" - >>> - >>> mapping = (r"hello\.example\.com", app) - >>> app2 = subdomain_application(mapping) - >>> app2.request("/hello", host="hello.example.com").data - 'hello' - >>> response = app2.request("/hello", host="something.example.com") - >>> response.status - '404 Not Found' - >>> response.data - 'not found' - """ - def handle(self): - host = web.ctx.host.split(':')[0] #strip port - fn, args = self._match(self.mapping, host) - return self._delegate(fn, self.fvars, args) - - def _match(self, mapping, value): - for pat, what in utils.group(mapping, 2): - if isinstance(what, basestring): - what, result = utils.re_subm('^' + pat + '$', what, value) - else: - result = utils.re_compile('^' + pat + '$').match(value) - - if result: # it's a match - return what, [x for x in result.groups()] - return None, None - -def loadhook(h): - """ - Converts a load hook into an application processor. - - >>> app = auto_application() - >>> def f(): "something done before handling request" - ... - >>> app.add_processor(loadhook(f)) - """ - def processor(handler): - h() - return handler() - - return processor - -def unloadhook(h): - """ - Converts an unload hook into an application processor. - - >>> app = auto_application() - >>> def f(): "something done after handling request" - ... - >>> app.add_processor(unloadhook(f)) - """ - def processor(handler): - try: - result = handler() - is_generator = result and hasattr(result, 'next') - except: - # run the hook even when handler raises some exception - h() - raise - - if is_generator: - return wrap(result) - else: - h() - return result - - def wrap(result): - def next(): - try: - return result.next() - except: - # call the hook at the and of iterator - h() - raise - - result = iter(result) - while True: - yield next() - - return processor - -def autodelegate(prefix=''): - """ - Returns a method that takes one argument and calls the method named prefix+arg, - calling `notfound()` if there isn't one. Example: - - urls = ('/prefs/(.*)', 'prefs') - - class prefs: - GET = autodelegate('GET_') - def GET_password(self): pass - def GET_privacy(self): pass - - `GET_password` would get called for `/prefs/password` while `GET_privacy` for - `GET_privacy` gets called for `/prefs/privacy`. - - If a user visits `/prefs/password/change` then `GET_password(self, '/change')` - is called. - """ - def internal(self, arg): - if '/' in arg: - first, rest = arg.split('/', 1) - func = prefix + first - args = ['/' + rest] - else: - func = prefix + arg - args = [] - - if hasattr(self, func): - try: - return getattr(self, func)(*args) - except TypeError: - raise web.notfound() - else: - raise web.notfound() - return internal - -class Reloader: - """Checks to see if any loaded modules have changed on disk and, - if so, reloads them. - """ - def __init__(self): - self.mtimes = {} - - def __call__(self): - for mod in sys.modules.values(): - self.check(mod) - - def check(self, mod): - try: - mtime = os.stat(mod.__file__).st_mtime - except (AttributeError, OSError, IOError): - return - if mod.__file__.endswith('.pyc') and os.path.exists(mod.__file__[:-1]): - mtime = max(os.stat(mod.__file__[:-1]).st_mtime, mtime) - - if mod not in self.mtimes: - self.mtimes[mod] = mtime - elif self.mtimes[mod] < mtime: - try: - reload(mod) - self.mtimes[mod] = mtime - except ImportError: - pass - -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/thirdparty/web/browser.py b/thirdparty/web/browser.py deleted file mode 100644 index 084a8c4815..0000000000 --- a/thirdparty/web/browser.py +++ /dev/null @@ -1,236 +0,0 @@ -"""Browser to test web applications. -(from web.py) -""" -from utils import re_compile -from net import htmlunquote - -import httplib, urllib, urllib2 -import copy -from StringIO import StringIO - -DEBUG = False - -__all__ = [ - "BrowserError", - "Browser", "AppBrowser", - "AppHandler" -] - -class BrowserError(Exception): - pass - -class Browser: - def __init__(self): - import cookielib - self.cookiejar = cookielib.CookieJar() - self._cookie_processor = urllib2.HTTPCookieProcessor(self.cookiejar) - self.form = None - - self.url = "http://0.0.0.0:8080/" - self.path = "/" - - self.status = None - self.data = None - self._response = None - self._forms = None - - def reset(self): - """Clears all cookies and history.""" - self.cookiejar.clear() - - def build_opener(self): - """Builds the opener using urllib2.build_opener. - Subclasses can override this function to prodive custom openers. - """ - return urllib2.build_opener() - - def do_request(self, req): - if DEBUG: - print 'requesting', req.get_method(), req.get_full_url() - opener = self.build_opener() - opener.add_handler(self._cookie_processor) - try: - self._response = opener.open(req) - except urllib2.HTTPError, e: - self._response = e - - self.url = self._response.geturl() - self.path = urllib2.Request(self.url).get_selector() - self.data = self._response.read() - self.status = self._response.code - self._forms = None - self.form = None - return self.get_response() - - def open(self, url, data=None, headers={}): - """Opens the specified url.""" - url = urllib.basejoin(self.url, url) - req = urllib2.Request(url, data, headers) - return self.do_request(req) - - def show(self): - """Opens the current page in real web browser.""" - f = open('page.html', 'w') - f.write(self.data) - f.close() - - import webbrowser, os - url = 'file://' + os.path.abspath('page.html') - webbrowser.open(url) - - def get_response(self): - """Returns a copy of the current response.""" - return urllib.addinfourl(StringIO(self.data), self._response.info(), self._response.geturl()) - - def get_soup(self): - """Returns beautiful soup of the current document.""" - import BeautifulSoup - return BeautifulSoup.BeautifulSoup(self.data) - - def get_text(self, e=None): - """Returns content of e or the current document as plain text.""" - e = e or self.get_soup() - return ''.join([htmlunquote(c) for c in e.recursiveChildGenerator() if isinstance(c, unicode)]) - - def _get_links(self): - soup = self.get_soup() - return [a for a in soup.findAll(name='a')] - - def get_links(self, text=None, text_regex=None, url=None, url_regex=None, predicate=None): - """Returns all links in the document.""" - return self._filter_links(self._get_links(), - text=text, text_regex=text_regex, url=url, url_regex=url_regex, predicate=predicate) - - def follow_link(self, link=None, text=None, text_regex=None, url=None, url_regex=None, predicate=None): - if link is None: - links = self._filter_links(self.get_links(), - text=text, text_regex=text_regex, url=url, url_regex=url_regex, predicate=predicate) - link = links and links[0] - - if link: - return self.open(link['href']) - else: - raise BrowserError("No link found") - - def find_link(self, text=None, text_regex=None, url=None, url_regex=None, predicate=None): - links = self._filter_links(self.get_links(), - text=text, text_regex=text_regex, url=url, url_regex=url_regex, predicate=predicate) - return links and links[0] or None - - def _filter_links(self, links, - text=None, text_regex=None, - url=None, url_regex=None, - predicate=None): - predicates = [] - if text is not None: - predicates.append(lambda link: link.string == text) - if text_regex is not None: - predicates.append(lambda link: re_compile(text_regex).search(link.string or '')) - if url is not None: - predicates.append(lambda link: link.get('href') == url) - if url_regex is not None: - predicates.append(lambda link: re_compile(url_regex).search(link.get('href', ''))) - if predicate: - predicate.append(predicate) - - def f(link): - for p in predicates: - if not p(link): - return False - return True - - return [link for link in links if f(link)] - - def get_forms(self): - """Returns all forms in the current document. - The returned form objects implement the ClientForm.HTMLForm interface. - """ - if self._forms is None: - import ClientForm - self._forms = ClientForm.ParseResponse(self.get_response(), backwards_compat=False) - return self._forms - - def select_form(self, name=None, predicate=None, index=0): - """Selects the specified form.""" - forms = self.get_forms() - - if name is not None: - forms = [f for f in forms if f.name == name] - if predicate: - forms = [f for f in forms if predicate(f)] - - if forms: - self.form = forms[index] - return self.form - else: - raise BrowserError("No form selected.") - - def submit(self, **kw): - """submits the currently selected form.""" - if self.form is None: - raise BrowserError("No form selected.") - req = self.form.click(**kw) - return self.do_request(req) - - def __getitem__(self, key): - return self.form[key] - - def __setitem__(self, key, value): - self.form[key] = value - -class AppBrowser(Browser): - """Browser interface to test web.py apps. - - b = AppBrowser(app) - b.open('/') - b.follow_link(text='Login') - - b.select_form(name='login') - b['username'] = 'joe' - b['password'] = 'secret' - b.submit() - - assert b.path == '/' - assert 'Welcome joe' in b.get_text() - """ - def __init__(self, app): - Browser.__init__(self) - self.app = app - - def build_opener(self): - return urllib2.build_opener(AppHandler(self.app)) - -class AppHandler(urllib2.HTTPHandler): - """urllib2 handler to handle requests using web.py application.""" - handler_order = 100 - - def __init__(self, app): - self.app = app - - def http_open(self, req): - result = self.app.request( - localpart=req.get_selector(), - method=req.get_method(), - host=req.get_host(), - data=req.get_data(), - headers=dict(req.header_items()), - https=req.get_type() == "https" - ) - return self._make_response(result, req.get_full_url()) - - def https_open(self, req): - return self.http_open(req) - - try: - https_request = urllib2.HTTPHandler.do_request_ - except AttributeError: - # for python 2.3 - pass - - def _make_response(self, result, url): - data = "\r\n".join(["%s: %s" % (k, v) for k, v in result.header_items]) - headers = httplib.HTTPMessage(StringIO(data)) - response = urllib.addinfourl(StringIO(result.data), headers, url) - code, msg = result.status.split(None, 1) - response.code, response.msg = int(code), msg - return response diff --git a/thirdparty/web/contrib/__init__.py b/thirdparty/web/contrib/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/thirdparty/web/contrib/template.py b/thirdparty/web/contrib/template.py deleted file mode 100644 index b2480e3348..0000000000 --- a/thirdparty/web/contrib/template.py +++ /dev/null @@ -1,131 +0,0 @@ -""" -Interface to various templating engines. -""" -import os.path - -__all__ = [ - "render_cheetah", "render_genshi", "render_mako", - "cache", -] - -class render_cheetah: - """Rendering interface to Cheetah Templates. - - Example: - - render = render_cheetah('templates') - render.hello(name="cheetah") - """ - def __init__(self, path): - # give error if Chetah is not installed - from Cheetah.Template import Template - self.path = path - - def __getattr__(self, name): - from Cheetah.Template import Template - path = os.path.join(self.path, name + ".html") - - def template(**kw): - t = Template(file=path, searchList=[kw]) - return t.respond() - - return template - -class render_genshi: - """Rendering interface genshi templates. - Example: - - for xml/html templates. - - render = render_genshi(['templates/']) - render.hello(name='genshi') - - For text templates: - - render = render_genshi(['templates/'], type='text') - render.hello(name='genshi') - """ - - def __init__(self, *a, **kwargs): - from genshi.template import TemplateLoader - - self._type = kwargs.pop('type', None) - self._loader = TemplateLoader(*a, **kwargs) - - def __getattr__(self, name): - # Assuming all templates are html - path = name + ".html" - - if self._type == "text": - from genshi.template import TextTemplate - cls = TextTemplate - type = "text" - else: - cls = None - type = None - - t = self._loader.load(path, cls=cls) - def template(**kw): - stream = t.generate(**kw) - if type: - return stream.render(type) - else: - return stream.render() - return template - -class render_jinja: - """Rendering interface to Jinja2 Templates - - Example: - - render= render_jinja('templates') - render.hello(name='jinja2') - """ - def __init__(self, *a, **kwargs): - extensions = kwargs.pop('extensions', []) - globals = kwargs.pop('globals', {}) - - from jinja2 import Environment,FileSystemLoader - self._lookup = Environment(loader=FileSystemLoader(*a, **kwargs), extensions=extensions) - self._lookup.globals.update(globals) - - def __getattr__(self, name): - # Assuming all templates end with .html - path = name + '.html' - t = self._lookup.get_template(path) - return t.render - -class render_mako: - """Rendering interface to Mako Templates. - - Example: - - render = render_mako(directories=['templates']) - render.hello(name="mako") - """ - def __init__(self, *a, **kwargs): - from mako.lookup import TemplateLookup - self._lookup = TemplateLookup(*a, **kwargs) - - def __getattr__(self, name): - # Assuming all templates are html - path = name + ".html" - t = self._lookup.get_template(path) - return t.render - -class cache: - """Cache for any rendering interface. - - Example: - - render = cache(render_cheetah("templates/")) - render.hello(name='cache') - """ - def __init__(self, render): - self._render = render - self._cache = {} - - def __getattr__(self, name): - if name not in self._cache: - self._cache[name] = getattr(self._render, name) - return self._cache[name] diff --git a/thirdparty/web/db.py b/thirdparty/web/db.py deleted file mode 100644 index 13284e8d9b..0000000000 --- a/thirdparty/web/db.py +++ /dev/null @@ -1,1172 +0,0 @@ -""" -Database API -(part of web.py) -""" - -__all__ = [ - "UnknownParamstyle", "UnknownDB", "TransactionError", - "sqllist", "sqlors", "reparam", "sqlquote", - "SQLQuery", "SQLParam", "sqlparam", - "SQLLiteral", "sqlliteral", - "database", 'DB', -] - -import time -try: - import datetime -except ImportError: - datetime = None - -try: set -except NameError: - from sets import Set as set - -from utils import threadeddict, storage, iters, iterbetter, safestr, safeunicode - -try: - # db module can work independent of web.py - from webapi import debug, config -except: - import sys - debug = sys.stderr - config = storage() - -class UnknownDB(Exception): - """raised for unsupported dbms""" - pass - -class _ItplError(ValueError): - def __init__(self, text, pos): - ValueError.__init__(self) - self.text = text - self.pos = pos - def __str__(self): - return "unfinished expression in %s at char %d" % ( - repr(self.text), self.pos) - -class TransactionError(Exception): pass - -class UnknownParamstyle(Exception): - """ - raised for unsupported db paramstyles - - (currently supported: qmark, numeric, format, pyformat) - """ - pass - -class SQLParam: - """ - Parameter in SQLQuery. - - >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam("joe")]) - >>> q - - >>> q.query() - 'SELECT * FROM test WHERE name=%s' - >>> q.values() - ['joe'] - """ - def __init__(self, value): - self.value = value - - def get_marker(self, paramstyle='pyformat'): - if paramstyle == 'qmark': - return '?' - elif paramstyle == 'numeric': - return ':1' - elif paramstyle is None or paramstyle in ['format', 'pyformat']: - return '%s' - raise UnknownParamstyle, paramstyle - - def sqlquery(self): - return SQLQuery([self]) - - def __add__(self, other): - return self.sqlquery() + other - - def __radd__(self, other): - return other + self.sqlquery() - - def __str__(self): - return str(self.value) - - def __repr__(self): - return '' % repr(self.value) - -sqlparam = SQLParam - -class SQLQuery: - """ - You can pass this sort of thing as a clause in any db function. - Otherwise, you can pass a dictionary to the keyword argument `vars` - and the function will call reparam for you. - - Internally, consists of `items`, which is a list of strings and - SQLParams, which get concatenated to produce the actual query. - """ - # tested in sqlquote's docstring - def __init__(self, items=[]): - r"""Creates a new SQLQuery. - - >>> SQLQuery("x") - - >>> q = SQLQuery(['SELECT * FROM ', 'test', ' WHERE x=', SQLParam(1)]) - >>> q - - >>> q.query(), q.values() - ('SELECT * FROM test WHERE x=%s', [1]) - >>> SQLQuery(SQLParam(1)) - - """ - if isinstance(items, list): - self.items = items - elif isinstance(items, SQLParam): - self.items = [items] - elif isinstance(items, SQLQuery): - self.items = list(items.items) - else: - self.items = [items] - - # Take care of SQLLiterals - for i, item in enumerate(self.items): - if isinstance(item, SQLParam) and isinstance(item.value, SQLLiteral): - self.items[i] = item.value.v - - def __add__(self, other): - if isinstance(other, basestring): - items = [other] - elif isinstance(other, SQLQuery): - items = other.items - else: - return NotImplemented - return SQLQuery(self.items + items) - - def __radd__(self, other): - if isinstance(other, basestring): - items = [other] - else: - return NotImplemented - - return SQLQuery(items + self.items) - - def __iadd__(self, other): - if isinstance(other, basestring): - items = [other] - elif isinstance(other, SQLQuery): - items = other.items - else: - return NotImplemented - self.items.extend(items) - return self - - def __len__(self): - return len(self.query()) - - def query(self, paramstyle=None): - """ - Returns the query part of the sql query. - >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')]) - >>> q.query() - 'SELECT * FROM test WHERE name=%s' - >>> q.query(paramstyle='qmark') - 'SELECT * FROM test WHERE name=?' - """ - s = [] - for x in self.items: - if isinstance(x, SQLParam): - x = x.get_marker(paramstyle) - s.append(safestr(x)) - else: - x = safestr(x) - # automatically escape % characters in the query - # For backward compatability, ignore escaping when the query looks already escaped - if paramstyle in ['format', 'pyformat']: - if '%' in x and '%%' not in x: - x = x.replace('%', '%%') - s.append(x) - return "".join(s) - - def values(self): - """ - Returns the values of the parameters used in the sql query. - >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')]) - >>> q.values() - ['joe'] - """ - return [i.value for i in self.items if isinstance(i, SQLParam)] - - def join(items, sep=' '): - """ - Joins multiple queries. - - >>> SQLQuery.join(['a', 'b'], ', ') - - """ - if len(items) == 0: - return SQLQuery("") - - q = SQLQuery(items[0]) - for item in items[1:]: - q += sep - q += item - return q - - join = staticmethod(join) - - def _str(self): - try: - return self.query() % tuple([sqlify(x) for x in self.values()]) - except (ValueError, TypeError): - return self.query() - - def __str__(self): - return safestr(self._str()) - - def __unicode__(self): - return safeunicode(self._str()) - - def __repr__(self): - return '' % repr(str(self)) - -class SQLLiteral: - """ - Protects a string from `sqlquote`. - - >>> sqlquote('NOW()') - - >>> sqlquote(SQLLiteral('NOW()')) - - """ - def __init__(self, v): - self.v = v - - def __repr__(self): - return self.v - -sqlliteral = SQLLiteral - -def _sqllist(values): - """ - >>> _sqllist([1, 2, 3]) - - """ - items = [] - items.append('(') - for i, v in enumerate(values): - if i != 0: - items.append(', ') - items.append(sqlparam(v)) - items.append(')') - return SQLQuery(items) - -def reparam(string_, dictionary): - """ - Takes a string and a dictionary and interpolates the string - using values from the dictionary. Returns an `SQLQuery` for the result. - - >>> reparam("s = $s", dict(s=True)) - - >>> reparam("s IN $s", dict(s=[1, 2])) - - """ - dictionary = dictionary.copy() # eval mucks with it - vals = [] - result = [] - for live, chunk in _interpolate(string_): - if live: - v = eval(chunk, dictionary) - result.append(sqlquote(v)) - else: - result.append(chunk) - return SQLQuery.join(result, '') - -def sqlify(obj): - """ - converts `obj` to its proper SQL version - - >>> sqlify(None) - 'NULL' - >>> sqlify(True) - "'t'" - >>> sqlify(3) - '3' - """ - # because `1 == True and hash(1) == hash(True)` - # we have to do this the hard way... - - if obj is None: - return 'NULL' - elif obj is True: - return "'t'" - elif obj is False: - return "'f'" - elif datetime and isinstance(obj, datetime.datetime): - return repr(obj.isoformat()) - else: - if isinstance(obj, unicode): obj = obj.encode('utf8') - return repr(obj) - -def sqllist(lst): - """ - Converts the arguments for use in something like a WHERE clause. - - >>> sqllist(['a', 'b']) - 'a, b' - >>> sqllist('a') - 'a' - >>> sqllist(u'abc') - u'abc' - """ - if isinstance(lst, basestring): - return lst - else: - return ', '.join(lst) - -def sqlors(left, lst): - """ - `left is a SQL clause like `tablename.arg = ` - and `lst` is a list of values. Returns a reparam-style - pair featuring the SQL that ORs together the clause - for each item in the lst. - - >>> sqlors('foo = ', []) - - >>> sqlors('foo = ', [1]) - - >>> sqlors('foo = ', 1) - - >>> sqlors('foo = ', [1,2,3]) - - """ - if isinstance(lst, iters): - lst = list(lst) - ln = len(lst) - if ln == 0: - return SQLQuery("1=2") - if ln == 1: - lst = lst[0] - - if isinstance(lst, iters): - return SQLQuery(['('] + - sum([[left, sqlparam(x), ' OR '] for x in lst], []) + - ['1=2)'] - ) - else: - return left + sqlparam(lst) - -def sqlwhere(dictionary, grouping=' AND '): - """ - Converts a `dictionary` to an SQL WHERE clause `SQLQuery`. - - >>> sqlwhere({'cust_id': 2, 'order_id':3}) - - >>> sqlwhere({'cust_id': 2, 'order_id':3}, grouping=', ') - - >>> sqlwhere({'a': 'a', 'b': 'b'}).query() - 'a = %s AND b = %s' - """ - return SQLQuery.join([k + ' = ' + sqlparam(v) for k, v in dictionary.items()], grouping) - -def sqlquote(a): - """ - Ensures `a` is quoted properly for use in a SQL query. - - >>> 'WHERE x = ' + sqlquote(True) + ' AND y = ' + sqlquote(3) - - >>> 'WHERE x = ' + sqlquote(True) + ' AND y IN ' + sqlquote([2, 3]) - - """ - if isinstance(a, list): - return _sqllist(a) - else: - return sqlparam(a).sqlquery() - -class Transaction: - """Database transaction.""" - def __init__(self, ctx): - self.ctx = ctx - self.transaction_count = transaction_count = len(ctx.transactions) - - class transaction_engine: - """Transaction Engine used in top level transactions.""" - def do_transact(self): - ctx.commit(unload=False) - - def do_commit(self): - ctx.commit() - - def do_rollback(self): - ctx.rollback() - - class subtransaction_engine: - """Transaction Engine used in sub transactions.""" - def query(self, q): - db_cursor = ctx.db.cursor() - ctx.db_execute(db_cursor, SQLQuery(q % transaction_count)) - - def do_transact(self): - self.query('SAVEPOINT webpy_sp_%s') - - def do_commit(self): - self.query('RELEASE SAVEPOINT webpy_sp_%s') - - def do_rollback(self): - self.query('ROLLBACK TO SAVEPOINT webpy_sp_%s') - - class dummy_engine: - """Transaction Engine used instead of subtransaction_engine - when sub transactions are not supported.""" - do_transact = do_commit = do_rollback = lambda self: None - - if self.transaction_count: - # nested transactions are not supported in some databases - if self.ctx.get('ignore_nested_transactions'): - self.engine = dummy_engine() - else: - self.engine = subtransaction_engine() - else: - self.engine = transaction_engine() - - self.engine.do_transact() - self.ctx.transactions.append(self) - - def __enter__(self): - return self - - def __exit__(self, exctype, excvalue, traceback): - if exctype is not None: - self.rollback() - else: - self.commit() - - def commit(self): - if len(self.ctx.transactions) > self.transaction_count: - self.engine.do_commit() - self.ctx.transactions = self.ctx.transactions[:self.transaction_count] - - def rollback(self): - if len(self.ctx.transactions) > self.transaction_count: - self.engine.do_rollback() - self.ctx.transactions = self.ctx.transactions[:self.transaction_count] - -class DB: - """Database""" - def __init__(self, db_module, keywords): - """Creates a database. - """ - # some DB implementaions take optional paramater `driver` to use a specific driver modue - # but it should not be passed to connect - keywords.pop('driver', None) - - self.db_module = db_module - self.keywords = keywords - - - self._ctx = threadeddict() - # flag to enable/disable printing queries - self.printing = config.get('debug', False) - self.supports_multiple_insert = False - - try: - import DBUtils - # enable pooling if DBUtils module is available. - self.has_pooling = True - except ImportError: - self.has_pooling = False - - # Pooling can be disabled by passing pooling=False in the keywords. - self.has_pooling = self.keywords.pop('pooling', True) and self.has_pooling - - def _getctx(self): - if not self._ctx.get('db'): - self._load_context(self._ctx) - return self._ctx - ctx = property(_getctx) - - def _load_context(self, ctx): - ctx.dbq_count = 0 - ctx.transactions = [] # stack of transactions - - if self.has_pooling: - ctx.db = self._connect_with_pooling(self.keywords) - else: - ctx.db = self._connect(self.keywords) - ctx.db_execute = self._db_execute - - if not hasattr(ctx.db, 'commit'): - ctx.db.commit = lambda: None - - if not hasattr(ctx.db, 'rollback'): - ctx.db.rollback = lambda: None - - def commit(unload=True): - # do db commit and release the connection if pooling is enabled. - ctx.db.commit() - if unload and self.has_pooling: - self._unload_context(self._ctx) - - def rollback(): - # do db rollback and release the connection if pooling is enabled. - ctx.db.rollback() - if self.has_pooling: - self._unload_context(self._ctx) - - ctx.commit = commit - ctx.rollback = rollback - - def _unload_context(self, ctx): - del ctx.db - - def _connect(self, keywords): - return self.db_module.connect(**keywords) - - def _connect_with_pooling(self, keywords): - def get_pooled_db(): - from DBUtils import PooledDB - - # In DBUtils 0.9.3, `dbapi` argument is renamed as `creator` - # see Bug#122112 - - if PooledDB.__version__.split('.') < '0.9.3'.split('.'): - return PooledDB.PooledDB(dbapi=self.db_module, **keywords) - else: - return PooledDB.PooledDB(creator=self.db_module, **keywords) - - if getattr(self, '_pooleddb', None) is None: - self._pooleddb = get_pooled_db() - - return self._pooleddb.connection() - - def _db_cursor(self): - return self.ctx.db.cursor() - - def _param_marker(self): - """Returns parameter marker based on paramstyle attribute if this database.""" - style = getattr(self, 'paramstyle', 'pyformat') - - if style == 'qmark': - return '?' - elif style == 'numeric': - return ':1' - elif style in ['format', 'pyformat']: - return '%s' - raise UnknownParamstyle, style - - def _db_execute(self, cur, sql_query): - """executes an sql query""" - self.ctx.dbq_count += 1 - - try: - a = time.time() - paramstyle = getattr(self, 'paramstyle', 'pyformat') - out = cur.execute(sql_query.query(paramstyle), sql_query.values()) - b = time.time() - except: - if self.printing: - print >> debug, 'ERR:', str(sql_query) - if self.ctx.transactions: - self.ctx.transactions[-1].rollback() - else: - self.ctx.rollback() - raise - - if self.printing: - print >> debug, '%s (%s): %s' % (round(b-a, 2), self.ctx.dbq_count, str(sql_query)) - return out - - def _where(self, where, vars): - if isinstance(where, (int, long)): - where = "id = " + sqlparam(where) - #@@@ for backward-compatibility - elif isinstance(where, (list, tuple)) and len(where) == 2: - where = SQLQuery(where[0], where[1]) - elif isinstance(where, SQLQuery): - pass - else: - where = reparam(where, vars) - return where - - def query(self, sql_query, vars=None, processed=False, _test=False): - """ - Execute SQL query `sql_query` using dictionary `vars` to interpolate it. - If `processed=True`, `vars` is a `reparam`-style list to use - instead of interpolating. - - >>> db = DB(None, {}) - >>> db.query("SELECT * FROM foo", _test=True) - - >>> db.query("SELECT * FROM foo WHERE x = $x", vars=dict(x='f'), _test=True) - - >>> db.query("SELECT * FROM foo WHERE x = " + sqlquote('f'), _test=True) - - """ - if vars is None: vars = {} - - if not processed and not isinstance(sql_query, SQLQuery): - sql_query = reparam(sql_query, vars) - - if _test: return sql_query - - db_cursor = self._db_cursor() - self._db_execute(db_cursor, sql_query) - - if db_cursor.description: - names = [x[0] for x in db_cursor.description] - def iterwrapper(): - row = db_cursor.fetchone() - while row: - yield storage(dict(zip(names, row))) - row = db_cursor.fetchone() - out = iterbetter(iterwrapper()) - out.__len__ = lambda: int(db_cursor.rowcount) - out.list = lambda: [storage(dict(zip(names, x))) \ - for x in db_cursor.fetchall()] - else: - out = db_cursor.rowcount - - if not self.ctx.transactions: - self.ctx.commit() - return out - - def select(self, tables, vars=None, what='*', where=None, order=None, group=None, - limit=None, offset=None, _test=False): - """ - Selects `what` from `tables` with clauses `where`, `order`, - `group`, `limit`, and `offset`. Uses vars to interpolate. - Otherwise, each clause can be a SQLQuery. - - >>> db = DB(None, {}) - >>> db.select('foo', _test=True) - - >>> db.select(['foo', 'bar'], where="foo.bar_id = bar.id", limit=5, _test=True) - - """ - if vars is None: vars = {} - sql_clauses = self.sql_clauses(what, tables, where, group, order, limit, offset) - clauses = [self.gen_clause(sql, val, vars) for sql, val in sql_clauses if val is not None] - qout = SQLQuery.join(clauses) - if _test: return qout - return self.query(qout, processed=True) - - def where(self, table, what='*', order=None, group=None, limit=None, - offset=None, _test=False, **kwargs): - """ - Selects from `table` where keys are equal to values in `kwargs`. - - >>> db = DB(None, {}) - >>> db.where('foo', bar_id=3, _test=True) - - >>> db.where('foo', source=2, crust='dewey', _test=True) - - """ - where = [] - for k, v in kwargs.iteritems(): - where.append(k + ' = ' + sqlquote(v)) - return self.select(table, what=what, order=order, - group=group, limit=limit, offset=offset, _test=_test, - where=SQLQuery.join(where, ' AND ')) - - def sql_clauses(self, what, tables, where, group, order, limit, offset): - return ( - ('SELECT', what), - ('FROM', sqllist(tables)), - ('WHERE', where), - ('GROUP BY', group), - ('ORDER BY', order), - ('LIMIT', limit), - ('OFFSET', offset)) - - def gen_clause(self, sql, val, vars): - if isinstance(val, (int, long)): - if sql == 'WHERE': - nout = 'id = ' + sqlquote(val) - else: - nout = SQLQuery(val) - #@@@ - elif isinstance(val, (list, tuple)) and len(val) == 2: - nout = SQLQuery(val[0], val[1]) # backwards-compatibility - elif isinstance(val, SQLQuery): - nout = val - else: - nout = reparam(val, vars) - - def xjoin(a, b): - if a and b: return a + ' ' + b - else: return a or b - - return xjoin(sql, nout) - - def insert(self, tablename, seqname=None, _test=False, **values): - """ - Inserts `values` into `tablename`. Returns current sequence ID. - Set `seqname` to the ID if it's not the default, or to `False` - if there isn't one. - - >>> db = DB(None, {}) - >>> q = db.insert('foo', name='bob', age=2, created=SQLLiteral('NOW()'), _test=True) - >>> q - - >>> q.query() - 'INSERT INTO foo (age, name, created) VALUES (%s, %s, NOW())' - >>> q.values() - [2, 'bob'] - """ - def q(x): return "(" + x + ")" - - if values: - _keys = SQLQuery.join(values.keys(), ', ') - _values = SQLQuery.join([sqlparam(v) for v in values.values()], ', ') - sql_query = "INSERT INTO %s " % tablename + q(_keys) + ' VALUES ' + q(_values) - else: - sql_query = SQLQuery("INSERT INTO %s DEFAULT VALUES" % tablename) - - if _test: return sql_query - - db_cursor = self._db_cursor() - if seqname is not False: - sql_query = self._process_insert_query(sql_query, tablename, seqname) - - if isinstance(sql_query, tuple): - # for some databases, a separate query has to be made to find - # the id of the inserted row. - q1, q2 = sql_query - self._db_execute(db_cursor, q1) - self._db_execute(db_cursor, q2) - else: - self._db_execute(db_cursor, sql_query) - - try: - out = db_cursor.fetchone()[0] - except Exception: - out = None - - if not self.ctx.transactions: - self.ctx.commit() - return out - - def multiple_insert(self, tablename, values, seqname=None, _test=False): - """ - Inserts multiple rows into `tablename`. The `values` must be a list of dictioanries, - one for each row to be inserted, each with the same set of keys. - Returns the list of ids of the inserted rows. - Set `seqname` to the ID if it's not the default, or to `False` - if there isn't one. - - >>> db = DB(None, {}) - >>> db.supports_multiple_insert = True - >>> values = [{"name": "foo", "email": "foo@example.com"}, {"name": "bar", "email": "bar@example.com"}] - >>> db.multiple_insert('person', values=values, _test=True) - - """ - if not values: - return [] - - if not self.supports_multiple_insert: - out = [self.insert(tablename, seqname=seqname, _test=_test, **v) for v in values] - if seqname is False: - return None - else: - return out - - keys = values[0].keys() - #@@ make sure all keys are valid - - # make sure all rows have same keys. - for v in values: - if v.keys() != keys: - raise ValueError, 'Bad data' - - sql_query = SQLQuery('INSERT INTO %s (%s) VALUES ' % (tablename, ', '.join(keys))) - - data = [] - for row in values: - d = SQLQuery.join([SQLParam(row[k]) for k in keys], ', ') - data.append('(' + d + ')') - sql_query += SQLQuery.join(data, ', ') - - if _test: return sql_query - - db_cursor = self._db_cursor() - if seqname is not False: - sql_query = self._process_insert_query(sql_query, tablename, seqname) - - if isinstance(sql_query, tuple): - # for some databases, a separate query has to be made to find - # the id of the inserted row. - q1, q2 = sql_query - self._db_execute(db_cursor, q1) - self._db_execute(db_cursor, q2) - else: - self._db_execute(db_cursor, sql_query) - - try: - out = db_cursor.fetchone()[0] - out = range(out-len(values)+1, out+1) - except Exception: - out = None - - if not self.ctx.transactions: - self.ctx.commit() - return out - - - def update(self, tables, where, vars=None, _test=False, **values): - """ - Update `tables` with clause `where` (interpolated using `vars`) - and setting `values`. - - >>> db = DB(None, {}) - >>> name = 'Joseph' - >>> q = db.update('foo', where='name = $name', name='bob', age=2, - ... created=SQLLiteral('NOW()'), vars=locals(), _test=True) - >>> q - - >>> q.query() - 'UPDATE foo SET age = %s, name = %s, created = NOW() WHERE name = %s' - >>> q.values() - [2, 'bob', 'Joseph'] - """ - if vars is None: vars = {} - where = self._where(where, vars) - - query = ( - "UPDATE " + sqllist(tables) + - " SET " + sqlwhere(values, ', ') + - " WHERE " + where) - - if _test: return query - - db_cursor = self._db_cursor() - self._db_execute(db_cursor, query) - if not self.ctx.transactions: - self.ctx.commit() - return db_cursor.rowcount - - def delete(self, table, where, using=None, vars=None, _test=False): - """ - Deletes from `table` with clauses `where` and `using`. - - >>> db = DB(None, {}) - >>> name = 'Joe' - >>> db.delete('foo', where='name = $name', vars=locals(), _test=True) - - """ - if vars is None: vars = {} - where = self._where(where, vars) - - q = 'DELETE FROM ' + table - if where: q += ' WHERE ' + where - if using: q += ' USING ' + sqllist(using) - - if _test: return q - - db_cursor = self._db_cursor() - self._db_execute(db_cursor, q) - if not self.ctx.transactions: - self.ctx.commit() - return db_cursor.rowcount - - def _process_insert_query(self, query, tablename, seqname): - return query - - def transaction(self): - """Start a transaction.""" - return Transaction(self.ctx) - -class PostgresDB(DB): - """Postgres driver.""" - def __init__(self, **keywords): - if 'pw' in keywords: - keywords['password'] = keywords.pop('pw') - - db_module = import_driver(["psycopg2", "psycopg", "pgdb"], preferred=keywords.pop('driver', None)) - if db_module.__name__ == "psycopg2": - import psycopg2.extensions - psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) - - # if db is not provided postgres driver will take it from PGDATABASE environment variable - if 'db' in keywords: - keywords['database'] = keywords.pop('db') - - self.dbname = "postgres" - self.paramstyle = db_module.paramstyle - DB.__init__(self, db_module, keywords) - self.supports_multiple_insert = True - self._sequences = None - - def _process_insert_query(self, query, tablename, seqname): - if seqname is None: - # when seqname is not provided guess the seqname and make sure it exists - seqname = tablename + "_id_seq" - if seqname not in self._get_all_sequences(): - seqname = None - - if seqname: - query += "; SELECT currval('%s')" % seqname - - return query - - def _get_all_sequences(self): - """Query postgres to find names of all sequences used in this database.""" - if self._sequences is None: - q = "SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'" - self._sequences = set([c.relname for c in self.query(q)]) - return self._sequences - - def _connect(self, keywords): - conn = DB._connect(self, keywords) - conn.set_client_encoding('UTF8') - return conn - - def _connect_with_pooling(self, keywords): - conn = DB._connect_with_pooling(self, keywords) - conn._con._con.set_client_encoding('UTF8') - return conn - -class MySQLDB(DB): - def __init__(self, **keywords): - import MySQLdb as db - if 'pw' in keywords: - keywords['passwd'] = keywords['pw'] - del keywords['pw'] - - if 'charset' not in keywords: - keywords['charset'] = 'utf8' - elif keywords['charset'] is None: - del keywords['charset'] - - self.paramstyle = db.paramstyle = 'pyformat' # it's both, like psycopg - self.dbname = "mysql" - DB.__init__(self, db, keywords) - self.supports_multiple_insert = True - - def _process_insert_query(self, query, tablename, seqname): - return query, SQLQuery('SELECT last_insert_id();') - -def import_driver(drivers, preferred=None): - """Import the first available driver or preferred driver. - """ - if preferred: - drivers = [preferred] - - for d in drivers: - try: - return __import__(d, None, None, ['x']) - except ImportError: - pass - raise ImportError("Unable to import " + " or ".join(drivers)) - -class SqliteDB(DB): - def __init__(self, **keywords): - db = import_driver(["sqlite3", "pysqlite2.dbapi2", "sqlite"], preferred=keywords.pop('driver', None)) - - if db.__name__ in ["sqlite3", "pysqlite2.dbapi2"]: - db.paramstyle = 'qmark' - - self.paramstyle = db.paramstyle - keywords['database'] = keywords.pop('db') - self.dbname = "sqlite" - DB.__init__(self, db, keywords) - - def _process_insert_query(self, query, tablename, seqname): - return query, SQLQuery('SELECT last_insert_rowid();') - - def query(self, *a, **kw): - out = DB.query(self, *a, **kw) - if isinstance(out, iterbetter): - del out.__len__ - return out - -class FirebirdDB(DB): - """Firebird Database. - """ - def __init__(self, **keywords): - try: - import kinterbasdb as db - except Exception: - db = None - pass - if 'pw' in keywords: - keywords['passwd'] = keywords['pw'] - del keywords['pw'] - keywords['database'] = keywords['db'] - del keywords['db'] - DB.__init__(self, db, keywords) - - def delete(self, table, where=None, using=None, vars=None, _test=False): - # firebird doesn't support using clause - using=None - return DB.delete(self, table, where, using, vars, _test) - - def sql_clauses(self, what, tables, where, group, order, limit, offset): - return ( - ('SELECT', ''), - ('FIRST', limit), - ('SKIP', offset), - ('', what), - ('FROM', sqllist(tables)), - ('WHERE', where), - ('GROUP BY', group), - ('ORDER BY', order) - ) - -class MSSQLDB(DB): - def __init__(self, **keywords): - import pymssql as db - if 'pw' in keywords: - keywords['password'] = keywords.pop('pw') - keywords['database'] = keywords.pop('db') - self.dbname = "mssql" - DB.__init__(self, db, keywords) - - def sql_clauses(self, what, tables, where, group, order, limit, offset): - return ( - ('SELECT', what), - ('TOP', limit), - ('FROM', sqllist(tables)), - ('WHERE', where), - ('GROUP BY', group), - ('ORDER BY', order), - ('OFFSET', offset)) - - def _test(self): - """Test LIMIT. - - Fake presence of pymssql module for running tests. - >>> import sys - >>> sys.modules['pymssql'] = sys.modules['sys'] - - MSSQL has TOP clause instead of LIMIT clause. - >>> db = MSSQLDB(db='test', user='joe', pw='secret') - >>> db.select('foo', limit=4, _test=True) - - """ - pass - -class OracleDB(DB): - def __init__(self, **keywords): - import cx_Oracle as db - if 'pw' in keywords: - keywords['password'] = keywords.pop('pw') - - #@@ TODO: use db.makedsn if host, port is specified - keywords['dsn'] = keywords.pop('db') - self.dbname = 'oracle' - db.paramstyle = 'numeric' - self.paramstyle = db.paramstyle - - # oracle doesn't support pooling - keywords.pop('pooling', None) - DB.__init__(self, db, keywords) - - def _process_insert_query(self, query, tablename, seqname): - if seqname is None: - # It is not possible to get seq name from table name in Oracle - return query - else: - return query + "; SELECT %s.currval FROM dual" % seqname - -_databases = {} -def database(dburl=None, **params): - """Creates appropriate database using params. - - Pooling will be enabled if DBUtils module is available. - Pooling can be disabled by passing pooling=False in params. - """ - dbn = params.pop('dbn') - if dbn in _databases: - return _databases[dbn](**params) - else: - raise UnknownDB, dbn - -def register_database(name, clazz): - """ - Register a database. - - >>> class LegacyDB(DB): - ... def __init__(self, **params): - ... pass - ... - >>> register_database('legacy', LegacyDB) - >>> db = database(dbn='legacy', db='test', user='joe', passwd='secret') - """ - _databases[name] = clazz - -register_database('mysql', MySQLDB) -register_database('postgres', PostgresDB) -register_database('sqlite', SqliteDB) -register_database('firebird', FirebirdDB) -register_database('mssql', MSSQLDB) -register_database('oracle', OracleDB) - -def _interpolate(format): - """ - Takes a format string and returns a list of 2-tuples of the form - (boolean, string) where boolean says whether string should be evaled - or not. - - from (public domain, Ka-Ping Yee) - """ - from tokenize import tokenprog - - def matchorfail(text, pos): - match = tokenprog.match(text, pos) - if match is None: - raise _ItplError(text, pos) - return match, match.end() - - namechars = "abcdefghijklmnopqrstuvwxyz" \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; - chunks = [] - pos = 0 - - while 1: - dollar = format.find("$", pos) - if dollar < 0: - break - nextchar = format[dollar + 1] - - if nextchar == "{": - chunks.append((0, format[pos:dollar])) - pos, level = dollar + 2, 1 - while level: - match, pos = matchorfail(format, pos) - tstart, tend = match.regs[3] - token = format[tstart:tend] - if token == "{": - level = level + 1 - elif token == "}": - level = level - 1 - chunks.append((1, format[dollar + 2:pos - 1])) - - elif nextchar in namechars: - chunks.append((0, format[pos:dollar])) - match, pos = matchorfail(format, dollar + 1) - while pos < len(format): - if format[pos] == "." and \ - pos + 1 < len(format) and format[pos + 1] in namechars: - match, pos = matchorfail(format, pos + 1) - elif format[pos] in "([": - pos, level = pos + 1, 1 - while level: - match, pos = matchorfail(format, pos) - tstart, tend = match.regs[3] - token = format[tstart:tend] - if token[0] in "([": - level = level + 1 - elif token[0] in ")]": - level = level - 1 - else: - break - chunks.append((1, format[dollar + 1:pos])) - else: - chunks.append((0, format[pos:dollar + 1])) - pos = dollar + 1 + (nextchar == "$") - - if pos < len(format): - chunks.append((0, format[pos:])) - return chunks - -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/thirdparty/web/debugerror.py b/thirdparty/web/debugerror.py deleted file mode 100644 index c3efbbd302..0000000000 --- a/thirdparty/web/debugerror.py +++ /dev/null @@ -1,354 +0,0 @@ -""" -pretty debug errors -(part of web.py) - -portions adapted from Django -Copyright (c) 2005, the Lawrence Journal-World -Used under the modified BSD license: -http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -""" - -__all__ = ["debugerror", "djangoerror", "emailerrors"] - -import sys, urlparse, pprint, traceback -from net import websafe -from template import Template -from utils import sendmail, safestr -import webapi as web - -import os, os.path -whereami = os.path.join(os.getcwd(), __file__) -whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1]) -djangoerror_t = """\ -$def with (exception_type, exception_value, frames) - - - - - - $exception_type at $ctx.path - - - - - -$def dicttable (d, kls='req', id=None): - $ items = d and d.items() or [] - $items.sort() - $:dicttable_items(items, kls, id) - -$def dicttable_items(items, kls='req', id=None): - $if items: - - - $for k, v in items: - - -
VariableValue
$k
$prettify(v)
- $else: -

No data.

- -
-

$exception_type at $ctx.path

-

$exception_value

- - - - - - -
Python$frames[0].filename in $frames[0].function, line $frames[0].lineno
Web$ctx.method $ctx.home$ctx.path
-
-
-

Traceback (innermost first)

-
    -$for frame in frames: -
  • - $frame.filename in $frame.function - $if frame.context_line is not None: -
    - $if frame.pre_context: -
      - $for line in frame.pre_context: -
    1. $line
    2. -
    -
    1. $frame.context_line ...
    - $if frame.post_context: -
      - $for line in frame.post_context: -
    1. $line
    2. -
    -
    - - $if frame.vars: -
    - Local vars - $# $inspect.formatargvalues(*inspect.getargvalues(frame['tb'].tb_frame)) -
    - $:dicttable(frame.vars, kls='vars', id=('v' + str(frame.id))) -
  • -
-
- -
-$if ctx.output or ctx.headers: -

Response so far

-

HEADERS

- $:dicttable_items(ctx.headers) - -

BODY

-

- $ctx.output -

- -

Request information

- -

INPUT

-$:dicttable(web.input(_unicode=False)) - - -$:dicttable(web.cookies()) - -

META

-$ newctx = [(k, v) for (k, v) in ctx.iteritems() if not k.startswith('_') and not isinstance(v, dict)] -$:dicttable(dict(newctx)) - -

ENVIRONMENT

-$:dicttable(ctx.env) -
- -
-

- You're seeing this error because you have web.config.debug - set to True. Set that to False if you don't to see this. -

-
- - - -""" - -djangoerror_r = None - -def djangoerror(): - def _get_lines_from_file(filename, lineno, context_lines): - """ - Returns context_lines before and after lineno from file. - Returns (pre_context_lineno, pre_context, context_line, post_context). - """ - try: - source = open(filename).readlines() - lower_bound = max(0, lineno - context_lines) - upper_bound = lineno + context_lines - - pre_context = \ - [line.strip('\n') for line in source[lower_bound:lineno]] - context_line = source[lineno].strip('\n') - post_context = \ - [line.strip('\n') for line in source[lineno + 1:upper_bound]] - - return lower_bound, pre_context, context_line, post_context - except (OSError, IOError, IndexError): - return None, [], None, [] - - exception_type, exception_value, tback = sys.exc_info() - frames = [] - while tback is not None: - filename = tback.tb_frame.f_code.co_filename - function = tback.tb_frame.f_code.co_name - lineno = tback.tb_lineno - 1 - - # hack to get correct line number for templates - lineno += tback.tb_frame.f_locals.get("__lineoffset__", 0) - - pre_context_lineno, pre_context, context_line, post_context = \ - _get_lines_from_file(filename, lineno, 7) - - if '__hidetraceback__' not in tback.tb_frame.f_locals: - frames.append(web.storage({ - 'tback': tback, - 'filename': filename, - 'function': function, - 'lineno': lineno, - 'vars': tback.tb_frame.f_locals, - 'id': id(tback), - 'pre_context': pre_context, - 'context_line': context_line, - 'post_context': post_context, - 'pre_context_lineno': pre_context_lineno, - })) - tback = tback.tb_next - frames.reverse() - urljoin = urlparse.urljoin - def prettify(x): - try: - out = pprint.pformat(x) - except Exception, e: - out = '[could not display: <' + e.__class__.__name__ + \ - ': '+str(e)+'>]' - return out - - global djangoerror_r - if djangoerror_r is None: - djangoerror_r = Template(djangoerror_t, filename=__file__, filter=websafe) - - t = djangoerror_r - globals = {'ctx': web.ctx, 'web':web, 'dict':dict, 'str':str, 'prettify': prettify} - t.t.func_globals.update(globals) - return t(exception_type, exception_value, frames) - -def debugerror(): - """ - A replacement for `internalerror` that presents a nice page with lots - of debug information for the programmer. - - (Based on the beautiful 500 page from [Django](http://djangoproject.com/), - designed by [Wilson Miner](http://wilsonminer.com/).) - """ - return web._InternalError(djangoerror()) - -def emailerrors(to_address, olderror, from_address=None): - """ - Wraps the old `internalerror` handler (pass as `olderror`) to - additionally email all errors to `to_address`, to aid in - debugging production websites. - - Emails contain a normal text traceback as well as an - attachment containing the nice `debugerror` page. - """ - from_address = from_address or to_address - - def emailerrors_internal(): - error = olderror() - tb = sys.exc_info() - error_name = tb[0] - error_value = tb[1] - tb_txt = ''.join(traceback.format_exception(*tb)) - path = web.ctx.path - request = web.ctx.method + ' ' + web.ctx.home + web.ctx.fullpath - - message = "\n%s\n\n%s\n\n" % (request, tb_txt) - - sendmail( - "your buggy site <%s>" % from_address, - "the bugfixer <%s>" % to_address, - "bug: %(error_name)s: %(error_value)s (%(path)s)" % locals(), - message, - attachments=[ - dict(filename="bug.html", content=safestr(djangoerror())) - ], - ) - return error - - return emailerrors_internal - -if __name__ == "__main__": - urls = ( - '/', 'index' - ) - from application import application - app = application(urls, globals()) - app.internalerror = debugerror - - class index: - def GET(self): - thisdoesnotexist - - app.run() diff --git a/thirdparty/web/form.py b/thirdparty/web/form.py deleted file mode 100644 index 4602082805..0000000000 --- a/thirdparty/web/form.py +++ /dev/null @@ -1,369 +0,0 @@ -""" -HTML forms -(part of web.py) -""" - -import copy, re -import webapi as web -import utils, net - -def attrget(obj, attr, value=None): - if hasattr(obj, 'has_key') and obj.has_key(attr): return obj[attr] - if hasattr(obj, attr): return getattr(obj, attr) - return value - -class Form: - r""" - HTML form. - - >>> f = Form(Textbox("x")) - >>> f.render() - '\n \n
' - """ - def __init__(self, *inputs, **kw): - self.inputs = inputs - self.valid = True - self.note = None - self.validators = kw.pop('validators', []) - - def __call__(self, x=None): - o = copy.deepcopy(self) - if x: o.validates(x) - return o - - def render(self): - out = '' - out += self.rendernote(self.note) - out += '\n' - - for i in self.inputs: - html = i.pre + i.render() + self.rendernote(i.note) + i.post - if i.is_hidden(): - out += ' \n' % (html) - else: - out += ' \n' % (i.id, net.websafe(i.description), html) - out += "
%s
%s
" - return out - - def render_css(self): - out = [] - out.append(self.rendernote(self.note)) - for i in self.inputs: - if not i.is_hidden(): - out.append('' % (i.id, net.websafe(i.description))) - out.append(i.pre) - out.append(i.render()) - out.append(self.rendernote(i.note)) - out.append(i.post) - out.append('\n') - return ''.join(out) - - def rendernote(self, note): - if note: return '%s' % net.websafe(note) - else: return "" - - def validates(self, source=None, _validate=True, **kw): - source = source or kw or web.input() - out = True - for i in self.inputs: - v = attrget(source, i.name) - if _validate: - out = i.validate(v) and out - else: - i.value = v - if _validate: - out = out and self._validate(source) - self.valid = out - return out - - def _validate(self, value): - self.value = value - for v in self.validators: - if not v.valid(value): - self.note = v.msg - return False - return True - - def fill(self, source=None, **kw): - return self.validates(source, _validate=False, **kw) - - def __getitem__(self, i): - for x in self.inputs: - if x.name == i: return x - raise KeyError, i - - def __getattr__(self, name): - # don't interfere with deepcopy - inputs = self.__dict__.get('inputs') or [] - for x in inputs: - if x.name == name: return x - raise AttributeError, name - - def get(self, i, default=None): - try: - return self[i] - except KeyError: - return default - - def _get_d(self): #@@ should really be form.attr, no? - return utils.storage([(i.name, i.get_value()) for i in self.inputs]) - d = property(_get_d) - -class Input(object): - def __init__(self, name, *validators, **attrs): - self.name = name - self.validators = validators - self.attrs = attrs = AttributeList(attrs) - - self.description = attrs.pop('description', name) - self.value = attrs.pop('value', None) - self.pre = attrs.pop('pre', "") - self.post = attrs.pop('post', "") - self.note = None - - self.id = attrs.setdefault('id', self.get_default_id()) - - if 'class_' in attrs: - attrs['class'] = attrs['class_'] - del attrs['class_'] - - def is_hidden(self): - return False - - def get_type(self): - raise NotImplementedError - - def get_default_id(self): - return self.name - - def validate(self, value): - self.set_value(value) - - for v in self.validators: - if not v.valid(value): - self.note = v.msg - return False - return True - - def set_value(self, value): - self.value = value - - def get_value(self): - return self.value - - def render(self): - attrs = self.attrs.copy() - attrs['type'] = self.get_type() - if self.value is not None: - attrs['value'] = self.value - attrs['name'] = self.name - return '' % attrs - - def rendernote(self, note): - if note: return '%s' % net.websafe(note) - else: return "" - - def addatts(self): - # add leading space for backward-compatibility - return " " + str(self.attrs) - -class AttributeList(dict): - """List of atributes of input. - - >>> a = AttributeList(type='text', name='x', value=20) - >>> a - - """ - def copy(self): - return AttributeList(self) - - def __str__(self): - return " ".join(['%s="%s"' % (k, net.websafe(v)) for k, v in self.items()]) - - def __repr__(self): - return '' % repr(str(self)) - -class Textbox(Input): - """Textbox input. - - >>> Textbox(name='foo', value='bar').render() - '' - >>> Textbox(name='foo', value=0).render() - '' - """ - def get_type(self): - return 'text' - -class Password(Input): - """Password input. - - >>> Password(name='password', value='secret').render() - '' - """ - - def get_type(self): - return 'password' - -class Textarea(Input): - """Textarea input. - - >>> Textarea(name='foo', value='bar').render() - '' - """ - def render(self): - attrs = self.attrs.copy() - attrs['name'] = self.name - value = net.websafe(self.value or '') - return '' % (attrs, value) - -class Dropdown(Input): - r"""Dropdown/select input. - - >>> Dropdown(name='foo', args=['a', 'b', 'c'], value='b').render() - '\n' - >>> Dropdown(name='foo', args=[('a', 'aa'), ('b', 'bb'), ('c', 'cc')], value='b').render() - '\n' - """ - def __init__(self, name, args, *validators, **attrs): - self.args = args - super(Dropdown, self).__init__(name, *validators, **attrs) - - def render(self): - attrs = self.attrs.copy() - attrs['name'] = self.name - - x = '\n' - return x - -class Radio(Input): - def __init__(self, name, args, *validators, **attrs): - self.args = args - super(Radio, self).__init__(name, *validators, **attrs) - - def render(self): - x = '' - for arg in self.args: - if isinstance(arg, (tuple, list)): - value, desc= arg - else: - value, desc = arg, arg - attrs = self.attrs.copy() - attrs['name'] = self.name - attrs['type'] = 'radio' - attrs['value'] = arg - if self.value == arg: - attrs['checked'] = 'checked' - x += ' %s' % (attrs, net.websafe(desc)) - x += '' - return x - -class Checkbox(Input): - """Checkbox input. - - >>> Checkbox('foo', value='bar', checked=True).render() - '' - >>> Checkbox('foo', value='bar').render() - '' - >>> c = Checkbox('foo', value='bar') - >>> c.validate('on') - True - >>> c.render() - '' - """ - def __init__(self, name, *validators, **attrs): - self.checked = attrs.pop('checked', False) - Input.__init__(self, name, *validators, **attrs) - - def get_default_id(self): - value = utils.safestr(self.value or "") - return self.name + '_' + value.replace(' ', '_') - - def render(self): - attrs = self.attrs.copy() - attrs['type'] = 'checkbox' - attrs['name'] = self.name - attrs['value'] = self.value - - if self.checked: - attrs['checked'] = 'checked' - return '' % attrs - - def set_value(self, value): - self.checked = bool(value) - - def get_value(self): - return self.checked - -class Button(Input): - """HTML Button. - - >>> Button("save").render() - '' - >>> Button("action", value="save", html="Save Changes").render() - '' - """ - def __init__(self, name, *validators, **attrs): - super(Button, self).__init__(name, *validators, **attrs) - self.description = "" - - def render(self): - attrs = self.attrs.copy() - attrs['name'] = self.name - if self.value is not None: - attrs['value'] = self.value - html = attrs.pop('html', None) or net.websafe(self.name) - return '' % (attrs, html) - -class Hidden(Input): - """Hidden Input. - - >>> Hidden(name='foo', value='bar').render() - '' - """ - def is_hidden(self): - return True - - def get_type(self): - return 'hidden' - -class File(Input): - """File input. - - >>> File(name='f').render() - '' - """ - def get_type(self): - return 'file' - -class Validator: - def __deepcopy__(self, memo): return copy.copy(self) - def __init__(self, msg, test, jstest=None): utils.autoassign(self, locals()) - def valid(self, value): - try: return self.test(value) - except: return False - -notnull = Validator("Required", bool) - -class regexp(Validator): - def __init__(self, rexp, msg): - self.rexp = re.compile(rexp) - self.msg = msg - - def valid(self, value): - return bool(self.rexp.match(value)) - -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/thirdparty/web/http.py b/thirdparty/web/http.py deleted file mode 100644 index 5476207314..0000000000 --- a/thirdparty/web/http.py +++ /dev/null @@ -1,150 +0,0 @@ -""" -HTTP Utilities -(from web.py) -""" - -__all__ = [ - "expires", "lastmodified", - "prefixurl", "modified", - "changequery", "url", - "profiler", -] - -import sys, os, threading, urllib, urlparse -try: import datetime -except ImportError: pass -import net, utils, webapi as web - -def prefixurl(base=''): - """ - Sorry, this function is really difficult to explain. - Maybe some other time. - """ - url = web.ctx.path.lstrip('/') - for i in xrange(url.count('/')): - base += '../' - if not base: - base = './' - return base - -def expires(delta): - """ - Outputs an `Expires` header for `delta` from now. - `delta` is a `timedelta` object or a number of seconds. - """ - if isinstance(delta, (int, long)): - delta = datetime.timedelta(seconds=delta) - date_obj = datetime.datetime.utcnow() + delta - web.header('Expires', net.httpdate(date_obj)) - -def lastmodified(date_obj): - """Outputs a `Last-Modified` header for `datetime`.""" - web.header('Last-Modified', net.httpdate(date_obj)) - -def modified(date=None, etag=None): - """ - Checks to see if the page has been modified since the version in the - requester's cache. - - When you publish pages, you can include `Last-Modified` and `ETag` - with the date the page was last modified and an opaque token for - the particular version, respectively. When readers reload the page, - the browser sends along the modification date and etag value for - the version it has in its cache. If the page hasn't changed, - the server can just return `304 Not Modified` and not have to - send the whole page again. - - This function takes the last-modified date `date` and the ETag `etag` - and checks the headers to see if they match. If they do, it returns - `True`, or otherwise it raises NotModified error. It also sets - `Last-Modified` and `ETag` output headers. - """ - try: - from __builtin__ import set - except ImportError: - # for python 2.3 - from sets import Set as set - - n = set([x.strip('" ') for x in web.ctx.env.get('HTTP_IF_NONE_MATCH', '').split(',')]) - m = net.parsehttpdate(web.ctx.env.get('HTTP_IF_MODIFIED_SINCE', '').split(';')[0]) - validate = False - if etag: - if '*' in n or etag in n: - validate = True - if date and m: - # we subtract a second because - # HTTP dates don't have sub-second precision - if date-datetime.timedelta(seconds=1) <= m: - validate = True - - if date: lastmodified(date) - if etag: web.header('ETag', '"' + etag + '"') - if validate: - raise web.notmodified() - else: - return True - -def urlencode(query, doseq=0): - """ - Same as urllib.urlencode, but supports unicode strings. - - >>> urlencode({'text':'foo bar'}) - 'text=foo+bar' - >>> urlencode({'x': [1, 2]}, doseq=True) - 'x=1&x=2' - """ - def convert(value, doseq=False): - if doseq and isinstance(value, list): - return [convert(v) for v in value] - else: - return utils.utf8(value) - - query = dict([(k, convert(v, doseq)) for k, v in query.items()]) - return urllib.urlencode(query, doseq=doseq) - -def changequery(query=None, **kw): - """ - Imagine you're at `/foo?a=1&b=2`. Then `changequery(a=3)` will return - `/foo?a=3&b=2` -- the same URL but with the arguments you requested - changed. - """ - if query is None: - query = web.rawinput(method='get') - for k, v in kw.iteritems(): - if v is None: - query.pop(k, None) - else: - query[k] = v - out = web.ctx.path - if query: - out += '?' + urlencode(query, doseq=True) - return out - -def url(path=None, **kw): - """ - Makes url by concatinating web.ctx.homepath and path and the - query string created using the arguments. - """ - if path is None: - path = web.ctx.path - if path.startswith("/"): - out = web.ctx.homepath + path - else: - out = path - - if kw: - out += '?' + urlencode(kw) - - return out - -def profiler(app): - """Outputs basic profiling information at the bottom of each response.""" - from utils import profile - def profile_internal(e, o): - out, result = profile(app)(e, o) - return list(out) + ['
' + net.websafe(result) + '
'] - return profile_internal - -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/thirdparty/web/httpserver.py b/thirdparty/web/httpserver.py deleted file mode 100644 index 1df71ebfec..0000000000 --- a/thirdparty/web/httpserver.py +++ /dev/null @@ -1,250 +0,0 @@ -__all__ = ["runsimple"] - -import sys, os -from SimpleHTTPServer import SimpleHTTPRequestHandler - -import webapi as web -import net -import utils - -def runbasic(func, server_address=("0.0.0.0", 8080)): - """ - Runs a simple HTTP server hosting WSGI app `func`. The directory `static/` - is hosted statically. - - Based on [WsgiServer][ws] from [Colin Stewart][cs]. - - [ws]: http://www.owlfish.com/software/wsgiutils/documentation/wsgi-server-api.html - [cs]: http://www.owlfish.com/ - """ - # Copyright (c) 2004 Colin Stewart (http://www.owlfish.com/) - # Modified somewhat for simplicity - # Used under the modified BSD license: - # http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 - - import SimpleHTTPServer, SocketServer, BaseHTTPServer, urlparse - import socket, errno - import traceback - - class WSGIHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): - def run_wsgi_app(self): - protocol, host, path, parameters, query, fragment = \ - urlparse.urlparse('http://dummyhost%s' % self.path) - - # we only use path, query - env = {'wsgi.version': (1, 0) - ,'wsgi.url_scheme': 'http' - ,'wsgi.input': self.rfile - ,'wsgi.errors': sys.stderr - ,'wsgi.multithread': 1 - ,'wsgi.multiprocess': 0 - ,'wsgi.run_once': 0 - ,'REQUEST_METHOD': self.command - ,'REQUEST_URI': self.path - ,'PATH_INFO': path - ,'QUERY_STRING': query - ,'CONTENT_TYPE': self.headers.get('Content-Type', '') - ,'CONTENT_LENGTH': self.headers.get('Content-Length', '') - ,'REMOTE_ADDR': self.client_address[0] - ,'SERVER_NAME': self.server.server_address[0] - ,'SERVER_PORT': str(self.server.server_address[1]) - ,'SERVER_PROTOCOL': self.request_version - } - - for http_header, http_value in self.headers.items(): - env ['HTTP_%s' % http_header.replace('-', '_').upper()] = \ - http_value - - # Setup the state - self.wsgi_sent_headers = 0 - self.wsgi_headers = [] - - try: - # We have there environment, now invoke the application - result = self.server.app(env, self.wsgi_start_response) - try: - try: - for data in result: - if data: - self.wsgi_write_data(data) - finally: - if hasattr(result, 'close'): - result.close() - except socket.error, socket_err: - # Catch common network errors and suppress them - if (socket_err.args[0] in \ - (errno.ECONNABORTED, errno.EPIPE)): - return - except socket.timeout, socket_timeout: - return - except: - print >> web.debug, traceback.format_exc(), - - if (not self.wsgi_sent_headers): - # We must write out something! - self.wsgi_write_data(" ") - return - - do_POST = run_wsgi_app - do_PUT = run_wsgi_app - do_DELETE = run_wsgi_app - - def do_GET(self): - if self.path.startswith('/static/'): - SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) - else: - self.run_wsgi_app() - - def wsgi_start_response(self, response_status, response_headers, - exc_info=None): - if (self.wsgi_sent_headers): - raise Exception \ - ("Headers already sent and start_response called again!") - # Should really take a copy to avoid changes in the application.... - self.wsgi_headers = (response_status, response_headers) - return self.wsgi_write_data - - def wsgi_write_data(self, data): - if (not self.wsgi_sent_headers): - status, headers = self.wsgi_headers - # Need to send header prior to data - status_code = status[:status.find(' ')] - status_msg = status[status.find(' ') + 1:] - self.send_response(int(status_code), status_msg) - for header, value in headers: - self.send_header(header, value) - self.end_headers() - self.wsgi_sent_headers = 1 - # Send the data - self.wfile.write(data) - - class WSGIServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): - def __init__(self, func, server_address): - BaseHTTPServer.HTTPServer.__init__(self, - server_address, - WSGIHandler) - self.app = func - self.serverShuttingDown = 0 - - print "http://%s:%d/" % server_address - WSGIServer(func, server_address).serve_forever() - -def runsimple(func, server_address=("0.0.0.0", 8080)): - """ - Runs [CherryPy][cp] WSGI server hosting WSGI app `func`. - The directory `static/` is hosted statically. - - [cp]: http://www.cherrypy.org - """ - func = StaticMiddleware(func) - func = LogMiddleware(func) - - server = WSGIServer(server_address, func) - - print "http://%s:%d/" % server_address - try: - server.start() - except KeyboardInterrupt: - server.stop() - -def WSGIServer(server_address, wsgi_app): - """Creates CherryPy WSGI server listening at `server_address` to serve `wsgi_app`. - This function can be overwritten to customize the webserver or use a different webserver. - """ - from wsgiserver import CherryPyWSGIServer - return CherryPyWSGIServer(server_address, wsgi_app, server_name="localhost") - -class StaticApp(SimpleHTTPRequestHandler): - """WSGI application for serving static files.""" - def __init__(self, environ, start_response): - self.headers = [] - self.environ = environ - self.start_response = start_response - - def send_response(self, status, msg=""): - self.status = str(status) + " " + msg - - def send_header(self, name, value): - self.headers.append((name, value)) - - def end_headers(self): - pass - - def log_message(*a): pass - - def __iter__(self): - environ = self.environ - - self.path = environ.get('PATH_INFO', '') - self.client_address = environ.get('REMOTE_ADDR','-'), \ - environ.get('REMOTE_PORT','-') - self.command = environ.get('REQUEST_METHOD', '-') - - from cStringIO import StringIO - self.wfile = StringIO() # for capturing error - - f = self.send_head() - self.start_response(self.status, self.headers) - - if f: - block_size = 16 * 1024 - while True: - buf = f.read(block_size) - if not buf: - break - yield buf - f.close() - else: - value = self.wfile.getvalue() - yield value - -class StaticMiddleware: - """WSGI middleware for serving static files.""" - def __init__(self, app, prefix='/static/'): - self.app = app - self.prefix = prefix - - def __call__(self, environ, start_response): - path = environ.get('PATH_INFO', '') - if path.startswith(self.prefix): - return StaticApp(environ, start_response) - else: - return self.app(environ, start_response) - -class LogMiddleware: - """WSGI middleware for logging the status.""" - def __init__(self, app): - self.app = app - self.format = '%s - - [%s] "%s %s %s" - %s' - - from BaseHTTPServer import BaseHTTPRequestHandler - import StringIO - f = StringIO.StringIO() - - class FakeSocket: - def makefile(self, *a): - return f - - # take log_date_time_string method from BaseHTTPRequestHandler - self.log_date_time_string = BaseHTTPRequestHandler(FakeSocket(), None, None).log_date_time_string - - def __call__(self, environ, start_response): - def xstart_response(status, response_headers, *args): - out = start_response(status, response_headers, *args) - self.log(status, environ) - return out - - return self.app(environ, xstart_response) - - def log(self, status, environ): - outfile = environ.get('wsgi.errors', web.debug) - req = environ.get('PATH_INFO', '_') - protocol = environ.get('ACTUAL_SERVER_PROTOCOL', '-') - method = environ.get('REQUEST_METHOD', '-') - host = "%s:%s" % (environ.get('REMOTE_ADDR','-'), - environ.get('REMOTE_PORT','-')) - - time = self.log_date_time_string() - - msg = self.format % (host, time, protocol, method, req, status) - print >> outfile, utils.safestr(msg) diff --git a/thirdparty/web/net.py b/thirdparty/web/net.py deleted file mode 100644 index 201ffb05f8..0000000000 --- a/thirdparty/web/net.py +++ /dev/null @@ -1,190 +0,0 @@ -""" -Network Utilities -(from web.py) -""" - -__all__ = [ - "validipaddr", "validipport", "validip", "validaddr", - "urlquote", - "httpdate", "parsehttpdate", - "htmlquote", "htmlunquote", "websafe", -] - -import urllib, time -try: import datetime -except ImportError: pass - -def validipaddr(address): - """ - Returns True if `address` is a valid IPv4 address. - - >>> validipaddr('192.168.1.1') - True - >>> validipaddr('192.168.1.800') - False - >>> validipaddr('192.168.1') - False - """ - try: - octets = address.split('.') - if len(octets) != 4: - return False - for x in octets: - if not (0 <= int(x) <= 255): - return False - except ValueError: - return False - return True - -def validipport(port): - """ - Returns True if `port` is a valid IPv4 port. - - >>> validipport('9000') - True - >>> validipport('foo') - False - >>> validipport('1000000') - False - """ - try: - if not (0 <= int(port) <= 65535): - return False - except ValueError: - return False - return True - -def validip(ip, defaultaddr="0.0.0.0", defaultport=8080): - """Returns `(ip_address, port)` from string `ip_addr_port`""" - addr = defaultaddr - port = defaultport - - ip = ip.split(":", 1) - if len(ip) == 1: - if not ip[0]: - pass - elif validipaddr(ip[0]): - addr = ip[0] - elif validipport(ip[0]): - port = int(ip[0]) - else: - raise ValueError, ':'.join(ip) + ' is not a valid IP address/port' - elif len(ip) == 2: - addr, port = ip - if not validipaddr(addr) and validipport(port): - raise ValueError, ':'.join(ip) + ' is not a valid IP address/port' - port = int(port) - else: - raise ValueError, ':'.join(ip) + ' is not a valid IP address/port' - return (addr, port) - -def validaddr(string_): - """ - Returns either (ip_address, port) or "/path/to/socket" from string_ - - >>> validaddr('/path/to/socket') - '/path/to/socket' - >>> validaddr('8000') - ('0.0.0.0', 8000) - >>> validaddr('127.0.0.1') - ('127.0.0.1', 8080) - >>> validaddr('127.0.0.1:8000') - ('127.0.0.1', 8000) - >>> validaddr('fff') - Traceback (most recent call last): - ... - ValueError: fff is not a valid IP address/port - """ - if '/' in string_: - return string_ - else: - return validip(string_) - -def urlquote(val): - """ - Quotes a string for use in a URL. - - >>> urlquote('://?f=1&j=1') - '%3A//%3Ff%3D1%26j%3D1' - >>> urlquote(None) - '' - >>> urlquote(u'\u203d') - '%E2%80%BD' - """ - if val is None: return '' - if not isinstance(val, unicode): val = str(val) - else: val = val.encode('utf-8') - return urllib.quote(val) - -def httpdate(date_obj): - """ - Formats a datetime object for use in HTTP headers. - - >>> import datetime - >>> httpdate(datetime.datetime(1970, 1, 1, 1, 1, 1)) - 'Thu, 01 Jan 1970 01:01:01 GMT' - """ - return date_obj.strftime("%a, %d %b %Y %H:%M:%S GMT") - -def parsehttpdate(string_): - """ - Parses an HTTP date into a datetime object. - - >>> parsehttpdate('Thu, 01 Jan 1970 01:01:01 GMT') - datetime.datetime(1970, 1, 1, 1, 1, 1) - """ - try: - t = time.strptime(string_, "%a, %d %b %Y %H:%M:%S %Z") - except ValueError: - return None - return datetime.datetime(*t[:6]) - -def htmlquote(text): - """ - Encodes `text` for raw use in HTML. - - >>> htmlquote("<'&\\">") - '<'&">' - """ - text = text.replace("&", "&") # Must be done first! - text = text.replace("<", "<") - text = text.replace(">", ">") - text = text.replace("'", "'") - text = text.replace('"', """) - return text - -def htmlunquote(text): - """ - Decodes `text` that's HTML quoted. - - >>> htmlunquote('<'&">') - '<\\'&">' - """ - text = text.replace(""", '"') - text = text.replace("'", "'") - text = text.replace(">", ">") - text = text.replace("<", "<") - text = text.replace("&", "&") # Must be done last! - return text - -def websafe(val): - """ - Converts `val` so that it's safe for use in UTF-8 HTML. - - >>> websafe("<'&\\">") - '<'&">' - >>> websafe(None) - '' - >>> websafe(u'\u203d') - '\\xe2\\x80\\xbd' - """ - if val is None: - return '' - if isinstance(val, unicode): - val = val.encode('utf-8') - val = str(val) - return htmlquote(val) - -if __name__ == "__main__": - import doctest - doctest.testmod() diff --git a/thirdparty/web/session.py b/thirdparty/web/session.py deleted file mode 100644 index 0a86e5701b..0000000000 --- a/thirdparty/web/session.py +++ /dev/null @@ -1,319 +0,0 @@ -""" -Session Management -(from web.py) -""" - -import os, time, datetime, random, base64 -try: - import cPickle as pickle -except ImportError: - import pickle -try: - import hashlib - sha1 = hashlib.sha1 -except ImportError: - import sha - sha1 = sha.new - -import utils -import webapi as web - -__all__ = [ - 'Session', 'SessionExpired', - 'Store', 'DiskStore', 'DBStore', -] - -web.config.session_parameters = utils.storage({ - 'cookie_name': 'webpy_session_id', - 'cookie_domain': None, - 'timeout': 86400, #24 * 60 * 60, # 24 hours in seconds - 'ignore_expiry': True, - 'ignore_change_ip': True, - 'secret_key': 'fLjUfxqXtfNoIldA0A0J', - 'expired_message': 'Session expired', -}) - -class SessionExpired(web.HTTPError): - def __init__(self, message): - web.HTTPError.__init__(self, '200 OK', {}, data=message) - -class Session(utils.ThreadedDict): - """Session management for web.py - """ - - def __init__(self, app, store, initializer=None): - self.__dict__['store'] = store - self.__dict__['_initializer'] = initializer - self.__dict__['_last_cleanup_time'] = 0 - self.__dict__['_config'] = utils.storage(web.config.session_parameters) - - if app: - app.add_processor(self._processor) - - def _processor(self, handler): - """Application processor to setup session for every request""" - self._cleanup() - self._load() - - try: - return handler() - finally: - self._save() - - def _load(self): - """Load the session from the store, by the id from cookie""" - cookie_name = self._config.cookie_name - cookie_domain = self._config.cookie_domain - self.session_id = web.cookies().get(cookie_name) - - # protection against session_id tampering - if self.session_id and not self._valid_session_id(self.session_id): - self.session_id = None - - self._check_expiry() - if self.session_id: - d = self.store[self.session_id] - self.update(d) - self._validate_ip() - - if not self.session_id: - self.session_id = self._generate_session_id() - - if self._initializer: - if isinstance(self._initializer, dict): - self.update(self._initializer) - elif hasattr(self._initializer, '__call__'): - self._initializer() - - self.ip = web.ctx.ip - - def _check_expiry(self): - # check for expiry - if self.session_id and self.session_id not in self.store: - if self._config.ignore_expiry: - self.session_id = None - else: - return self.expired() - - def _validate_ip(self): - # check for change of IP - if self.session_id and self.get('ip', None) != web.ctx.ip: - if not self._config.ignore_change_ip: - return self.expired() - - def _save(self): - cookie_name = self._config.cookie_name - cookie_domain = self._config.cookie_domain - if not self.get('_killed'): - web.setcookie(cookie_name, self.session_id, domain=cookie_domain) - self.store[self.session_id] = dict(self) - else: - web.setcookie(cookie_name, self.session_id, expires=-1, domain=cookie_domain) - - def _generate_session_id(self): - """Generate a random id for session""" - - while True: - rand = os.urandom(16) - now = time.time() - secret_key = self._config.secret_key - session_id = sha1("%s%s%s%s" %(rand, now, utils.safestr(web.ctx.ip), secret_key)) - session_id = session_id.hexdigest() - if session_id not in self.store: - break - return session_id - - def _valid_session_id(self, session_id): - rx = utils.re_compile('^[0-9a-fA-F]+$') - return rx.match(session_id) - - def _cleanup(self): - """Cleanup the stored sessions""" - current_time = time.time() - timeout = self._config.timeout - if current_time - self._last_cleanup_time > timeout: - self.store.cleanup(timeout) - self.__dict__['_last_cleanup_time'] = current_time - - def expired(self): - """Called when an expired session is atime""" - self._killed = True - self._save() - raise SessionExpired(self._config.expired_message) - - def kill(self): - """Kill the session, make it no longer available""" - del self.store[self.session_id] - self._killed = True - -class Store: - """Base class for session stores""" - - def __contains__(self, key): - raise NotImplementedError - - def __getitem__(self, key): - raise NotImplementedError - - def __setitem__(self, key, value): - raise NotImplementedError - - def cleanup(self, timeout): - """removes all the expired sessions""" - raise NotImplementedError - - def encode(self, session_dict): - """encodes session dict as a string""" - pickled = pickle.dumps(session_dict) - return base64.encodestring(pickled) - - def decode(self, session_data): - """decodes the data to get back the session dict """ - pickled = base64.decodestring(session_data) - return pickle.loads(pickled) - -class DiskStore(Store): - """ - Store for saving a session on disk. - - >>> import tempfile - >>> root = tempfile.mkdtemp() - >>> s = DiskStore(root) - >>> s['a'] = 'foo' - >>> s['a'] - 'foo' - >>> time.sleep(0.01) - >>> s.cleanup(0.01) - >>> s['a'] - Traceback (most recent call last): - ... - KeyError: 'a' - """ - def __init__(self, root): - # if the storage root doesn't exists, create it. - if not os.path.exists(root): - os.mkdir(root) - self.root = root - - def _get_path(self, key): - if os.path.sep in key: - raise ValueError, "Bad key: %s" % repr(key) - return os.path.join(self.root, key) - - def __contains__(self, key): - path = self._get_path(key) - return os.path.exists(path) - - def __getitem__(self, key): - path = self._get_path(key) - if os.path.exists(path): - pickled = open(path).read() - return self.decode(pickled) - else: - raise KeyError, key - - def __setitem__(self, key, value): - path = self._get_path(key) - pickled = self.encode(value) - try: - f = open(path, 'w') - try: - f.write(pickled) - finally: - f.close() - except IOError: - pass - - def __delitem__(self, key): - path = self._get_path(key) - if os.path.exists(path): - os.remove(path) - - def cleanup(self, timeout): - now = time.time() - for f in os.listdir(self.root): - path = self._get_path(f) - atime = os.stat(path).st_atime - if now - atime > timeout : - os.remove(path) - -class DBStore(Store): - """Store for saving a session in database - Needs a table with the following columns: - - session_id CHAR(128) UNIQUE NOT NULL, - atime DATETIME NOT NULL default current_timestamp, - data TEXT - """ - def __init__(self, db, table_name): - self.db = db - self.table = table_name - - def __contains__(self, key): - data = self.db.select(self.table, where="session_id=$key", vars=locals()) - return bool(list(data)) - - def __getitem__(self, key): - now = datetime.datetime.now() - try: - s = self.db.select(self.table, where="session_id=$key", vars=locals())[0] - self.db.update(self.table, where="session_id=$key", atime=now, vars=locals()) - except IndexError: - raise KeyError - else: - return self.decode(s.data) - - def __setitem__(self, key, value): - pickled = self.encode(value) - now = datetime.datetime.now() - if key in self: - self.db.update(self.table, where="session_id=$key", data=pickled, vars=locals()) - else: - self.db.insert(self.table, False, session_id=key, data=pickled ) - - def __delitem__(self, key): - self.db.delete(self.table, where="session_id=$key", vars=locals()) - - def cleanup(self, timeout): - timeout = datetime.timedelta(timeout/(24.0*60*60)) #timedelta takes numdays as arg - last_allowed_time = datetime.datetime.now() - timeout - self.db.delete(self.table, where="$last_allowed_time > atime", vars=locals()) - -class ShelfStore: - """Store for saving session using `shelve` module. - - import shelve - store = ShelfStore(shelve.open('session.shelf')) - - XXX: is shelve thread-safe? - """ - def __init__(self, shelf): - self.shelf = shelf - - def __contains__(self, key): - return key in self.shelf - - def __getitem__(self, key): - atime, v = self.shelf[key] - self[key] = v # update atime - return v - - def __setitem__(self, key, value): - self.shelf[key] = time.time(), value - - def __delitem__(self, key): - try: - del self.shelf[key] - except KeyError: - pass - - def cleanup(self, timeout): - now = time.time() - for k in self.shelf.keys(): - atime, v = self.shelf[k] - if now - atime > timeout : - del self[k] - -if __name__ == '__main__' : - import doctest - doctest.testmod() diff --git a/thirdparty/web/template.py b/thirdparty/web/template.py deleted file mode 100644 index f1175e9ad0..0000000000 --- a/thirdparty/web/template.py +++ /dev/null @@ -1,1471 +0,0 @@ -""" -simple, elegant templating -(part of web.py) - -Template design: - -Template string is split into tokens and the tokens are combined into nodes. -Parse tree is a nodelist. TextNode and ExpressionNode are simple nodes and -for-loop, if-loop etc are block nodes, which contain multiple child nodes. - -Each node can emit some python string. python string emitted by the -root node is validated for safeeval and executed using python in the given environment. - -Enough care is taken to make sure the generated code and the template has line to line match, -so that the error messages can point to exact line number in template. (It doesn't work in some cases still.) - -Grammar: - - template -> defwith sections - defwith -> '$def with (' arguments ')' | '' - sections -> section* - section -> block | assignment | line - - assignment -> '$ ' - line -> (text|expr)* - text -> - expr -> '$' pyexpr | '$(' pyexpr ')' | '${' pyexpr '}' - pyexpr -> -""" - -__all__ = [ - "Template", - "Render", "render", "frender", - "ParseError", "SecurityError", - "test" -] - -import tokenize -import os -import glob -import re - -from utils import storage, safeunicode, safestr, re_compile -from webapi import config -from net import websafe - -def splitline(text): - r""" - Splits the given text at newline. - - >>> splitline('foo\nbar') - ('foo\n', 'bar') - >>> splitline('foo') - ('foo', '') - >>> splitline('') - ('', '') - """ - index = text.find('\n') + 1 - if index: - return text[:index], text[index:] - else: - return text, '' - -class Parser: - """Parser Base. - """ - def __init__(self): - self.statement_nodes = STATEMENT_NODES - self.keywords = KEYWORDS - - def parse(self, text, name="