From ef9b23ca6dd76a88c75eb889d4212d0de13814cf Mon Sep 17 00:00:00 2001 From: AB Date: Sat, 5 May 2018 01:57:11 +0300 Subject: [PATCH] minumal UI --- .gitignore | 2 +- __app__.py | 88 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 8d31a21..cc01379 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # configs -assets/config.json +creds.ini # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/__app__.py b/__app__.py index aa99d1b..30050f9 100644 --- a/__app__.py +++ b/__app__.py @@ -1,20 +1,86 @@ from main import Main +import configparser +import random -username = '4016014' -password = '40201' +config = configparser.ConfigParser() + + +def input_line(): + allah = [ + '༼ つ ͠° ͟ ͟ʖ ͡° ༽つ', '(☄ฺ◣д◢)☄ฺ', '( >д<)', '(ꐦ ಠ皿ಠ )', '(;≧皿≦)', + '((╬●∀●)', '(; ̄Д ̄)', '(;¬_¬)', '(ꐦ°᷄д°᷅)', '(*`益´*)', '(;¬_¬)', + '(メ゚皿゚)', '( ╬◣ 益◢)', '(ఠ్ఠ ˓̭ ఠ్ఠ)' + ] + return allah[random.randint(0, len(allah)-1)] + +def act(q): + if (q == 'h') or (q== 'help'): + print('''I don't know how to help you... +`list` - list all test +`resolve ` +''') + elif q == 'list': + list_all() + elif q[:7] == 'resolve': + q = q.split(' ') + print(q[1], q[2]) + if len(q) != 3: + print('''Specify Subj number and Test number. +List it with `list` command +example: +resolve 4 1''') + return 1 +# print("Resolving %s, %s" % ( +# app.subjects[q[1]], +# app.subjects[q[1]][q[2]]) +# ) + app.resolve(int(q[1]), int(q[2])) + +def list_all(): + i = 0 + for subj in app.subjects: + print("[%s] %s" % (i, subj)) + i += 1 + j = 0 + for test in app.subjects[subj]: + print("\t[%s] %s" % (j, test)) + j += 1 + +try: + config.read("creds.ini") + username = config['creds']['user'] + password = config['creds']['pass'] + accuracy = config['mics']['accuracy'] +except: + print("Couldn't find appropriate config file. Let's create new.") + print("Provide credentials for fesmu.ru/eport/eport/ below") + + username = input('User ID %s ' % input_line()) + password = input('Password %s ' % input_line()) + config['creds'] = {} + config['creds']['user'] = username + config['creds']['pass'] = password + print("Also you are able to set desired level of accuracy in percent (%).") + accuracy = int(input('Accuracy %s ' % input_line())) + while (accuracy < 0) or (accuracy > 100): + print("Are you stupid? Try again.") + accuracy = int(input('Accuracy %s ' % input_line())) + config['mics'] = {} + config['mics']['accuracy'] = str(accuracy) + with open('creds.ini', 'w') as configfile: + config.write(configfile) app = Main(username, password) app.auth() app.get_tests() -#print(app.start_test(3, 0)) + +print(''' +You are in bot command line engine. +Type h or help for help. +''') while True: - q = input('Subj >>> ') - a = input('Test >>> ') - app.resolve(int(q),int(a)) - #q = input('Q >>> ') - #a = input('A >>> ') - #z = [a] - #app.answer(q, z) - + q = input('%s >>> ' % input_line()) + + act(q)