summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2018-02-19 18:02:51 -0800
committerMicah Lee <micah@micahflee.com>2018-02-19 18:02:51 -0800
commit3d1c0eabc445323f686fd0b6f95ea811dc28d0c5 (patch)
tree80c779dd2d659435b41da7bd5aff4aa317d56194
parentcb69ae89fc80c87e776bcb41c65d176d64f4f1a1 (diff)
parent760661c9c197620ba24751a3e88c4700c89a44ca (diff)
downloadonionshare-3d1c0eabc445323f686fd0b6f95ea811dc28d0c5.tar.gz
onionshare-3d1c0eabc445323f686fd0b6f95ea811dc28d0c5.zip
Merge branch 'develop' into mig5-info_widgets_download_info
-rw-r--r--.travis.yml7
-rw-r--r--install/onionshare.desktop2
-rw-r--r--install/scripts/onionshare-nautilus.py2
-rw-r--r--onionshare/common.py11
-rw-r--r--onionshare/onion.py6
-rw-r--r--onionshare/web.py4
-rw-r--r--onionshare_gui/__init__.py4
-rw-r--r--setup.py22
8 files changed, 36 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml
index 6d324010..9010e77a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,12 @@ python:
- "nightly"
# command to install dependencies
install:
- - pip install Flask==0.12 stem==1.5.4 pytest-cov coveralls
+ - pip install Flask==0.12 stem==1.5.4 pytest-cov coveralls flake8
+before_script:
+ # stop the build if there are Python syntax errors or undefined names
+ - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+ - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# command to run tests
script: pytest --cov=onionshare test/
after_success:
diff --git a/install/onionshare.desktop b/install/onionshare.desktop
index 256a7b50..fbac3660 100644
--- a/install/onionshare.desktop
+++ b/install/onionshare.desktop
@@ -1,9 +1,11 @@
[Desktop Entry]
Name=OnionShare
Comment=Share a file securely and anonymously over Tor
+Comment[da]=Del en fil sikkert og anonymt over Tor
Exec=/usr/bin/onionshare-gui
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/onionshare80.xpm
Categories=Network;
Keywords=tor;anonymity;privacy;onion service;file sharing;file hosting;
+Keywords[da]=tor;anonymitet;privatliv;onion-tjeneste;fildeling;filhosting;
diff --git a/install/scripts/onionshare-nautilus.py b/install/scripts/onionshare-nautilus.py
index 6674dd18..ed50fb23 100644
--- a/install/scripts/onionshare-nautilus.py
+++ b/install/scripts/onionshare-nautilus.py
@@ -64,7 +64,7 @@ class OnionShareExtension(GObject.GObject, Nautilus.MenuProvider):
"""
def url2path(self,url):
- file_uri = url.get_activation_uri()
+ file_uri = url.get_activation_uri()
arg_uri = file_uri[7:]
path = urllib.url2pathname(arg_uri)
return path
diff --git a/onionshare/common.py b/onionshare/common.py
index 25b901ee..79d62ca9 100644
--- a/onionshare/common.py
+++ b/onionshare/common.py
@@ -23,6 +23,7 @@ import inspect
import os
import platform
import random
+import re
import socket
import sys
import tempfile
@@ -56,8 +57,10 @@ def get_platform():
"""
Returns the platform OnionShare is running on.
"""
- return platform.system()
-
+ plat = platform.system()
+ if re.match('^.*BSD$', plat):
+ plat = 'BSD'
+ return plat
def get_resource_path(filename):
"""
@@ -73,7 +76,7 @@ def get_resource_path(filename):
# While running tests during stdeb bdist_deb, look 3 directories up for the share folder
prefix = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(prefix)))), 'share')
- elif p == 'Linux':
+ elif p == 'BSD' or p == 'Linux':
# Assume OnionShare is installed systemwide in Linux, since we're not running in dev mode
prefix = os.path.join(sys.prefix, 'share/onionshare')
@@ -107,7 +110,7 @@ def get_tor_paths():
tor_geo_ip_file_path = os.path.join(base_path, 'Resources', 'Tor', 'geoip')
tor_geo_ipv6_file_path = os.path.join(base_path, 'Resources', 'Tor', 'geoip6')
obfs4proxy_file_path = os.path.join(base_path, 'Resources', 'Tor', 'obfs4proxy')
- elif p == 'OpenBSD' or p == 'FreeBSD':
+ elif p == 'BSD':
tor_path = '/usr/local/bin/tor'
tor_geo_ip_file_path = '/usr/local/share/tor/geoip'
tor_geo_ipv6_file_path = '/usr/local/share/tor/geoip6'
diff --git a/onionshare/onion.py b/onionshare/onion.py
index 668de051..41e44781 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -131,7 +131,7 @@ class Onion(object):
self.stealth = False
self.service_id = None
- self.system = platform.system()
+ self.system = common.get_platform()
# Is bundled tor supported?
if (self.system == 'Windows' or self.system == 'Darwin') and getattr(sys, 'onionshare_dev_mode', False):
@@ -183,7 +183,7 @@ class Onion(object):
raise OSError(strings._('no_available_port'))
self.tor_torrc = os.path.join(self.tor_data_directory.name, 'torrc')
else:
- # Linux and Mac can use unix sockets
+ # Linux, Mac and BSD can use unix sockets
with open(common.get_resource_path('torrc_template')) as f:
torrc_template = f.read()
self.tor_control_port = None
@@ -318,7 +318,7 @@ class Onion(object):
# guessing the socket file name next
if not found_tor:
try:
- if self.system == 'Linux':
+ if self.system == 'Linux' or self.system == 'BSD':
socket_file_path = '/run/user/{}/Tor/control.socket'.format(os.geteuid())
elif self.system == 'Darwin':
socket_file_path = '/run/user/{}/Tor/control.socket'.format(os.geteuid())
diff --git a/onionshare/web.py b/onionshare/web.py
index 0fedb29b..d16ca251 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -315,12 +315,14 @@ def download(slug_candidate):
percent = (1.0 * downloaded_bytes / zip_filesize) * 100
# only output to stdout if running onionshare in CLI mode, or if using Linux (#203, #304)
- if not gui_mode or common.get_platform() == 'Linux':
+ plat = common.get_platform()
+ if not gui_mode or plat == 'Linux' or plat == 'BSD':
sys.stdout.write(
"\r{0:s}, {1:.2f}% ".format(common.human_readable_filesize(downloaded_bytes), percent))
sys.stdout.flush()
add_request(REQUEST_PROGRESS, path, {'id': download_id, 'bytes': downloaded_bytes})
+ done = False
except:
# looks like the download was canceled
done = True
diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py
index 14c76617..24e627bb 100644
--- a/onionshare_gui/__init__.py
+++ b/onionshare_gui/__init__.py
@@ -35,8 +35,8 @@ class Application(QtWidgets.QApplication):
and the quick keyboard shortcut.
"""
def __init__(self):
- system = platform.system()
- if system == 'Linux':
+ system = common.get_platform()
+ if system == 'Linux' or system == 'BSD':
self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
QtWidgets.QApplication.__init__(self, sys.argv)
self.installEventFilter(self)
diff --git a/setup.py b/setup.py
index dcbe42fb..23e1ea17 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,17 @@ author_email = 'micah@micahflee.com'
url = 'https://github.com/micahflee/onionshare'
license = 'GPL v3'
keywords = 'onion, share, onionshare, tor, anonymous, web server'
+data_files=[
+ (os.path.join(sys.prefix, 'share/applications'), ['install/onionshare.desktop']),
+ (os.path.join(sys.prefix, 'share/appdata'), ['install/onionshare.appdata.xml']),
+ (os.path.join(sys.prefix, 'share/pixmaps'), ['install/onionshare80.xpm']),
+ (os.path.join(sys.prefix, 'share/onionshare'), file_list('share')),
+ (os.path.join(sys.prefix, 'share/onionshare/images'), file_list('share/images')),
+ (os.path.join(sys.prefix, 'share/onionshare/locale'), file_list('share/locale')),
+ (os.path.join(sys.prefix, 'share/onionshare/html'), file_list('share/html')),
+ ]
+if platform.system() != 'OpenBSD':
+ data_files.append(('/usr/share/nautilus-python/extensions/', ['install/scripts/onionshare-nautilus.py']))
setup(
name='onionshare', version=version,
@@ -54,14 +65,5 @@ setup(
packages=['onionshare', 'onionshare_gui'],
include_package_data=True,
scripts=['install/scripts/onionshare', 'install/scripts/onionshare-gui'],
- data_files=[
- (os.path.join(sys.prefix, 'share/applications'), ['install/onionshare.desktop']),
- (os.path.join(sys.prefix, 'share/appdata'), ['install/onionshare.appdata.xml']),
- (os.path.join(sys.prefix, 'share/pixmaps'), ['install/onionshare80.xpm']),
- (os.path.join(sys.prefix, 'share/onionshare'), file_list('share')),
- (os.path.join(sys.prefix, 'share/onionshare/images'), file_list('share/images')),
- (os.path.join(sys.prefix, 'share/onionshare/locale'), file_list('share/locale')),
- (os.path.join(sys.prefix, 'share/onionshare/html'), file_list('share/html')),
- ('/usr/share/nautilus-python/extensions/', ['install/scripts/onionshare-nautilus.py'])
- ]
+ data_files=data_files
)