Skip to content

Commit

Permalink
Fix jmeter launch and home path update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leelaprasadv authored Nov 18, 2023
1 parent e129ee2 commit bb2c979
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions hamster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 9 additions & 7 deletions hamster/menu.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit bb2c979

Please sign in to comment.