From 4d638ebdc85ff9077e79b49af2e38ee6fd344c2f Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 24 Jul 2020 11:08:04 +0200 Subject: [PATCH 1/3] added item to tray menu with version --- pype/tools/tray/pype_tray.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 7dda8bf4f7..99832f0313 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -4,6 +4,11 @@ import platform from avalon import style from Qt import QtCore, QtGui, QtWidgets, QtSvg from pype.api import config, Logger, resources +import pype.version +try: + import configparser +except Exception: + import ConfigParser as configparser class TrayManager: @@ -100,6 +105,11 @@ class TrayManager: if items and self.services_submenu is not None: self.add_separator(self.tray_widget.menu) + version_string = self._version_string() + version_action = QtWidgets.QAction(version_string, self.tray_widget) + self.tray_widget.menu.addAction(version_action) + self.add_separator(self.tray_widget.menu) + # Add Exit action to menu aExit = QtWidgets.QAction("&Exit", self.tray_widget) aExit.triggered.connect(self.tray_widget.exit) @@ -109,6 +119,31 @@ class TrayManager: self.connect_modules() self.start_modules() + def _version_string(self): + subversion = None + client_name = None + config_file_path = os.path.join( + os.environ["PYPE_SETUP_PATH"], "pypeapp", "config.ini" + ) + version_string = pype.version.__version__ + if os.path.exists(config_file_path): + config = configparser.ConfigParser() + config.read(config_file_path) + try: + default_config = config["CLIENT"] + except Exception: + default_config = {} + subversion = default_config.get("subversion") + client_name = default_config.get("client_name") + + if subversion: + version_string += " ({})".format(subversion) + + if client_name: + version_string += ", {}".format(client_name) + + return version_string + def process_items(self, items, parent_menu): """ Loop through items and add them to parent_menu. From f4d49b330eabd9d9f6d5a744f1b9dd7374080df7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 24 Jul 2020 11:12:47 +0200 Subject: [PATCH 2/3] add version item only if client information is in config.ini --- pype/tools/tray/pype_tray.py | 40 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 99832f0313..3d6d6d473b 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -105,10 +105,7 @@ class TrayManager: if items and self.services_submenu is not None: self.add_separator(self.tray_widget.menu) - version_string = self._version_string() - version_action = QtWidgets.QAction(version_string, self.tray_widget) - self.tray_widget.menu.addAction(version_action) - self.add_separator(self.tray_widget.menu) + self._add_version_item() # Add Exit action to menu aExit = QtWidgets.QAction("&Exit", self.tray_widget) @@ -119,30 +116,37 @@ class TrayManager: self.connect_modules() self.start_modules() - def _version_string(self): - subversion = None - client_name = None + def _add_version_item(self): config_file_path = os.path.join( os.environ["PYPE_SETUP_PATH"], "pypeapp", "config.ini" ) - version_string = pype.version.__version__ - if os.path.exists(config_file_path): - config = configparser.ConfigParser() - config.read(config_file_path) - try: - default_config = config["CLIENT"] - except Exception: - default_config = {} - subversion = default_config.get("subversion") - client_name = default_config.get("client_name") + if not os.path.exists(config_file_path): + return + subversion = None + client_name = None + + config = configparser.ConfigParser() + config.read(config_file_path) + try: + default_config = config["CLIENT"] + except Exception: + default_config = {} + subversion = default_config.get("subversion") + client_name = default_config.get("client_name") + if not subversion and not client_name: + return + + version_string = pype.version.__version__ if subversion: version_string += " ({})".format(subversion) if client_name: version_string += ", {}".format(client_name) - return version_string + version_action = QtWidgets.QAction(version_string, self.tray_widget) + self.tray_widget.menu.addAction(version_action) + self.add_separator(self.tray_widget.menu) def process_items(self, items, parent_menu): """ Loop through items and add them to parent_menu. From b7cf6679248a169f8bff0323a48014cb0e139433 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 27 Jul 2020 10:03:22 +0200 Subject: [PATCH 3/3] show the version string all the time --- pype/tools/tray/pype_tray.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pype/tools/tray/pype_tray.py b/pype/tools/tray/pype_tray.py index 3d6d6d473b..9537b62581 100644 --- a/pype/tools/tray/pype_tray.py +++ b/pype/tools/tray/pype_tray.py @@ -120,22 +120,18 @@ class TrayManager: config_file_path = os.path.join( os.environ["PYPE_SETUP_PATH"], "pypeapp", "config.ini" ) - if not os.path.exists(config_file_path): - return - subversion = None - client_name = None + default_config = {} + if os.path.exists(config_file_path): + config = configparser.ConfigParser() + config.read(config_file_path) + try: + default_config = config["CLIENT"] + except Exception: + pass - config = configparser.ConfigParser() - config.read(config_file_path) - try: - default_config = config["CLIENT"] - except Exception: - default_config = {} subversion = default_config.get("subversion") client_name = default_config.get("client_name") - if not subversion and not client_name: - return version_string = pype.version.__version__ if subversion: