[Pkg-privacy-commits] [onionshare] 30/256: Added dev scripts for launching onionshare and onionshare-gui from the source code tree, without having to install it

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:06 UTC 2017


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

ulrike pushed a commit to branch master
in repository onionshare.

commit fd41eac48d1afd4a8399e05f393fecb4cccc099a
Author: Micah Lee <micah at micahflee.com>
Date:   Thu Dec 22 16:19:54 2016 -0800

    Added dev scripts for launching onionshare and onionshare-gui from the source code tree, without having to install it
---
 BUILD.md                   |  4 ++--
 dev_scripts/onionshare     | 28 ++++++++++++++++++++++++++++
 dev_scripts/onionshare-gui | 28 ++++++++++++++++++++++++++++
 onionshare/helpers.py      |  9 ++++++---
 4 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 668e386..69bb4db 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -20,8 +20,8 @@ sudo apt-get install -y python3-flask python3-stem python3-pyqt5 python-nautilus
 After that you can try both the CLI and the GUI version of OnionShare:
 
 ```sh
-./install/scripts/onionshare
-./install/scripts/onionshare-gui
+./dev_scripts/onionshare
+./dev_scripts/onionshare-gui
 ```
 
 A script to build a .deb package and install OnionShare easily is also provided for your convenience:
diff --git a/dev_scripts/onionshare b/dev_scripts/onionshare
new file mode 100755
index 0000000..b94d113
--- /dev/null
+++ b/dev_scripts/onionshare
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+OnionShare | https://onionshare.org/
+
+Copyright (C) 2016 Micah Lee <micah at micahflee.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+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/>.
+"""
+
+# Load onionshare module and resources from the source code tree
+import os, sys
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.onionshare_dev_mode = True
+
+import onionshare
+onionshare.main()
diff --git a/dev_scripts/onionshare-gui b/dev_scripts/onionshare-gui
new file mode 100755
index 0000000..6d610bb
--- /dev/null
+++ b/dev_scripts/onionshare-gui
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+OnionShare | https://onionshare.org/
+
+Copyright (C) 2016 Micah Lee <micah at micahflee.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+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/>.
+"""
+
+# Load onionshare module and resources from the source code tree
+import os, sys
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.onionshare_dev_mode = True
+
+import onionshare_gui
+onionshare_gui.main()
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 6ad8f80..5d321c0 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -34,14 +34,17 @@ def get_resource_path(filename):
     systemwide, and whether regardless of platform
     """
     p = get_platform()
-    if p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix):
+
+    if getattr(sys, 'onionshare_dev_mode', False):
+        # Look for resources directory relative to python file
+        resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources')
+
+    elif p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix):
         # OnionShare is installed systemwide in Linux
         resources_dir = os.path.join(sys.prefix, 'share/onionshare')
     elif getattr(sys, 'frozen', False): # Check if app is "frozen" with cx_Freeze
         # http://cx-freeze.readthedocs.io/en/latest/faq.html#using-data-files
         resources_dir = os.path.join(os.path.dirname(sys.executable), 'resources')
-    else:  # Look for resources directory relative to python file
-        resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources')
 
     return os.path.join(resources_dir, filename)
 

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