Skip to content

Commit

Permalink
Add support for multiple Mac app paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Feb 24, 2015
1 parent e27327e commit 3e96d84
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mine/manager.py
Expand Up @@ -3,6 +3,7 @@
import os
import abc
import time
import glob
import platform
import functools

Expand Down Expand Up @@ -148,8 +149,15 @@ def start(self, application):
if os.path.exists(name):
path = name
else:
# TODO: search additional paths?
path = os.path.join("/Applications", name)
path = os.path.join('/Applications', name)
if not os.path.exists(path):
pattern = os.path.join("/Applications/*", name)
log.debug("glob pattern: %s", pattern)
paths = glob.glob(pattern)
for path in paths:
log.debug("match: %s", path)
assert paths, "not found: {}".format(application)
path = paths[0]
self._start_app(path)

@log_stopping
Expand All @@ -163,10 +171,11 @@ def stop(self, application):
@staticmethod
def _get_process(name):
"""Get a process whose executable path contains an app name."""
log.debug("searching for exe path containing '%s'...", name)
for process in psutil.process_iter():
try:
path = process.exe()
if name in path.split(os.sep):
path = process.exe().lower()
if name.lower() in path.split(os.sep):
if process.status() == psutil.STATUS_ZOMBIE:
log.debug("skipped zombie process: %s", path)
else:
Expand Down

0 comments on commit 3e96d84

Please sign in to comment.