exiting cleanly if less is not found

This commit is contained in:
Lionel Dricot 2022-03-23 16:35:10 +01:00
parent 5247813b21
commit 431d5d81cb
1 changed files with 6 additions and 0 deletions

View File

@ -219,10 +219,16 @@ _MAX_CACHE_SIZE = 10
_MAX_CACHE_AGE_SECS = 180
less_version = 0
if not shutil.which("less"):
print("Please install the pager \"less\" to run Offpunk.")
print("If you wish to use another pager, send your request to offpunk@ploum.eu.")
print("(Im really curious to hear about people not having \"less\" on their system.)")
sys.exit()
return_code = subprocess.run("less --version",shell=True, capture_output=True)
output = return_code.stdout.decode()
# We get less Version (which is the only integer on the first line)
words = output.split("\n")[0].split()
less_version = 0
for w in words:
if w.isdigit():
less_version = int(w)