Skip to content

Commit

Permalink
Don't force root, rather catch exceptions; See #49
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Dec 9, 2015
1 parent 6c7ec4e commit ec48814
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion tracer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tracer.resources.router import Router
from tracer.resources.args_parser import parser
from tracer.resources.package import Package
from tracer.resources.exceptions import UnsupportedDistribution, PathNotFound, LockedDatabase
from tracer.resources.exceptions import UnsupportedDistribution, PathNotFound, LockedDatabase, DatabasePermissions


def run():
Expand All @@ -44,5 +44,9 @@ def run():
except (UnsupportedDistribution, PathNotFound, LockedDatabase) as ex:
print(ex)
exit(1)
except DatabasePermissions as ex:
print(ex)
print("You will probably need to run tracer as root")
exit(1)
except (KeyboardInterrupt, EOFError):
print("")
4 changes: 2 additions & 2 deletions tracer/packageManagers/portage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from tracer.resources.package import Package
from tracer.resources.collections import PackagesCollection
from gentoolkit.helpers import FileOwner
from psutil import AccessDenied
from tracer.resources.exceptions import DatabasePermissions
from tracer.resources.applications import Applications
import os
import portage
Expand All @@ -51,7 +51,7 @@ def packages_newer_than(self, unix_time):
"""

if not os.access('/var/log/emerge.log', os.R_OK):
raise AccessDenied
raise DatabasePermissions

newer = PackagesCollection()
process = subprocess.Popen(['qlop', '-lC'], stdout=subprocess.PIPE)
Expand Down
3 changes: 0 additions & 3 deletions tracer/resources/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def dispatch(self):
elif self.args.version:
print(__version__)

elif os.getuid() != 0:
print(_("Only root can use this application"))

elif self.args.resource:
from tracer.controllers.resource import ResourceController
controller = ResourceController(self.args)
Expand Down

0 comments on commit ec48814

Please sign in to comment.