Skip to content

Commit

Permalink
Hack in the services autodetect functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Jul 29, 2015
1 parent 7533757 commit 419c3f7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tracer/resources/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _load(file):
def _append_application(default_attrs, specific_attrs={}):
application = Application(default_attrs)
application.update(specific_attrs)

if application in Applications._apps:
i = Applications._apps.index(application)
Applications._apps[i].update(application)
Expand Down Expand Up @@ -177,10 +178,18 @@ def update(self, values):
values = values._attributes
self._attributes.update(values)

@property
def type(self):
return Applications.TYPES["DAEMON"] if self.has_service_file else self._attributes["type"]

@property
def has_service_file(self):
return os.path.isfile("/usr/lib/systemd/system/{0}.service".format(self.name))

# @TODO rename to helper_format
@property
def helper(self):
helper = self._attributes["helper"]
helper = self._attributes["helper"] if self._attributes["helper"] else Applications._helper(self)
if os.getlogin() != "root" and self.type == Applications.TYPES["DAEMON"]:
if helper and not helper.startswith("sudo "):
helper = "sudo " + helper
Expand Down

0 comments on commit 419c3f7

Please sign in to comment.