Beispiel #1
0
def coursemenu():
    # remove total row
    ovtbl = initoverviewtbl()
    ovtbl = ovtbl.delrow(ovtbl.numrows() - 1).delrow(ovtbl.numrows() - 1)
    # ask which course to view
    ovtbl.view()
    try:
        chosencourseidx = wsutils.getidx(
            strings['prompts'][3], [i for i in range(len(initcoursetbls()))])
        chosencoursetbl = initcoursetbls()[chosencourseidx]
    except:
        return
    threads = chosencoursetbl.items

    wsmenu.menu(
        [
            strings['menus'][0],
            strings['menus'][1],
            strings['menus'][2],
            strings['menus'][3],
        ],
        beforechoices=[lambda: initcoursetbls()[chosencourseidx].view()],
        funcs=[
            lambda: wsclasses.ForumThread.getlink(
                wsutils.getidx(strings['prompts'][0], threads)),
            lambda: wsclasses.ForumThread.finish(
                wsutils.getidx(strings['prompts'][1], threads)),
            lambda: wsclasses.ForumThread.getcontent(
                wsutils.getidx(strings['prompts'][2], threads)),
            lambda: wsclasses.ForumThread.reply(
                wsutils.getidx(strings['prompts'][9], threads), headers,
                cookies),
        ])
Beispiel #2
0
def unfinishedmenu():
    unfinisheds = []
    for t in forum:
        if not t.done:
            unfinisheds.append(t)
    wsmenu.menu(
        [
            strings['menus'][0], strings['menus'][1], strings['menus'][2],
            strings['menus'][3]
        ],
        beforechoices=[
            lambda: wsprinter.Table([
                'No', 'Course', 'Class', 'Thread', 'Finished', 'Created at',
                'Replies'
            ], [[i + 1 for i in range(len(unfinisheds))],
                [t.coursecaption
                 for t in unfinisheds], [t.classcaption for t in unfinisheds],
                [t.threadcaption for t in unfinisheds],
                ['Yes' if t.done else 'No' for t in unfinisheds],
                [
                    datetime.datetime.strptime(t.threaddate[:10], "%Y-%m-%d").
                    strftime("%d-%b-%Y") for t in unfinisheds
                ], [t.threadreplies for t in unfinisheds]], "rrrlrrr").view()
        ],
        funcs=[
            lambda: wsclasses.ForumThread.getlink(
                wsutils.getidx(strings['prompts'][0], unfinisheds)),
            lambda: wsclasses.ForumThread.finish(
                wsutils.getidx(strings['prompts'][1], unfinisheds)),
            lambda: wsclasses.ForumThread.getcontent(
                wsutils.getidx(strings['prompts'][2], unfinisheds)),
            lambda: wsclasses.ForumThread.reply(
                wsutils.getidx(strings['prompts'][9], unfinisheds), headers,
                cookies),
        ])
Beispiel #3
0
def sortmenu():
    keys = [
        'coursecaption', 'classcaption', 'threadcaption', 'threaddate', 'done',
        'threadreplies'
    ]

    wsmenu.menu([
        'Course asc', 'Class asc', 'Thread asc', 'Create date asc',
        'Finished/unfinished asc', 'Replies asc', 'Course dsc', 'Class dsc',
        'Thread dsc', 'Create date dsc', 'Finished/unfinished dsc',
        'Replies dsc'
    ],
                beforechoices=[lambda: initalltbl().view()],
                funcs=[
                    lambda: sortforum('coursecaption', False),
                    lambda: sortforum('classcaption', False),
                    lambda: sortforum('threadcaption', False),
                    lambda: sortforum('threaddate', False),
                    lambda: sortforum('done', False),
                    lambda: sortforum('threadreplies', False),
                    lambda: sortforum('coursecaption', True),
                    lambda: sortforum('classcaption', True),
                    lambda: sortforum('threadcaption', True),
                    lambda: sortforum('threaddate', True),
                    lambda: sortforum('done', True),
                    lambda: sortforum('threadreplies', True),
                ])
Beispiel #4
0
def main():
    parseargs()
    try:
        global myname
        myname = getmyname()
    except:
        traceback.print_exc()
        print "[!] Problem occurred, make sure you're logged in to bimay and the phpsessid is valid"
        exit()

    try:
        global forum
        forum = loadp("forum%s.data" % acadyear)
    except:
        print "[+] Initiating forum data, first time run only"
        try:
            print "[+] Hello there " + myname
            getforum()
        except Exception:
            traceback.print_exc()
            print "[!] Problem occurred, make sure you're logged in to bimay and the phpsessid is valid"
            exit()
    try:
        global vidconfs
        vidconfs = loadp("vidconf%s.data" % acadyear)
    except:
        print "[+] Initiating vidconf data (needs forum data), first time run only"
        try:
            getvidconfs()
        except:
            traceback.print_exc()
            print "[!] Problem occurred, make sure you're logged in to bimay and the phpsessid is valid"
            exit()

    wsmenu.menu([
        "//Welcome " + myname, "//wfhsucks main menu", "//    Forum",
        "        Check for new threads",
        "        Print all unfinished threads (NEW!)",
        "        Print threads from a course (NEW!)",
        "        Print threads from all courses (NEW!)",
        "        Batch finish/unfinish", "        Sort table",
        "//    Video conference (obsolete and no longer maintained, use https://myclass.apps.binus.ac.id instead)",
        "        Check for new upcoming video conferences",
        "        Print all upcoming video conferences", "//    Others",
        "        Quick fix table printing issues", "        Quick info",
        "        FAQ"
    ],
                beforechoices=[lambda: initmainmenutbl().view()],
                afterchoices=[
                    lambda: savep(forum, "forum%s.data" % acadyear),
                    lambda: savep(vidconfs, "vidconf%s.data" % acadyear)
                ],
                funcs=[
                    lambda: getforum(), lambda: unfinishedmenu(),
                    lambda: coursemenu(), lambda: allmenu(),
                    lambda: batchmenu(), lambda: sortmenu(),
                    lambda: getvidconfs(), lambda: vcmenu(),
                    lambda: fixissues(), lambda: help(), lambda: faq()
                ])
Beispiel #5
0
def vcmenu():
    wsmenu.menu(
        [
            strings['menus'][0],
            # "delete finished vidconfs"
        ],
        beforechoices=[lambda: initvctbl().view()],
        funcs=[
            lambda: wsclasses.Vidconf.getlink(
                wsutils.getidx(strings['prompts'][4], vidconfs))
        ])
Beispiel #6
0
def batchmenu():
    wsmenu.menu(
        [
            "Finish all threads from date1 until date2",
            "Unfinish all threads from date1 until date2"
        ],
        beforechoices=[lambda: initalltbl().view()],
        funcs=[
            lambda: batchtoggle(
                wsutils.gettimestamp(strings['prompts'][5], "%d/%m/%Y"),
                wsutils.gettimestamp(strings['prompts'][6], "%d/%m/%Y"), True),
            lambda: batchtoggle(
                wsutils.gettimestamp(strings['prompts'][5], "%d/%m/%Y"),
                wsutils.gettimestamp(strings['prompts'][6], "%d/%m/%Y"), False)
        ])
Beispiel #7
0
def allmenu():
    wsmenu.menu([
        strings['menus'][0],
        strings['menus'][1],
        strings['menus'][2],
        strings['menus'][3],
    ],
                beforechoices=[lambda: initalltbl().view()],
                funcs=[
                    lambda: wsclasses.ForumThread.getlink(
                        wsutils.getidx(strings['prompts'][0], forum)),
                    lambda: wsclasses.ForumThread.finish(
                        wsutils.getidx(strings['prompts'][1], forum)),
                    lambda: wsclasses.ForumThread.getcontent(
                        wsutils.getidx(strings['prompts'][2], forum)),
                    lambda: wsclasses.ForumThread.reply(
                        wsutils.getidx(strings['prompts'][9], forum), headers,
                        cookies),
                ])