[Pkg-privacy-commits] [onionshare] 04/53: Fix some codestyle issues according to pep8.

Ulrike Uhlig u-guest at moszumanska.debian.org
Wed Dec 30 00:20:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian
in repository onionshare.

commit 7446cee6551cc3bf1d6422969ae8dd416bfd32d4
Author: Lazlo Westerhof <github at lazlo.me>
Date:   Fri Jun 26 19:38:22 2015 +0200

    Fix some codestyle issues according to pep8.
---
 onionshare/helpers.py            |  2 ++
 onionshare/onionshare.py         |  4 ++--
 onionshare/socks.py              | 52 ++++++++++++++++++++--------------------
 onionshare/web.py                |  2 +-
 onionshare_gui/common.py         |  1 +
 onionshare_gui/onionshare_gui.py |  2 +-
 onionshare_gui/options.py        |  3 +--
 onionshare_gui/server_status.py  |  2 +-
 8 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 8c30c2e..05d69fe 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -40,6 +40,7 @@ if get_platform() == 'Darwin':
 else:
     osx_resources_dir = None
 
+
 def get_onionshare_dir():
     if get_platform() == 'Darwin':
         onionshare_dir = os.path.dirname(__file__)
@@ -47,6 +48,7 @@ def get_onionshare_dir():
         onionshare_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
     return onionshare_dir
 
+
 def get_html_path(filename):
     p = platform.system()
     if p == 'Darwin':
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index d29b09c..1a56d9b 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -112,7 +112,7 @@ class OnionShare(object):
                 args = ['/usr/bin/sudo', '--', '/usr/bin/onionshare']
             print "Executing: {0:s}".format(args+[str(self.port)])
             p = subprocess.Popen(args+[str(self.port)], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
-            stdout = p.stdout.read(22) # .onion URLs are 22 chars long
+            stdout = p.stdout.read(22)  # .onion URLs are 22 chars long
 
             if stdout:
                 self.onion_host = stdout
@@ -227,7 +227,7 @@ class OnionShare(object):
             except urllib2.HTTPError:  # Tails error
                 sys.stdout.write('{0:s}\n'.format(strings._('wait_for_hs_nope')))
                 sys.stdout.flush()
-            except httplib.BadStatusLine: # Tails (with bridge) error
+            except httplib.BadStatusLine:  # Tails (with bridge) error
                 sys.stdout.write('{0:s}\n'.format(strings._('wait_for_hs_nope')))
                 sys.stdout.flush()
             except KeyboardInterrupt:
diff --git a/onionshare/socks.py b/onionshare/socks.py
index cbfabd0..809a444 100644
--- a/onionshare/socks.py
+++ b/onionshare/socks.py
@@ -14,7 +14,7 @@ are permitted provided that the following conditions are met:
 3. Neither the name of Dan Haim nor the names of his contributors may be used
    to endorse or promote products derived from this software without specific
    prior written permission.
-   
+
 THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
@@ -40,7 +40,7 @@ mainly to merge bug fixes found in Sourceforge
 Modifications made by Anorov (https://github.com/Anorov)
 -Forked and renamed to PySocks
 -Fixed issue with HTTP proxy failure checking (same bug that was in the old ___recvall() method)
--Included SocksiPyHandler (sockshandler.py), to be used as a urllib2 handler, 
+-Included SocksiPyHandler (sockshandler.py), to be used as a urllib2 handler,
  courtesy of e000 (https://github.com/e000): https://gist.github.com/869791#file_socksipyhandler.py
 -Re-styled code to make it readable
     -Aliased PROXY_TYPE_SOCKS5 -> SOCKS5 etc.
@@ -136,7 +136,7 @@ def set_default_proxy(proxy_type=None, addr=None, port=None, rdns=True, username
     Sets a default proxy which all further socksocket objects will use,
     unless explicitly changed.
     """
-    socksocket.default_proxy = (proxy_type, addr.encode(), port, rdns, 
+    socksocket.default_proxy = (proxy_type, addr.encode(), port, rdns,
                                 username.encode() if username else None,
                                 password.encode() if password else None)
 
@@ -200,7 +200,7 @@ class socksocket(socket.socket):
 
     def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
         _orig_socket.__init__(self, family, type, proto, _sock)
-        
+
         if self.default_proxy:
             self.proxy = self.default_proxy
         else:
@@ -245,7 +245,7 @@ class socksocket(socket.socket):
         password -    Password to authenticate with to the server.
                        Only relevant when username is also provided.
         """
-        self.proxy = (proxy_type, addr.encode(), port, rdns, 
+        self.proxy = (proxy_type, addr.encode(), port, rdns,
                       username.encode() if username else None,
                       password.encode() if password else None)
 
@@ -292,18 +292,18 @@ class socksocket(socket.socket):
             # No username/password were entered, therefore we
             # only support connections with no authentication.
             self.sendall(b"\x05\x01\x00")
-        
+
         # We'll receive the server's response to determine which
         # method was selected
         chosen_auth = self._recvall(2)
 
         if chosen_auth[0:1] != b"\x05":
-            # Note: string[i:i+1] is used because indexing of a bytestring 
+            # Note: string[i:i+1] is used because indexing of a bytestring
             # via bytestring[i] yields an integer in Python 3
             raise GeneralProxyError("SOCKS5 proxy server sent invalid data")
-        
+
         # Check the chosen authentication method
-        
+
         if chosen_auth[1:2] == b"\x02":
             # Okay, we need to perform a basic username/password
             # authentication.
@@ -318,17 +318,17 @@ class socksocket(socket.socket):
             if auth_status[1:2] != b"\x00":
                 # Authentication failed
                 raise SOCKS5AuthError("SOCKS5 authentication failed")
-            
+
             # Otherwise, authentication succeeded
 
-        # No authentication is required if 0x00 
+        # No authentication is required if 0x00
         elif chosen_auth[1:2] != b"\x00":
             # Reaching here is always bad
             if chosen_auth[1:2] == b"\xFF":
                 raise SOCKS5AuthError("All offered SOCKS5 authentication methods were rejected")
             else:
                 raise GeneralProxyError("SOCKS5 proxy server sent invalid data")
-        
+
         # Now we can request the actual connection
         req = b"\x05\x01\x00"
         # If the given destination address is an IP address, we'll
@@ -349,7 +349,7 @@ class socksocket(socket.socket):
 
         req += struct.pack(">H", dest_port)
         self.sendall(req)
-        
+
         # Get the response
         resp = self._recvall(4)
         if resp[0:1] != b"\x05":
@@ -360,7 +360,7 @@ class socksocket(socket.socket):
             # Connection failed: server returned an error
             error = SOCKS5_ERRORS.get(status, "Unknown error")
             raise SOCKS5Error("{:#04x}: {}".format(status, error))
-        
+
         # Get the bound address/port
         if resp[3:4] == b"\x01":
             bound_addr = self._recvall(4)
@@ -369,7 +369,7 @@ class socksocket(socket.socket):
             bound_addr = self._recvall(ord(resp[4:5]))
         else:
             raise GeneralProxyError("SOCKS5 proxy server sent invalid data")
-        
+
         bound_port = struct.unpack(">H", self._recvall(2))[0]
         self.proxy_sockname = bound_addr, bound_port
         if addr_bytes:
@@ -394,15 +394,15 @@ class socksocket(socket.socket):
                 remote_resolve = True
             else:
                 addr_bytes = socket.inet_aton(socket.gethostbyname(dest_addr))
-        
+
         # Construct the request packet
         req = struct.pack(">BBH", 0x04, 0x01, dest_port) + addr_bytes
-        
+
         # The username parameter is considered userid for SOCKS4
         if username:
             req += username
         req += b"\x00"
-        
+
         # DNS name if remote resolving is required
         # NOTE: This is actually an extension to the SOCKS4 protocol
         # called SOCKS4A and may not be supported in all cases.
@@ -439,25 +439,25 @@ class socksocket(socket.socket):
         # If we need to resolve locally, we do this now
         addr = dest_addr if rdns else socket.gethostbyname(dest_addr)
 
-        self.sendall(b"CONNECT " + addr.encode() + b":" + str(dest_port).encode() + 
+        self.sendall(b"CONNECT " + addr.encode() + b":" + str(dest_port).encode() +
                      b" HTTP/1.1\r\n" + b"Host: " + dest_addr.encode() + b"\r\n\r\n")
-        
+
         # We just need the first line to check if the connection was successful
         fobj = self.makefile()
         status_line = fobj.readline()
         fobj.close()
-        
+
         if not status_line:
             raise GeneralProxyError("Connection closed unexpectedly")
-        
+
         try:
             proto, status_code, status_msg = status_line.split(" ", 2)
         except ValueError:
             raise GeneralProxyError("HTTP proxy server sent invalid response")
-            
+
         if not proto.startswith("HTTP/"):
             raise GeneralProxyError("Proxy server does not appear to be an HTTP proxy")
-        
+
         try:
             status_code = int(status_code)
         except ValueError:
@@ -475,7 +475,7 @@ class socksocket(socket.socket):
         self.proxy_peername = addr, dest_port
 
     def connect(self, dest_pair):
-        """        
+        """
         Connects to the specified destination through a proxy.
         Uses the same API as socket's connect().
         To select the proxy server, use set_proxy().
@@ -500,7 +500,7 @@ class socksocket(socket.socket):
         proxy_port = proxy_port or DEFAULT_PORTS.get(proxy_type)
         if not proxy_port:
             raise GeneralProxyError("Invalid proxy type")
-        
+
         try:
             # Initial connection to proxy server
             _orig_socket.connect(self, (proxy_addr, proxy_port))
diff --git a/onionshare/web.py b/onionshare/web.py
index 059475a..eb50eab 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -146,7 +146,7 @@ def download(slug_candidate):
     basename = os.path.basename(zip_filename)
 
     def generate():
-        chunk_size = 102400 # 100kb
+        chunk_size = 102400  # 100kb
 
         fp = open(zip_filename, 'rb')
         done = False
diff --git a/onionshare_gui/common.py b/onionshare_gui/common.py
index 60212f0..4ec83ea 100644
--- a/onionshare_gui/common.py
+++ b/onionshare_gui/common.py
@@ -20,6 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import os, sys, inspect, platform
 from onionshare import helpers
 
+
 def get_onionshare_gui_dir():
     p = helpers.get_platform()
     if p == 'Darwin':
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index b2642db..46757a0 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -26,7 +26,7 @@ import common
 try:
     import onionshare
 except ImportError:
-    sys.path.append(os.path.abspath(common.onionshare_gui_dir+"/.."))
+    sys.path.append(os.path.abspath(common.onionshare_gui_dir + "/.."))
     import onionshare
 from onionshare import strings, helpers, web
 
diff --git a/onionshare_gui/options.py b/onionshare_gui/options.py
index f7443b8..2fce2c9 100644
--- a/onionshare_gui/options.py
+++ b/onionshare_gui/options.py
@@ -28,7 +28,7 @@ class Options(QtGui.QHBoxLayout):
         super(Options, self).__init__()
 
         self.web = web
-        
+
         # close automatically
         self.close_automatically = QtGui.QCheckBox()
         if self.web.stay_open:
@@ -46,4 +46,3 @@ class Options(QtGui.QHBoxLayout):
             self.web.set_stay_open(False)
         else:
             self.web.set_stay_open(True)
-
diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py
index 579e2e8..02b4c58 100644
--- a/onionshare_gui/server_status.py
+++ b/onionshare_gui/server_status.py
@@ -144,7 +144,7 @@ class ServerStatus(QtGui.QVBoxLayout):
             GMEM_DDESHARE = 0x2000
             ctypes.windll.user32.OpenClipboard(None)
             ctypes.windll.user32.EmptyClipboard()
-            hcd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(url))+1)
+            hcd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(url)) + 1)
             pch_data = ctypes.windll.kernel32.GlobalLock(hcd)
             ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pch_data), bytes(url))
             ctypes.windll.kernel32.GlobalUnlock(hcd)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list