[Pkg-privacy-commits] [onionshare] 20/66: Display version string automatically in CLI, and in the status bar in GUI (#251)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Wed Apr 13 22:17:47 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit e199946a8d9a03bb50df764b456986a05f538607
Author: Micah Lee <micah at micahflee.com>
Date: Fri Feb 12 10:48:25 2016 -0800
Display version string automatically in CLI, and in the status bar in GUI (#251)
---
locale/en.json | 3 ++-
onionshare/helpers.py | 16 +++++++++++++++-
onionshare/onionshare.py | 1 +
onionshare_gui/onionshare_gui.py | 4 ++++
setup.py | 1 +
5 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/locale/en.json b/locale/en.json
index e45a2fa..2215c02 100644
--- a/locale/en.json
+++ b/locale/en.json
@@ -44,5 +44,6 @@
"using_ephemeral": "Staring ephemeral Tor hidden service and awaiting publication",
"gui_download_progress_complete": "%p%, Time Elapsed: {0:s}",
"gui_download_progress_starting": "{0:s}, %p% (Computing ETA)",
- "gui_download_progress_eta": "{0:s}, ETA: {1:s}, %p%"
+ "gui_download_progress_eta": "{0:s}, ETA: {1:s}, %p%",
+ "version_string": "Onionshare {0:s} | https://onionshare.org/"
}
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index c2c4793..43dd781 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -58,7 +58,7 @@ def get_html_path(filename):
"""
Returns the path of the html files.
"""
- p = platform.system()
+ p = get_platform()
if p == 'Darwin':
prefix = os.path.join(osx_resources_dir, 'html')
else:
@@ -66,6 +66,20 @@ def get_html_path(filename):
return os.path.join(prefix, filename)
+def get_version():
+ """
+ Returns the version of OnionShare that is running.
+ """
+ p = get_platform()
+ if p == 'Linux':
+ version_filename = os.path.join(sys.prefix, 'share/onionshare/version')
+ elif p == 'Darwin':
+ version_filename = os.path.join(helpers.osx_resources_dir, 'version')
+ else:
+ version_filename = os.path.join(os.path.dirname(helpers.get_onionshare_dir()), 'version')
+ return open(version_filename).read().strip()
+
+
def constant_time_compare(val1, val2):
"""
Compares two values in constant time.
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index edc7469..e10fe65 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -97,6 +97,7 @@ def main(cwd=None):
onionshare uses.
"""
strings.load_strings()
+ print strings._('version_string').format(helpers.get_version())
# onionshare CLI in OSX needs to change current working directory (#132)
if helpers.get_platform() == 'Darwin':
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index 9f2eea7..31f6cea 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -111,6 +111,9 @@ class OnionShareGui(QtGui.QWidget):
# status bar
self.status_bar = QtGui.QStatusBar()
self.status_bar.setSizeGripEnabled(False)
+ version_label = QtGui.QLabel('v{0:s}'.format(helpers.get_version()))
+ version_label.setStyleSheet('color: #666666;')
+ self.status_bar.addPermanentWidget(version_label)
# main layout
self.layout = QtGui.QVBoxLayout()
@@ -260,6 +263,7 @@ def main():
The main() function implements all of the logic that the GUI version of onionshare uses.
"""
strings.load_strings()
+ print strings._('version_string').format(helpers.get_version())
# start the Qt app
global qtapp
diff --git a/setup.py b/setup.py
index f56ff83..21ef090 100644
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,7 @@ if system == 'Linux':
(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'), ['version']),
(os.path.join(sys.prefix, 'share/onionshare/images'), images),
(os.path.join(sys.prefix, 'share/onionshare/locale'), locale)
]
--
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