def get_announcement_page(page=1): if not request.form.get('uid'): return jsonify({'error': 'UID not provided'}) if not request.form.get('password'): return jsonify({'error': 'Password not provided'}) try: my_acc = SessionUIMS(request.form.get('uid'), request.form.get('password')) except Exception as e: if e.__class__ == IncorrectCredentialsError: return jsonify({'error': 'Invalid credentials'}) try: ann_page = my_acc.annoucements(page) except Exception as e: if e.__class__ == UIMSInternalError: return jsonify({'error': 'UIMS Internal Failure'}) else: return jsonify(ann_page)
def get_data(): if not request.form.get('uid'): return jsonify({'error': 'UID not provided'}) if not request.form.get('password'): return jsonify({'error': 'Password not provided'}) my_acc = SessionUIMS(request.form.get('uid'), request.form.get('password')) try: subjects = my_acc.attendance except: return jsonify({'error': 'Invalid credentials'}) else: return jsonify(subjects)
def signin(): if not request.form.get('uid'): return jsonify({'error': 'UID not provided'}) if not request.form.get('password'): return jsonify({'error': 'Password not provided'}) try: SessionUIMS(request.form.get('uid'), request.form.get('password')) except Exception as e: if e.__class__ == IncorrectCredentialsError: return jsonify({'error': 'Invalid credentials'}) else: return jsonify({'success': True})
def get_full_attendance(): if not request.form.get('uid'): return jsonify({'error': 'UID not provided'}) if not request.form.get('password'): return jsonify({'error': 'Password not provided'}) try: my_acc = SessionUIMS(request.form.get('uid'), request.form.get('password')) except Exception as e: if e.__class__ == IncorrectCredentialsError: return jsonify({'error': 'Invalid credentials'}) try: subjects = my_acc.full_attendance except Exception as e: if e.__class__ == UIMSInternalError: return jsonify({'error': 'UIMS Internal Failure'}) else: return jsonify(subjects)
def get_timetable(): if not request.form.get('uid'): return jsonify({'error': 'UID not provided'}) if not request.form.get('password'): return jsonify({'error': 'Password not provided'}) try: my_acc = SessionUIMS(request.form.get( 'uid'), request.form.get('password')) except Exception as e: if e.__class__ == IncorrectCredentialsError: return jsonify({'error': 'Invalid credentials'}) else: return jsonify({'error': 'Looks like this Module is inactive on UIMS'}) try: timetable = my_acc.timetable except Exception as e: if e.__class__ == UIMSInternalError: return jsonify({'error': 'UIMS Internal Failure'}) else: return jsonify({'error': 'Looks like this Module is inactive on UIMS'}) else: return jsonify(timetable)
from uims_api import SessionUIMS import sys args = sys.argv my_account = SessionUIMS(args[1], args[2]) subjects = my_account.attendance response = '{' for subject in subjects: subject_attendance = f""""{subject['Title']}": {subject['TotalPercentage']},""" response = response + subject_attendance response = response[:-1] + '}' print(response)