From a71ffe9cd09164182584bb01b3993881f7766dfd Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 18 Aug 2020 12:26:10 +0100 Subject: make sisyphus.check.root more portable, replace it everywhere --- src/backend/searchbinary.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/backend/searchbinary.py') diff --git a/src/backend/searchbinary.py b/src/backend/searchbinary.py index 0305a14..e16c98c 100644 --- a/src/backend/searchbinary.py +++ b/src/backend/searchbinary.py @@ -1,6 +1,5 @@ #!/usr/bin/python3 -import os import sisyphus.filesystem import sisyphus.update import sqlite3 @@ -101,11 +100,7 @@ def searchDB(filter, cat = '', pn = '', desc = ''): def tosql(string): return '%%' if string == '' else string.replace('*', '%').replace('?', '_') -def start(filter, cat, pn, desc, single = False): - if os.getuid() == 0: - sisyphus.update.start() - else: - print('You are not root, cannot fetch updates.\nSearch result may be inaccurate!') +def showSearch(filter, cat, pn, desc, single = False): print(f"Looking for {filter} matching packages ...\n") pkglist = searchDB(filter, tosql(cat), tosql(pn), tosql(desc)) @@ -129,3 +124,11 @@ def start(filter, cat, pn, desc, single = False): print(f"\nFound {len(pkglist)} binary package(s)") print("To search for source packages, use the '--ebuild' option.") + +def start(filter, cat, pn, desc, single = False): + if sisyphus.check.root() == 0: + sisyphus.update.start() + showSearch(filter, cat, pn, desc, single = False) + else: + print('\nYou are not root, cannot fetch updates.\nSearch result may be inaccurate!\n') + showSearch(filter, cat, pn, desc, single = False) -- cgit v1.2.3