[Pkg-anonymity-tools] [onionshare] 48/57: moving platform-specific scripts into install folder, and making onionshare CLI work in OSX (#132)

Ulrike Uhlig u-guest at moszumanska.debian.org
Tue May 19 18:18:57 UTC 2015


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

u-guest pushed a commit to annotated tag 0.7
in repository onionshare.

commit 2ea0c6aef38252bf4a1e4576d3116e6fa1ff88d7
Author: Micah Lee <micah at micahflee.com>
Date:   Fri May 15 18:52:20 2015 -0700

    moving platform-specific scripts into install folder, and making onionshare CLI work in OSX (#132)
---
 README.md                                     |  8 ++++++++
 {bin => install/linux_scripts}/onionshare     |  0
 {bin => install/linux_scripts}/onionshare-gui |  0
 {bin => install/osx_scripts}/onionshare       | 12 ++++--------
 {bin => install/osx_scripts}/onionshare-gui   | 10 +---------
 onionshare/helpers.py                         |  8 +++++---
 setup.py                                      |  7 ++++---
 7 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index eb22137..8c0dd45 100644
--- a/README.md
+++ b/README.md
@@ -33,3 +33,11 @@ Open OnionShare and drag and drop files and folders you wish to share, and start
 Send this URL to the person you're trying to send the files to. If the files you're sending aren't secret, you can use normal means of sending the URL: emailing it, posting it to Facebook or Twitter, etc. If you're trying to send secret files then it's important to send this URL securely. I recommend you use [Off-the-Record encrypted chat](https://pressfreedomfoundation.org/encryption-works#otr) to send the URL.
 
 The person who is receiving the files doesn't need OnionShare. All they need is to open the URL you send them in Tor Browser to be able to download the file.
+
+## Using Command Line in Mac OS X
+
+If you'd like to use the command-line version of OnionShare in Mac OS X, after installing open a terminal and type:
+
+`ln -s /Applications/OnionShare.app/Contents/Resources/onionshare /usr/local/bin/onionshare`
+
+From that point on you can just call `onionshare`, like: `onionshare --help`
diff --git a/bin/onionshare b/install/linux_scripts/onionshare
similarity index 100%
copy from bin/onionshare
copy to install/linux_scripts/onionshare
diff --git a/bin/onionshare-gui b/install/linux_scripts/onionshare-gui
similarity index 100%
copy from bin/onionshare-gui
copy to install/linux_scripts/onionshare-gui
diff --git a/bin/onionshare b/install/osx_scripts/onionshare
similarity index 76%
rename from bin/onionshare
rename to install/osx_scripts/onionshare
index fadd8be..db3f6bc 100755
--- a/bin/onionshare
+++ b/install/osx_scripts/onionshare
@@ -18,12 +18,8 @@ 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 sys, os
-
-try:
-    import onionshare
-except ImportError:
-    sys.path.append(os.path.abspath(os.path.dirname(__file__)+'/..'))
-    import onionshare
-
+import zipimport, os, inspect
+cwd = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe()))))
+zi = zipimport.zipimporter(cwd+'/lib/python2.7/site-packages.zip')
+onionshare = zi.load_module('onionshare')
 onionshare.main()
diff --git a/bin/onionshare-gui b/install/osx_scripts/onionshare-gui
similarity index 80%
rename from bin/onionshare-gui
rename to install/osx_scripts/onionshare-gui
index f0b9955..8725fa6 100755
--- a/bin/onionshare-gui
+++ b/install/osx_scripts/onionshare-gui
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 """
 OnionShare | https://onionshare.org/
@@ -18,12 +17,5 @@ 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 sys, os
-
-try:
-    import onionshare_gui
-except ImportError:
-    sys.path.append(os.path.abspath(os.path.dirname(__file__)+'/..'))
-    import onionshare_gui
-
+import onionshare_gui
 onionshare_gui.main()
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 6465dcf..c933c97 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -42,10 +42,12 @@ def get_onionshare_dir():
 
 
 def get_osx_resources_dir():
-    # this is hacky, but in it ultimate ends up returning the absolute path to
-    # OnionShare.app/Contents/Resources
-    return os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
+    if get_platform() == 'Darwin':
+        # this is hacky, but in it ultimate ends up returning the absolute path to
+        # OnionShare.app/Contents/Resources, based on the location of helpers.py
+        return os.path.dirname(os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))))
 
+    return None
 
 def get_html_path(filename):
     p = platform.system()
diff --git a/setup.py b/setup.py
index 54eba52..3f796e0 100644
--- a/setup.py
+++ b/setup.py
@@ -83,7 +83,7 @@ if system == 'Linux':
         keywords='onion, share, onionshare, tor, anonymous, web server',
         packages=['onionshare', 'onionshare_gui'],
         include_package_data=True,
-        scripts=['bin/onionshare', 'bin/onionshare-gui'],
+        scripts=['install/linux_scripts/onionshare', 'install/linux_scripts/onionshare-gui'],
         data_files=[
             (os.path.join(sys.prefix, 'share/applications'), ['install/onionshare.desktop']),
             (os.path.join(sys.prefix, 'share/pixmaps'), ['install/onionshare80.xpm']),
@@ -98,7 +98,7 @@ elif system == 'Darwin':
         version=version,
         description=description,
         long_description=long_description,
-        app=['install/onionshare-launcher.py'],
+        app=['install/osx_scripts/onionshare-gui'],
         data_files=[
             ('images', images),
             ('locale', locale),
@@ -107,7 +107,8 @@ elif system == 'Darwin':
         options={
             'py2app': {
                 'argv_emulation': True,
-                'iconfile':'install/onionshare.icns',
+                'iconfile': 'install/onionshare.icns',
+                'extra_scripts': ['install/osx_scripts/onionshare'],
                 'includes': [
                     'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui',
                     'jinja2', 'jinja2.ext', 'jinja2.ext.autoescape'],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/onionshare.git



More information about the Pkg-anonymity-tools mailing list