Skip to content

Commit

Permalink
Added application version in about dialog (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilcardella committed Feb 3, 2020
1 parent 30872bf commit d18d16c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated Pipfile unifying packages and adding custom scripts

### Added
- Show application version in About dialog

## [2.1.1] - 2020-01-13
### Changed
- Removed unused resource files
Expand Down
17 changes: 17 additions & 0 deletions src/TradingMate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import inspect
import logging
import datetime as dt
import subprocess
import re

currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
Expand Down Expand Up @@ -147,6 +149,21 @@ def get_app_log_filepath(self):
"""Return the full filepath of the log file of application current session"""
return self._app_log_filepath

def get_app_version(self):
# Find the app version with pip
output = subprocess.Popen(
"pip3 show TradingMate".split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
# Extract the version from the command output
match = re.search(
r"Version:\s([0-9].[0-9].[0-9])", str(output.communicate()[0])
)
if match is None:
return "Unknown"
return match.group(1).strip()


def main():
# Initialise the business logic
Expand Down
3 changes: 3 additions & 0 deletions src/UI/TradingMateClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ def is_portfolio_auto_refreshing(self, portfolio_id):

def get_app_log_filepath(self):
return self._server.get_app_log_filepath()

def get_app_version(self):
return self._server.get_app_version()
10 changes: 4 additions & 6 deletions src/UI/gtk/UIHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ def _close_application(self):
gtk.main_quit()

def _on_show_about_event(self, widget):
MessageDialog(
self._main_window,
"About",
Messages.ABOUT_MESSAGE.value,
gtk.MessageType.INFO,
).show()
message = "Version: {}\n{}".format(
self._client.get_app_version(), Messages.ABOUT_MESSAGE.value
)
MessageDialog(self._main_window, "About", message, gtk.MessageType.INFO).show()

def _on_show_log_event(self, widget):
self._log_window.show()
Expand Down

0 comments on commit d18d16c

Please sign in to comment.