From 61240bf8edb91ea85e17d8a2f4a9b44bbccf4b9c Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 15 May 2013 15:05:41 +0200 Subject: [PATCH 1/4] these samples do not work with 0.9 --- Python/requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Python/requirements.txt diff --git a/Python/requirements.txt b/Python/requirements.txt new file mode 100644 index 0000000..43cec05 --- /dev/null +++ b/Python/requirements.txt @@ -0,0 +1,6 @@ +blessings==1.5 +couchbase==0.8.2 +requests==1.1.0 +unittest2==0.5.1 +uuid==1.30 +wsgiref==0.1.2 From 3ffc1d7210ce32f01f2c33448092d814268664ac Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 15 May 2013 15:15:25 +0200 Subject: [PATCH 2/4] and blessings 1.5 has an empty __init__.py, so 1.4 --- Python/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/requirements.txt b/Python/requirements.txt index 43cec05..91a8690 100644 --- a/Python/requirements.txt +++ b/Python/requirements.txt @@ -1,4 +1,4 @@ -blessings==1.5 +blessings==1.4 couchbase==0.8.2 requests==1.1.0 unittest2==0.5.1 From 17adfd6be1c8cf19dbbe59ce7ff0a275f2d8bfa8 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 15 May 2013 15:15:43 +0200 Subject: [PATCH 3/4] allow us to config the examples --- Python/01_connect.py | 14 ++++++++++---- Python/secret.py | 13 +++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Python/secret.py diff --git a/Python/01_connect.py b/Python/01_connect.py index 73d8bc7..a049db2 100644 --- a/Python/01_connect.py +++ b/Python/01_connect.py @@ -1,11 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import os +import os import inspect + from couchbase.client import Couchbase + from blessings import Terminal +import secret + t = Terminal() os.system('clear') @@ -16,7 +20,8 @@ # establish connection -couchbase = Couchbase("127.0.0.1:8091", "default", "") +couchbase = Couchbase(secret.HOSTPORT, + username=secret.USERNAME, password=secret.PASSWORD) # set bucket object cb = couchbase["default"] @@ -24,10 +29,11 @@ print couchbase.servers # establish connection to beer-sample -couchbase = Couchbase("127.0.0.1:8091", "beer-sample", "") +couchbase = Couchbase(secret.HOSTPORT, + username=secret.USERNAME, password=secret.PASSWORD) # set bucket instance beers = couchbase["beer-sample"] print couchbase.servers -print \ No newline at end of file +print diff --git a/Python/secret.py b/Python/secret.py new file mode 100644 index 0000000..cd74375 --- /dev/null +++ b/Python/secret.py @@ -0,0 +1,13 @@ +# -*- Mode: Python -*- +# vi:si:et:sw=4:sts=4:ts=4 + +# customize these variables for your deployment in your local.py + +HOSTPORT = 'localhost:8081' +USERNAME = 'default' +PASSWORD = '' + +try: + from local import * +except: + pass From fc5a40e008b409c54fcb602cf5ab5a245246d13f Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 15 May 2013 15:21:54 +0200 Subject: [PATCH 4/4] update all examples --- Python/01_connect.py | 1 - Python/02_storage.py | 8 ++++++-- Python/03_storage_json.py | 13 ++++++++----- Python/04_retrieve.py | 13 ++++++++----- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Python/01_connect.py b/Python/01_connect.py index a049db2..608a880 100644 --- a/Python/01_connect.py +++ b/Python/01_connect.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import os -import inspect from couchbase.client import Couchbase diff --git a/Python/02_storage.py b/Python/02_storage.py index 814e305..c502599 100644 --- a/Python/02_storage.py +++ b/Python/02_storage.py @@ -2,10 +2,13 @@ # -*- coding: utf-8 -*- # sudo pip install blessings (for color terminal output) -import os +import os + from couchbase.client import Couchbase from blessings import Terminal +import secret + t = Terminal() os.system('clear') @@ -15,7 +18,8 @@ print # establish connection -couchbase = Couchbase("127.0.0.1:8091", "default", "") +couchbase = Couchbase(secret.HOSTPORT, + username=secret.USERNAME, password=secret.PASSWORD) # connect to default bucket cb = couchbase["default"] diff --git a/Python/03_storage_json.py b/Python/03_storage_json.py index a7c7eb1..2c30b09 100644 --- a/Python/03_storage_json.py +++ b/Python/03_storage_json.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import os +import os +import json + from couchbase.client import Couchbase from blessings import Terminal -import json -import hashlib + +import secret t = Terminal() @@ -16,7 +18,8 @@ print # establish connection -couchbase = Couchbase("127.0.0.1:8091", "default", "") +couchbase = Couchbase(secret.HOSTPORT, + username=secret.USERNAME, password=secret.PASSWORD) # connect to default bucket cb = couchbase["default"] @@ -69,4 +72,4 @@ print print t.bold_red("--------------------------------------------------------------------------") -print \ No newline at end of file +print diff --git a/Python/04_retrieve.py b/Python/04_retrieve.py index 5ff4b97..ab4bf73 100644 --- a/Python/04_retrieve.py +++ b/Python/04_retrieve.py @@ -1,14 +1,17 @@ #!/usr/bin/env python # -*- coding" utf-8 -*- -import os +import os +import json + from couchbase.client import Couchbase from blessings import Terminal -import json -import hashlib + +import secret # establish connection -couchbase = Couchbase("127.0.0.1:8091", "default", "") +couchbase = Couchbase(secret.HOSTPORT, + username=secret.USERNAME, password=secret.PASSWORD) # connect to default bucket cb = couchbase["default"] @@ -112,4 +115,4 @@ def parse_json( val ): #print -print t.bold_red("--------------------------------------------------------------------------") \ No newline at end of file +print t.bold_red("--------------------------------------------------------------------------")