[Pkg-privacy-commits] [onionshare] 05/53: Various fixes

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 ac97ddf7d0a69cc44253af698c0fddea0fef7421
Author: jvoisin <julien.voisin at dustri.org>
Date:   Sat Jul 25 10:37:05 2015 +0200

    Various fixes
    
    - more pep8
    - add some forgotten deps in setup.py
---
 onionshare/helpers.py    |  2 ++
 onionshare/onionshare.py |  9 +++++----
 onionshare/socks.py      |  4 ++--
 onionshare/strings.py    | 16 ++++++++--------
 onionshare/web.py        |  8 ++++----
 setup.py                 |  2 +-
 6 files changed, 22 insertions(+), 19 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..b923331 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -17,7 +17,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import os, sys, subprocess, time, argparse, inspect, shutil, socket, threading, urllib2, httplib, tempfile
+import os, sys, subprocess, time, argparse, shutil, socket, threading, urllib2, httplib, tempfile
 import socks
 
 from stem.control import Controller
@@ -52,6 +52,7 @@ class OnionShare(object):
         self.port = None
         self.controller = None
         self.hidserv_dir = None
+        self.onion_host = None
 
         # debug mode
         if debug:
@@ -112,14 +113,14 @@ 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
                 print 'Got onion_host: {0:s}'.format(self.onion_host)
             else:
                 if p.poll() == -1:
-                    raise TailsError(o.stderr.read())
+                    raise TailsError(sys.stderr.read())
                 else:
                     raise TailsError(strings._("error_tails_unknown_root"))
 
@@ -227,7 +228,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..16b1b8c 100644
--- a/onionshare/socks.py
+++ b/onionshare/socks.py
@@ -198,8 +198,8 @@ class socksocket(socket.socket):
 
     default_proxy = None
 
-    def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
-        _orig_socket.__init__(self, family, type, proto, _sock)
+    def __init__(self, family=socket.AF_INET, socket_type=socket.SOCK_STREAM, proto=0, _sock=None):
+        _orig_socket.__init__(self, family, socket_type, proto, _sock)
         
         if self.default_proxy:
             self.proxy = self.default_proxy
diff --git a/onionshare/strings.py b/onionshare/strings.py
index fe4fc0e..daa0574 100644
--- a/onionshare/strings.py
+++ b/onionshare/strings.py
@@ -17,7 +17,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import json, locale, sys, os, inspect
+import json, locale, sys, os
 import helpers
 
 strings = {}
@@ -36,22 +36,22 @@ def load_strings(default="en"):
         locale_dir = os.path.join(os.path.dirname(helpers.get_onionshare_dir()), 'locale')
 
     # load all translations
-    translated = {}
+    translations = {}
     for filename in os.listdir(locale_dir):
         abs_filename = os.path.join(locale_dir, filename)
         lang, ext = os.path.splitext(filename)
         if abs_filename.endswith('.json'):
-            translated[lang] = json.loads(open(abs_filename).read())
+            translations[lang] = json.loads(open(abs_filename).read())
 
-    strings = translated[default]
+    strings = translations[default]
     lc, enc = locale.getdefaultlocale()
     if lc:
         lang = lc[:2]
-        if lang in translated:
+        if lang in translations:
             # if a string doesn't exist, fallback to English
-            for key in translated[default]:
-                if key in translated[lang]:
-                    strings[key] = translated[lang][key]
+            for key in translations[default]:
+                if key in translations[lang]:
+                    strings[key] = translations[lang][key]
 
 
 def translated(k, gui=False):
diff --git a/onionshare/web.py b/onionshare/web.py
index 059475a..3bfb504 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -17,7 +17,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import Queue, mimetypes, platform, os, sys, zipfile, urllib2
+import Queue, mimetypes, platform, os, sys, urllib2
 from flask import Flask, Response, request, render_template_string, abort
 
 import strings, helpers
@@ -70,10 +70,10 @@ REQUEST_CANCELED = 4
 q = Queue.Queue()
 
 
-def add_request(type, path, data=None):
+def add_request(request_type, path, data=None):
     global q
     q.put({
-        'type': type,
+        'type': request_type,
         'path': path,
         'data': data
     })
@@ -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/setup.py b/setup.py
index 159bc59..e447a1a 100644
--- a/setup.py
+++ b/setup.py
@@ -123,5 +123,5 @@ elif system == 'Darwin':
                     'PyQt4.QtSvg', 'PyQt4.QtXmlPatterns']
             }
         },
-        setup_requires=['py2app'],
+        setup_requires=['py2app', 'flask', 'stem'],
     )

-- 
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