コード例 #1
0
def autostudy():
    login_url = "https://pc.xuexi.cn/points/login.html"
    exam_url = 'https://pc.xuexi.cn/points/exam-index.html'
    score_url = 'https://pc.xuexi.cn/points/my-points.html'

    # sparse args
    args = args_sparse()

    if args.chrome:
        show_flag = True
    else:
        show_flag = False

    driver = init_chromedriver(show_flag=show_flag)

    # Login
    if args.login:
        while check_login(driver, login_url):
            get_qrcode_screen_pic(driver, login_url)
            login_study(driver)

    else:
        while check_login(driver, login_url):
            get_qrcode_screen_pic(driver, login_url)
            login_study(driver)

        if args.read:
            # Read Article
            read_articles(driver)
        if args.watch:
            # Watch Videos
            watch_videos(driver)
        if args.dexam:
            # Do Daily Exam
            daily_exam(driver, url=exam_url, questions_per_group=5)
        if args.wexam:
            # Do Weekly Exam
            weekly_exam(driver, url=exam_url, questions_per_week=5)
        if args.sexam:
            # Do Special Exam
            special_exam(driver, url=exam_url, questions_per_special=10)
        if args.score:
            get_scores(driver, score_url)

        if args.all:
            read_articles(driver)
            watch_videos(driver)
            daily_exam(driver, questions_per_group=5)
            weekly_exam(driver, questions_per_week=5)
            special_exam(driver, questions_per_special=10)
            get_scores(driver, score_url)
コード例 #2
0
def docgi():

    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - lookup player</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Lookup player</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'get_player'):
        return
    if "name" in form:
        print_player(form["event"].value, form["name"].value, form)
    else:
        print """
<form>
	<input type='hidden' name='password' value='%s'/>
	Enter name: <input type='text' name='name' /><input type='submit' />
</form>
<p>
You can enter any fragment of a name, all matches will be returned. Searches are case-insensitive. Typos will not match.
</p>
""" % (form['password'].value if 'password' in form else '')

    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #3
0
ファイル: pairings.py プロジェクト: mjj29/deckchecks
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Pairings</title><link rel='stylesheet' href='style.css' /></head>
		<body>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        maxrounds = db.get_round(db.getEventId(form["event"].value))
        roundnum = int(form['round'].value) if 'round' in form else maxrounds
        print "<h1>Pairings for %s round %s</h1>" % (db.getEventName(
            form['event'].value), roundnum)
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'pairings'):
        return
    print '<div class="links">|'
    for i in range(1, maxrounds + 1):
        print output.makeLink(form, 'pairings?round=%s' % i, str(i))
        print '|'
    print '</div>'
    pairings(form["event"].value, roundnum)
    output.printLink(form, 'export?type=pairings&amp;round=%s' % roundnum,
                     'Download as TSV')
    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #4
0
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - lookup table</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Lookup table</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'get_table'):
        return
    if "table" in form:
        print_table(form["event"].value, int(form["table"].value), form)
    else:
        print """
<form>
	<input type='hidden' name='password' value='%s'/>
	Enter table number: <input type='text' name='table' /><input type='submit' />
</form>
""" % (form['password'].value if 'password' in form else '')

    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #5
0
ファイル: top_tables.py プロジェクト: mjj29/deckchecks
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - top tables</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Top tables</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'top_tables'):
        return
    print """ 
			<p>Key: 
				<span class='undefeated'>undefeated</span> 
				<span class='live'>definitely live for top 8</span> 
				<span class='marginal'>possibility of top 8</span> 
				<span class='unlikely'>theoretically possible</span> 
				<span class='dead'>cannot top 8</span> 
			</p>
"""
    top_tables(form["event"].value, form)
    output.printLink(form, 'export?type=top', 'Download as TSV')
    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #6
0
def main(name=None):
    try:
        print '''Welcome to the plog - personal blogging assistant'''
        ch = raw_input("Login(y|n) : ")
        if ch == 'y':
            cur_user = login.check_login()
            action(cur_user)
        else:
            if login.create_user() == False:
                print "user creation failed"
                sys.exit(0)
            cur_user = login.check_login()
            action(cur_user)
    except:
        print sys.exc_info()[0]
        print "logging out system...bye "
        sys.exit(0)
コード例 #7
0
ファイル: work_thread.py プロジェクト: SunicYosen/spider
 def login(self):
     while check_login(self.driver, self.login_url, self.cookies):
         self.qrcode_path = get_qrcode_screen_pic(self.driver,
                                                  self.login_url)
         self.login_qrcode.emit(self.qrcode_path)
         login_study(self.driver)
     self.name = get_user_name(self.driver, self.exam_url)
     self.is_login = True
     self.login_signal.emit(True)
     self.update_cookie()
     self.save_cookies()
コード例 #8
0
def main():
    if not check_login():
        print("Ingreso Fallido.")
        return
    streamer_logins = read_streamer_logins()
    if not streamer_logins:
        print("Tienes que especificar al menos un streamer!")
        return
    set_streamer_logins(streamer_logins)
    do_for_each_streamer(load_channel_points_context)
    start_watching()
    listen_for_channel_points()
コード例 #9
0
ファイル: main.py プロジェクト: r4fyy/idontgiveafucktwitch
def main():
    if not check_login():
        print("Login failed.")
        return
    streamer_logins = read_streamer_logins()
    if not streamer_logins:
        print("You have to specify at least one streamer!")
        return
    set_streamer_logins(streamer_logins)
    do_for_each_streamer(load_channel_points_context)
    start_watching()
    listen_for_channel_points()
コード例 #10
0
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - check history</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>History of checks</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'allchecks'):
        return
    if "tables" in form and form['tables']:
        deckcheck.output = output
        for table in form['tables'].value.split():
            if ':' in table:
                (table, seat) = table.split(':')
                seat = seat.strip().lower()
                if 'a' == seat: seat = 0
                elif 'b' == seat: seat = 1
                elif 'c' == seat: seat = 2
                else: raise Exception("Seat must be A, B or C")
                deckcheck.mark_checked(form["event"].value,
                                       table=table,
                                       seat=seat,
                                       roundnum=form['round'].value)
            else:
                deckcheck.mark_checked(form["event"].value,
                                       table=table,
                                       roundnum=form['round'].value)
    else:
        print """
			<h2>Check tables</h2>
			<p>Enter one table per line (table number for individual, table:seat for team (eg '7:A')</p>
			<form>
			<input type='hidden' name='password' value='%s'/>
			<textarea name='tables' cols='30' rows='5'></textarea>
			<br/>
			<input type='text' name='round' value='%s'/>
			<br/>
			<input type='submit' value='Mark as checked' />
			</form>
""" % (form['password'].value if 'password' in form else '', roundnum)
        allchecks(form["event"].value, form)
    output.printLink(form, 'export?type=checks', 'Download as TSV')
    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #11
0
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - mark as checked</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Deck Checks</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'deckcheck'):
        return
    if "table" in form and form['table']:
        mark_checked(form["event"].value,
                     table=int(form["table"].value),
                     seat=int(form["seat"].value) if 'seat' in form else 0,
                     remove=form["remove"] if 'remove' in form else False,
                     roundnum=form['round'].value if 'round' in form else None)
        print """<script language="JavaScript" type="text/javascript"><!--
		setTimeout("window.history.go(-1)",3000);
		//--></script>"""

    elif 'player' in form and form['player']:
        mark_checked(form["event"].value,
                     player=form["player"].value,
                     seat=int(form["seat"].value) if 'seat' in form else 0,
                     remove=form["remove"] if 'remove' in form else False,
                     roundnum=form['round'].value if 'round' in form else None)
        print """<script language="JavaScript" type="text/javascript"><!--
		setTimeout("window.history.go(-2)",5000);
		//--></script>"""
    else:
        print """
<form>
			<input type='hidden' name='password' value='%s'/>
	Enter table number: <input type='text' name='table' /><input type='submit' /><br/>
	Enter player name: <input type='text' name='player' /><input type='submit' />
</form>
""" % (form['password'].value if 'password' in form else '')

    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #12
0
def login():
    """manage login page"""

    if request.method == "POST":
        username = request.POST.username.strip()
        password = request.POST.password.strip()
        # check for valid user credentials
        # set token
        if check_login(username, password):
            user = GP.select(lambda user: user.username == username).first()
            print("in")
            # set required user information
            # response.set_cookie("username",user.username)
            # response.set_cookie("user_id",user.id)
            # response.set_cookie("admin",user.admin)

            app.config["username"] = user.username
            app.config["user_id"] = user.id
            app.config["admin"] = user.admin

            # set logged in token
            token = jwt.encode({"exp": TOKEN_TIME},
                               SECRET_KEY,
                               algorithm="HS256")
            app.config["logged_in_token"] = token

            response.headers["x-access-token"] = token
            response.set_cookie("x-access-token",
                                token,
                                httponly=True,
                                expires=TOKEN_TIME,
                                secret=SECRET_KEY)
            response.set_cookie("user_data", {
                "userid": user.id,
                "username": user.username,
                "admin": user.admin
            },
                                expires=TOKEN_TIME,
                                secret=SECRET_KEY)

            # default redirect
            redirect("/user")

        return template("login.html", message="Invalid username or password")

    return template("login.html", message="")
コード例 #13
0
ファイル: recommend.py プロジェクト: mjj29/deckchecks
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Deck Checks - recommend checks</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Recommended Checks</h1>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'recommend'):
        return
    recommend_checks(form["event"].value, form)
    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #14
0
ファイル: lists.py プロジェクト: mjj29/deckchecks
def docgi():
    print """Content-type: text/html

	<html>
		<head><title>Lists</title><link rel='stylesheet' href='style.css' /></head>
		<body>
"""
    form = cgi.FieldStorage()
    with DeckDB() as db:
        db.checkEvent(form["event"].value, output)
        print "<h1>Lists excluding online</h1>"
        roundnum = db.get_round(db.getEventId(form["event"].value))
        output.pageHeader(db, form['event'].value, roundnum, form)
        print "<p>List of players who didn't submit online decklists, sorted by build table / starting table. Note, if this is not a CFB event with online decklists then this will just be the master list of all players by table numbers, with byes first on table '0', alphabetically.</p>"

    if not check_login(output, form['event'].value, form['password'].value
                       if 'password' in form else '', 'lists'):
        return
    lists(form["event"].value)
    output.printLink(form, 'root', 'Return to menu')
    print """
コード例 #15
0
ファイル: settings.py プロジェクト: mjj29/deckchecks
def docgi():
	print """Content-type: text/html

	<html>
		<head><title>Deck Checks - event settings</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Event Settings</h1>
"""
	form = cgi.FieldStorage()
	with DeckDB() as db:
		db.checkEvent(form["event"].value, output)
		currentround = db.get_round(db.getEventId(form['event'].value))
		output.pageHeader(db, form['event'].value, currentround, form)
	if not check_login(output, form['event'].value, form['password'].value if 'password' in form else '', 'settings'):
		return
	if 'name' in form:
	
		update_settings(form['event'].value, form['name'].value, form['url'].value if 'url' in form else '', form['rounds'].value if 'rounds' in form else '', form['newpassword'].value if 'newpassword' in form else '', form['pairings'].value if 'pairings' in form else '', form['team'].value if 'team' in form else '', form['decklisturl'].value if 'decklisturl' in form else '')
	else:
		with DeckDB() as db:
			id = db.getEventId(form['event'].value)
			(name, url, rounds, password, pairings, team, decklisturl) = db.getEventSettings(id)
		print """
<p>Update settings:</p>
<form method='post'>
<input type='hidden' name='password' value='%s'/>
Name: <input type='text' name='name' value='%s'/><br/>
URL: <input type='text' name='url' value='%s'/><br/>
Rounds: <input type='text' name='rounds' value='%s'/><br/>
Password: <input type='text' name='newpassword' value='%s'/><br/>
Pairings: <input type='checkbox' name='pairings' %s/><br/>
Team: <input type='checkbox' name='team' %s/><br/>
Decklist URL: <input type='text' name='decklisturl' value='%s'/><br/>
<input type='submit' />
</form>
""" % (form['password'].value if 'password' in form else '', name, url, rounds, password, 'checked="true"' if pairings else '', 'checked="true"' if team else '', decklisturl or '')
	output.printLink(form, 'root', 'Return to menu')
	print """
コード例 #16
0
ファイル: views.py プロジェクト: Chalebgwa/EPR
def login():
    """manage login page"""

    # if route accessed by redirect from decorated route
    if request.query:
        rdr = request.query["rdr"]
        app.config["rdr"] = "/{}".format(rdr)

    if request.method == "POST":
        username = request.POST.username.strip()
        password = request.POST.password.strip()

        # check for valid user credentials
        # set token
        if check_login(username, password):
            user = GP.select(lambda user: user.username == username).first()

            # set required user information
            app.config["username"] = user.username
            app.config["user_id"] = user.id

            # set logged in token
            token = jwt.encode({"exp": TOKEN_TIME},
                               SECRET_KEY,
                               algorithm="HS256")
            app.config["logged_in_token"] = token

            # redirect to route given by decorator
            if "rdr" in app.config.keys():
                rdr = app.config.pop("rdr")
                redirect(rdr)

            # default redirect
            redirect("/patients")

    return template("views/login.html")
コード例 #17
0
ファイル: import.py プロジェクト: mjj29/deckchecks
def docgi():
			
	print """Content-type: text/html

	<html>
		<head><title>Deck Checks - import data</title><link rel='stylesheet' href='style.css' /></head>
		<body>
			<h1>Import data</h1>
"""
	form = cgi.FieldStorage()
	with DeckDB() as db:
		db.checkEvent(form["event"].value, output)
		currentround = db.get_round(db.getEventId(form['event'].value))
		url = db.getEventUrl(db.getEventId(form['event'].value))
		output.pageHeader(db, form['event'].value, currentround, form)
	if not check_login(output, form['event'].value, form['password'].value if 'password' in form else '', 'import'):
		return
	if 'clear' in form:
		clear = True if form['clear'].value else False
	else:
		clear = False
	if 'round' in form:
		roundnum = int(form['round'].value)
	else:
		roundnum = 0
	if 'datafile' in form and form['datafile'].value:
		import_data(form["event"].value, form["type"].value, form['datafile'].file.read(), clear, roundnum)
	elif 'pairingsurl' in form and form['pairingsurl'].value:
		importAllDataURL(form['event'].value, form['pairingsurl'].value, clear)
	elif "data" in form:
		import_data(form["event"].value, form["type"].value, form["data"].value, clear, roundnum)
	else:
		print """
<div>
<form method='post' enctype="multipart/form-data">
	<input type='hidden' name='password' value='%s'/>
	Clear data: <input type='checkbox' name='clear' value='true' /> [resets all tournament data including checks]<br/>
	Import all data from Pairings URL: <input type='text' name='pairingsurl' value='%s'/> <input type='submit'/>
</form>
</div>
<div>
<form method='post' enctype="multipart/form-data">
	<input type='hidden' name='password' value='%s'/>
	Enter data:
	<select name='type'>
		<option value='pairings' selected='true'>Pairings</option>
		<option value='seatings'>Seatings</option>
	</select><br/>
	Clear data: <input type='checkbox' name='clear' value='true' />[if importing seating resets all tournament data including checks]<br/>
	Import round: <input type='text' name='round' value='%s' /><br/>
	Import from file: <input type='file' name='datafile' /><br/>
	<input type='submit' />
	<textarea name='data' cols='80' rows='20'></textarea><br/>
</form>
</div>
<h2>Instructions</h2>
<p>
The simplest way to import data for a GP or other event on CFB pairings site is just to put the pairings URL into the top form. That will load all data up until this point, assuming R1 pairings are original decklist tables and all byes are sorted alphabetically. For more complex use cases, use the other forms. You can manually important seatings and then use the URL import to load the pairings, as long as you do not use clear.
</p>
<p>
There is also support for using mtgpairings.com to import from a URL. Put the event page URL into the URL dialog. This is the simplest way to import data for WER-based events.
</p>
<p>
For WER-based events, print pairings-by-name to file as a PDF, open the PDF, select the whole page (ctrl-A), copy and paste them in. Round one pairings will be used as seatings.
</p>
<h3>Seatings</h3>
<p>
Seatings should be tab-separated, two columns:
</p>
<pre>Original table or player number &lt;tab&gt; Surname, First Names</pre>
<p>
(The name should match exactly the format that WLTR will produce for pairings).
</p>
<p>
You can get this by having 2 columns in Excel, selecting and copying them, then pasting into this dialog. Select 'Clear data' to replace existing seatings. Deselect if you want to add further seatings (such as byes) in addition to the current seatings. The 'Import round' field is ignored for seatings.
</p>
<h3>Pairings</h3>
<p>
Pairings can either be copied from WLTR, in which case the format should be:
</p>
<pre>"Table","Surname, Forename","Country","Points","Surname, Forename","Country","Points"</pre>
<p>
Alternatively, they can be copied from <a href="http://pairings.channelfireball.com/pairings">http://pairings.channelfireball.com/pairings</a>. In that case, just use select-all, copy then past into this dialog. That will be in the format:
</p>
<pre>Table &lt;tab&gt; Surname, Firstname &lt;tab&gt; Score &lt;tab&gt; Surname, Firstname </pre>
<p>NOTE: this will only work in <b>Firefox</b>, <b>Chrome</b> or <b>Safari</b>. It won't work in Internet Explorer or Edge.</p>
<p>NOTE: you will see warnings failing to import the header and footer of the page. This is entirely normal.</p>
<p>
Select 'Clear data' to replace existing pairings for a round. Leave unselected to import new pairings for a round.
</p>
<h3>Adding late players</h3>
<p>
If you do nothing and import pairings containing the new players they will be imported with a start table of 0. Alternatively, 
You can enter a line like:<br/>
&lt;number&gt;&lt;tab&gt;&lt;surname, name&gt;<br/>
Import seatings without clear and this will add an additional player with the given starting table number.
</p>
""" % (form['password'].value if 'password' in form else '', url,form['password'].value if 'password' in form else '',  currentround+1)

	output.printLink(form, 'root', 'Return to menu')
	print """
コード例 #18
0
ファイル: root.py プロジェクト: mjj29/deckchecks
cgitb.enable()
output = HTMLOutput()

print """Content-type: text/html

<html>
<head><title>Deck Checks - root</title><link rel='stylesheet' href='style.css' /></head>
<body>
<h1>Deck Checks</h1>
"""
form = cgi.FieldStorage()
with DeckDB() as db:
    db.checkEvent(form["event"].value, output)
    roundnum = db.get_round(db.getEventId(form["event"].value))
    output.pageHeader(db, form['event'].value, roundnum, form)
if check_login(output, form['event'].value,
               form['password'].value if 'password' in form else '', 'root'):
    output.printLink(form, 'get_table', 'Lookup by table')
    output.printLink(form, 'get_player', 'Lookup by player')
    output.printLink(form, 'top_tables', 'Check top tables')
    output.printLink(form, 'recommend', 'Recommend checks')
    output.printLink(form, 'lists', 'Show offline lists')
    output.printLink(form, 'allchecks', 'See all checks')
    output.printLink(form, 'pairings', 'Pairings')
    output.printLink(form, 'import', 'Import data')
    output.printLink(form, 'settings', 'Event settings')
print """
</body>
</html>
"""