[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[bridgedb/master] Rename lib/bridgedb/Raptcha.py → lib/bridgedb/captcha.py.



commit 4709c1536a18cfe629ea196cb9eccdc2ddf92d79
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Feb 27 21:56:36 2014 +0000

    Rename lib/bridgedb/Raptcha.py â?? lib/bridgedb/captcha.py.
    
     * CHANGE imports of ``recaptcha.client.captcha`` to
       ``from recaptcha.client import captcha as recaptcha``, to avoid name
       conflict.
     * Update Sphinx source configuration and build files to reflect module
       name change.
---
 doc/sphinx/source/bridgedb.Raptcha.rst |    4 +--
 doc/sphinx/source/bridgedb.rst         |    2 +-
 doc/sphinx/source/conf.py              |    2 +-
 lib/bridgedb/HTTPServer.py             |    6 ++--
 lib/bridgedb/Raptcha.py                |   51 -------------------------------
 lib/bridgedb/captcha.py                |   52 ++++++++++++++++++++++++++++++++
 6 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/doc/sphinx/source/bridgedb.Raptcha.rst b/doc/sphinx/source/bridgedb.Raptcha.rst
index 374286f..633fa61 100644
--- a/doc/sphinx/source/bridgedb.Raptcha.rst
+++ b/doc/sphinx/source/bridgedb.Raptcha.rst
@@ -1,7 +1,7 @@
-bridgedb.Raptcha
+bridgedb.captcha
 ----------------
 
-.. automodule:: bridgedb.Raptcha
+.. automodule:: bridgedb.captcha
     :members:
     :undoc-members:
     :private-members:
diff --git a/doc/sphinx/source/bridgedb.rst b/doc/sphinx/source/bridgedb.rst
index afb7a0c..38dc9a2 100644
--- a/doc/sphinx/source/bridgedb.rst
+++ b/doc/sphinx/source/bridgedb.rst
@@ -7,6 +7,7 @@ bridgedb
 
     bridgedb.Bridges
     bridgedb.Bucket
+    bridgedb.captcha
     bridgedb.crypto
     bridgedb.Dist
     bridgedb.EmailServer
@@ -16,7 +17,6 @@ bridgedb
     bridgedb.Main
     bridgedb.parse
     bridgedb.persistent
-    bridgedb.Raptcha
     bridgedb.runner
     bridgedb.Stability
     bridgedb.Storage
diff --git a/doc/sphinx/source/conf.py b/doc/sphinx/source/conf.py
index eab7673..de44db4 100644
--- a/doc/sphinx/source/conf.py
+++ b/doc/sphinx/source/conf.py
@@ -27,6 +27,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(
 
 
 import bridgedb
+import bridgedb.captcha
 import bridgedb.Bridges
 import bridgedb.Bucket
 import bridgedb.crypto
@@ -37,7 +38,6 @@ import bridgedb.HTTPServer
 import bridgedb.I18n
 import bridgedb.Main
 import bridgedb.persistent
-import bridgedb.Raptcha
 import bridgedb.runner
 import bridgedb.Stability
 import bridgedb.Storage
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index b679ff5..175fd24 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -26,8 +26,8 @@ import bridgedb.Dist
 import bridgedb.I18n as I18n
 import bridgedb.Util as Util
 
-from recaptcha.client import captcha
-from bridgedb.Raptcha import Raptcha
+from recaptcha.client import captcha as recaptcha
+from bridgedb.captcha import Raptcha
 from bridgedb.Filters import filterBridgesByIP6, filterBridgesByIP4
 from bridgedb.Filters import filterBridgesByTransport
 from bridgedb.Filters import filterBridgesByNotBlockedIn
@@ -191,7 +191,7 @@ class CaptchaProtectedResource(twisted.web.resource.Resource):
             remote_ip = '%d.%d.%d.%d' % (randint(1,255),randint(1,255),
                                          randint(1,255),randint(1,255))
 
-        recaptcha_response = captcha.submit(challenge, response,
+        recaptcha_response = recaptcha.submit(challenge, response,
                                             self.recaptchaPrivKey, remote_ip)
         logging.debug("Captcha from client with masked IP %r. Parameters:\n%r"
                       % (remote_ip, request.args))
diff --git a/lib/bridgedb/Raptcha.py b/lib/bridgedb/Raptcha.py
deleted file mode 100644
index 9a35b08..0000000
--- a/lib/bridgedb/Raptcha.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- encoding: utf-8 -*-
-#_____________________________________________________________________________
-#
-# This file is part of BridgeDB, a Tor bridge distribution system.
-#
-# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@xxxxxxxxxxxxxx>
-#           Aaron Gibson   0x2C4B239DD876C9F6 <aagbsn@xxxxxxxxxxxxxx>
-#           Nick Mathewson 0x21194EBB165733EA <nickm@xxxxxxxxxxxxxx>
-#           please also see AUTHORS file
-# :copyright: (c) 2007-2014, The Tor Project, Inc.
-#             (c) 2007-2014, all entities within the AUTHORS file
-#             (c) 2014, Isis Lovecruft
-# :license: see LICENSE for licensing information
-#_____________________________________________________________________________
-
-"""
-This module wraps the recaptcha api and proxies requests to protect privacy.
-"""
-import recaptcha.client.captcha as captcha
-from BeautifulSoup import BeautifulSoup
-import urllib2
-
-class Raptcha():
-    """ A recaptcha captcha and method to request them """
-
-    def __init__(self, pubkey=None, privkey=None):
-        self.pubkey = pubkey
-        self.privkey = privkey
-        self.image = None
-        self.challenge = None
-
-    def get(self):
-        """ gets a fresh captcha """
-
-        if (self.pubkey == '') or (self.privkey == ''):
-            raise RaptchaKeyError
-        urlbase = captcha.API_SERVER
-        form = "/noscript?k=%s" % self.pubkey
-
-        # extract and store image from captcha
-        html = urllib2.urlopen(urlbase+form).read()
-        soup = BeautifulSoup(html)
-        imgurl = urlbase+"/"+ soup.find('img')['src']
-        self.challenge = str(soup.find('input', {'name' : 'recaptcha_challenge_field'})['value'])
-        self.image = urllib2.urlopen(imgurl).read()
-
-class RaptchaKeyError(Exception):
-    """ Exception raised when recaptcha API keys are not supplied"""
-    def __init__(self):
-        msg = 'You must supply recaptcha API keys'
-        Exception.__init__(self, msg)
diff --git a/lib/bridgedb/captcha.py b/lib/bridgedb/captcha.py
new file mode 100644
index 0000000..9936343
--- /dev/null
+++ b/lib/bridgedb/captcha.py
@@ -0,0 +1,52 @@
+# -*- encoding: utf-8 -*-
+#_____________________________________________________________________________
+#
+# This file is part of BridgeDB, a Tor bridge distribution system.
+#
+# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@xxxxxxxxxxxxxx>
+#           Aaron Gibson   0x2C4B239DD876C9F6 <aagbsn@xxxxxxxxxxxxxx>
+#           Nick Mathewson 0x21194EBB165733EA <nickm@xxxxxxxxxxxxxx>
+#           please also see AUTHORS file
+# :copyright: (c) 2007-2014, The Tor Project, Inc.
+#             (c) 2007-2014, all entities within the AUTHORS file
+#             (c) 2014, Isis Lovecruft
+# :license: see LICENSE for licensing information
+#_____________________________________________________________________________
+
+"""
+This module wraps the recaptcha api and proxies requests to protect privacy.
+"""
+
+from recaptcha.client import captcha as recaptcha
+from BeautifulSoup import BeautifulSoup
+import urllib2
+
+class Raptcha():
+    """ A recaptcha captcha and method to request them """
+
+    def __init__(self, pubkey=None, privkey=None):
+        self.pubkey = pubkey
+        self.privkey = privkey
+        self.image = None
+        self.challenge = None
+
+    def get(self):
+        """ gets a fresh captcha """
+
+        if (self.pubkey == '') or (self.privkey == ''):
+            raise RaptchaKeyError
+        urlbase = recaptcha.API_SERVER
+        form = "/noscript?k=%s" % self.pubkey
+
+        # extract and store image from captcha
+        html = urllib2.urlopen(urlbase+form).read()
+        soup = BeautifulSoup(html)
+        imgurl = urlbase+"/"+ soup.find('img')['src']
+        self.challenge = str(soup.find('input', {'name' : 'recaptcha_challenge_field'})['value'])
+        self.image = urllib2.urlopen(imgurl).read()
+
+class RaptchaKeyError(Exception):
+    """ Exception raised when recaptcha API keys are not supplied"""
+    def __init__(self):
+        msg = 'You must supply recaptcha API keys'
+        Exception.__init__(self, msg)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits