better file not found handling

This commit is contained in:
lickthecheese 2020-03-13 19:16:38 -04:00
parent c1160874f7
commit 8157cd78ca
1 changed files with 17 additions and 2 deletions

19
uquiz
View File

@ -15,12 +15,27 @@ uquiz is a simple user based quiz engine
print(motd)
if len(sys.argv) < 2:
print('run with the uquiz file as an arg to start')
if len(sys.argv) < 2 or sys.argv[1] == 'help':
print("""
Hi, welcome to uquiz, lickthecheese's userdir based assessment engine.
To get started, type in a test name as the first argument of this
command, or make your own test by making a json file in your ~/.uquiz
There is not much documentation at the moment of how to make a uquiz
compatable file, however you can just look at examples until i make
some docs lol
""")
sys.exit()
filename=subprocess.run(['bash -c "find /home/*/.uquiz/* | grep \'{}\' | head -n 1"'.format(sys.argv[1])], shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')[:-1]
if not filename:
print('Whoops! I cant find that quiz, try specifying the absolute path.')
sys.exit()
print('Using "{}"! wrong quiz file? specify a complete path (make sure your quiz file is in a .uquiz/ in a homedir)\n'.format(filename))
answers = []