This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo-proxy.git


The following commit(s) were added to refs/heads/master by this push:
     new 435d845   #10 - Created instructions for using proxy with python (#11)
435d845 is described below

commit 435d845fdf98ed68198f2598feef97ee8235d161
Author: Mike Walch <mwa...@apache.org>
AuthorDate: Tue Nov 26 13:01:16 2019 -0500

     #10 - Created instructions for using proxy with python (#11)
---
 README.md                                          | 28 ++++++++++++-
 src/main/python/.gitignore                         |  1 +
 src/main/python/accumulo/.gitignore                |  1 +
 .../python/{ => accumulo}/AccumuloProxy-remote     |  0
 src/main/python/{ => accumulo}/AccumuloProxy.py    |  0
 src/main/python/{ => accumulo}/__init__.py         |  0
 src/main/python/{ => accumulo}/constants.py        |  0
 src/main/python/{ => accumulo}/ttypes.py           |  0
 src/main/python/example.py                         | 47 ++++++++++++++++++++++
 src/main/python/{__init__.py => setup.py}          | 11 ++++-
 10 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index ab23767..9740a2b 100644
--- a/README.md
+++ b/README.md
@@ -41,8 +41,35 @@ Thrift language binding).
     ./bin/accumulo-proxy -p conf/proxy.properties -c 
$ACCUMULO_HOME/conf/accumulo-client.properties
     ```
 
+# Build language specific bindings
+
+Bindings have been built in `src/main/` for Java, python, and ruby.
+
+Bindings for other languages can be built using the Thrift compiler. Follow 
the [Thrift tutorial]
+to install a Thrift compiler and use the following command to generate 
language bindings.
+
+```
+thrift -r --gen <language> <Thrift filename>
+```
+
+# Create an Accumulo client using Python
+
+Run the commands below to install the Python bindings and create an example 
client:
+
+```bash
+mkdir accumulo-client/
+cd accumulo-client/
+pipenv --python 2.7
+pipenv install -e /path/to/accumulo-proxy/src/main/python
+cp /path/to/accumulo-proxy/src/main/python/example.py .
+# Edit credentials if needed
+vim example.py
+pipenv run python2 example.py
+```
+
 [accumulo]: https://accumulo.apache.org
 [Thrift]: https://thrift.apache.org
+[Thrift tutorial]: https://thrift.apache.org/tutorial/
 [li]: https://img.shields.io/badge/license-ASL-blue.svg
 [ll]: https://www.apache.org/licenses/LICENSE-2.0
 [mi]: 
https://maven-badges.herokuapp.com/maven-central/org.apache.accumulo/accumulo-proxy/badge.svg
@@ -51,4 +78,3 @@ Thrift language binding).
 [jl]: https://www.javadoc.io/doc/org.apache.accumulo/accumulo-proxy
 [ti]: https://travis-ci.org/apache/accumulo-proxy.svg?branch=master
 [tl]: https://travis-ci.org/apache/accumulo-proxy
-
diff --git a/src/main/python/.gitignore b/src/main/python/.gitignore
new file mode 100644
index 0000000..c45695d
--- /dev/null
+++ b/src/main/python/.gitignore
@@ -0,0 +1 @@
+AccumuloProxy.egg-info/
diff --git a/src/main/python/accumulo/.gitignore 
b/src/main/python/accumulo/.gitignore
new file mode 100644
index 0000000..c45695d
--- /dev/null
+++ b/src/main/python/accumulo/.gitignore
@@ -0,0 +1 @@
+AccumuloProxy.egg-info/
diff --git a/src/main/python/AccumuloProxy-remote 
b/src/main/python/accumulo/AccumuloProxy-remote
similarity index 100%
rename from src/main/python/AccumuloProxy-remote
rename to src/main/python/accumulo/AccumuloProxy-remote
diff --git a/src/main/python/AccumuloProxy.py 
b/src/main/python/accumulo/AccumuloProxy.py
similarity index 100%
rename from src/main/python/AccumuloProxy.py
rename to src/main/python/accumulo/AccumuloProxy.py
diff --git a/src/main/python/__init__.py b/src/main/python/accumulo/__init__.py
similarity index 100%
copy from src/main/python/__init__.py
copy to src/main/python/accumulo/__init__.py
diff --git a/src/main/python/constants.py 
b/src/main/python/accumulo/constants.py
similarity index 100%
rename from src/main/python/constants.py
rename to src/main/python/accumulo/constants.py
diff --git a/src/main/python/ttypes.py b/src/main/python/accumulo/ttypes.py
similarity index 100%
rename from src/main/python/ttypes.py
rename to src/main/python/accumulo/ttypes.py
diff --git a/src/main/python/example.py b/src/main/python/example.py
new file mode 100644
index 0000000..cf04c74
--- /dev/null
+++ b/src/main/python/example.py
@@ -0,0 +1,47 @@
+# 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.
+
+#! /usr/bin/env python
+
+import sys
+
+from thrift import Thrift
+from thrift.transport import TSocket
+from thrift.transport import TTransport
+from thrift.protocol import TCompactProtocol
+
+from accumulo import AccumuloProxy
+from accumulo.ttypes import *
+
+transport = TSocket.TSocket('localhost', 42424)
+transport = TTransport.TFramedTransport(transport)
+protocol = TCompactProtocol.TCompactProtocol(transport)
+client = AccumuloProxy.Client(protocol)
+transport.open()
+
+login = client.login('root', {'password':'secret'})
+
+print client.listTables(login)
+
+testtable = "pythontest"
+if not client.tableExists(login, testtable):
+    client.createTable(login, testtable, True, TimeType.MILLIS)
+
+row1 = {'a':[ColumnUpdate('a','a',value='value1'), 
ColumnUpdate('b','b',value='value2')]}
+client.updateAndFlush(login, testtable, row1)
+
+cookie = client.createScanner(login, testtable, None)
+for entry in client.nextK(cookie, 10).results:
+   print entry
diff --git a/src/main/python/__init__.py b/src/main/python/setup.py
similarity index 78%
rename from src/main/python/__init__.py
rename to src/main/python/setup.py
index 0892e2f..a348d99 100644
--- a/src/main/python/__init__.py
+++ b/src/main/python/setup.py
@@ -12,4 +12,13 @@
 # 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__ = ['ttypes', 'constants', 'AccumuloProxy']
+
+from distutils.core import setup
+
+setup(
+    name='AccumuloProxy',
+    version='2.0.0',
+    packages=['accumulo',],
+    license='Apache License, Version 2.0',
+    long_description=open('../../../README.md').read(),
+)

Reply via email to