From 907dbe248832e421ce0612192a3241b30d1f4745 Mon Sep 17 00:00:00 2001 From: bionel Date: Sun, 16 Aug 2020 11:01:14 +0300 Subject: allow search as non-root --- src/backend/dbsearch.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/backend/dbsearch.py b/src/backend/dbsearch.py index 7467462..6e32b69 100644 --- a/src/backend/dbsearch.py +++ b/src/backend/dbsearch.py @@ -2,6 +2,7 @@ import sisyphus import sqlite3 +import os def searchDB(filter, cat = '', pn = '', desc = ''): NOVIRT = "AND cat NOT LIKE 'virtual'" @@ -100,8 +101,11 @@ def tosql(string): return '%%' if string == '' else string.replace('*', '%').replace('?', '_') def showSearch(filter, cat, pn, desc, single = False): - sisyphus.update.start() - print(f"Searching for {filter} packages ...\n") + if os.getuid() == 0: + sisyphus.update.start() + else: + print('You are not root, cannot fetch updates.\nSearch result may be inaccurate!') + print(f"Looking for {filter} matching packages ...\n") pkglist = searchDB(filter, tosql(cat), tosql(pn), tosql(desc)) if len(pkglist) == 0: -- cgit v1.2.3