From bb2c9797e8e4dcc32f839de60472986574cbca49 Mon Sep 17 00:00:00 2001 From: Leela Prasad <47483946+leelaprasadv@users.noreply.github.com> Date: Sun, 19 Nov 2023 04:08:43 +0530 Subject: [PATCH] Fix jmeter launch and home path update issues --- hamster/config.py | 5 +++-- hamster/menu.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/hamster/config.py b/hamster/config.py index b7888f1..917dbff 100644 --- a/hamster/config.py +++ b/hamster/config.py @@ -13,8 +13,9 @@ pattern = re.compile("recent_file_.*") jmeter_plist = f"/Users/{username}/Library/Preferences/org.apache.jmeter.plist" -jmeter_home = config_parser.get('JMETER', 'HOME') def jmeter_path(): - return jmeter_home + '/bin/jmeter' + jmeter_home = config_parser.get('JMETER', 'HOME') + jmeter_bin = jmeter_home + '/bin/jmeter' + return jmeter_home, jmeter_bin diff --git a/hamster/menu.py b/hamster/menu.py index 02df9b3..68829ef 100644 --- a/hamster/menu.py +++ b/hamster/menu.py @@ -1,7 +1,7 @@ import rumps import subprocess from utils import update_properties, show_splash_screen, prechecks, get_recent_jmeter_test_plans, sleep -from config import jmeter_path, icon_path, properties_file_path, config_parser, jmeter_plist, jmeter_home +from config import jmeter_path, icon_path, properties_file_path, config_parser, jmeter_plist class DynamicMenuApp(rumps.App): @@ -25,8 +25,8 @@ def __init__(self, title): super(DynamicMenuApp, self).__init__(title, icon=icon_path, quit_button='Quit') self.menu = ['Launch JMeter', 'Recent Test Plans', None, 'View Config', 'Edit JMETER_HOME', None, 'Refresh', 'Help', 'About'] - self.jmeter_path = jmeter_path() - prechecks(jmeter_plist, jmeter_home, self.jmeter_path) + self.jmeter_home, self.jmeter_bin = jmeter_path() + prechecks(jmeter_plist, self.jmeter_home, self.jmeter_bin) self.refresh_test_plans(delay=1) def refresh_test_plans(self, delay=5): @@ -90,9 +90,11 @@ def edit_home_path(self, _): response = window_builder.run() if response.clicked: - update_properties({'HOME': str(response.text.strip())}) + updated_jmeter_home = response.text.strip() + update_properties({'HOME': str(updated_jmeter_home)}) config_parser.read(properties_file_path) - self.refresh_test_plans() + self.jmeter_home, self.jmeter_bin = jmeter_path() + self.refresh_test_plans(1) except Exception as e: rumps.alert("Error", e) @@ -101,7 +103,7 @@ def menu_callback(self, sender): Callback function for menu items. """ try: - subprocess.Popen([self.jmeter_path, '-t', sender.title], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen([self.jmeter_bin, '-t', sender.title], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) self.refresh_test_plans() except Exception as e: rumps.alert("Error", e) @@ -112,7 +114,7 @@ def just_jmeter(self, _): Launches JMeter without any test plan. """ try: - subprocess.Popen([self.jmeter_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen([self.jmeter_bin], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except Exception as e: rumps.alert("Error", e)