コード例 #1
0
def index():
    # initialize form
    form = ScrapeForm()

    # POST method
    if form.validate_on_submit():

        # run scraping program with argument values from  Form
        filename, err, errmsg = driver.main(search_str=request.form["item"], pages=int(
            request.form["page"]), site=request.form["site"])

        # render hompage with errors if any
        if err:
            print(f"ERROR: {errmsg}")
            return render_template("index.html", sites=sites, form=form)

        state = {"site": request.form["site"], "item": request.form["item"]}
        state["filename"] = os.path.join(ROOT_DIR, filename)
        session["info"] = state
        # redirect to results page if no errors occur
        return redirect(url_for("result"))

    # GET method return homepage

    return render_template("index.html", sites=sites, form=form)
コード例 #2
0
ファイル: systemtest.py プロジェクト: strangemonad/cplr
def testCreateDriverWithCompilerInstance():
   source = path.join("tests", "scanner", "average_text_correct")
   
   env = environment.empty()
   env[environment.LAST_PHASE] = "scanner"
   result = driver.main([source, TMP_OUT], compiler=Compiler(env))
   assertEqual(0, result)
   assertNoDiff(TMP_OUT, source + ".expect")
   os.remove(TMP_OUT)
コード例 #3
0
def main():
    m_max = 25
    obj_size = 1
    default_radius = 5
    default_num_agents = 20
    default_vol_prob = 0.01
    TIME_LIMIT = 1500
    num_exp = 40

    ms = np.linspace(10, m_max, m_max + 1 - 10, endpoint=True, dtype=int)
    radii = np.linspace(1, m_max, m_max + 1, endpoint=True, dtype=int)
    #num_agents = np.array([1, 3, 5, 7])
    num_agents = np.linspace(1, m_max, m_max, endpoint=True, dtype=int)
    probabilities = np.linspace(0, 1, 20, endpoint=False)

    m = m_max

    # time_results = np.zeros((radii.size, num_agents.size, num_exp))
    # for i in range(radii.size):
    #     for j in range(num_agents.size):
    #         for k in range(num_exp):
    #             t = dr.main(m, num_agents[j], 0, radii[i], 1, 5000, default_vol_prob, TIME_LIMIT = TIME_LIMIT)
    #             time_results[i,j,k] = t
    #             print 'Time ' + str(t) + ' radius ' + str(radii[i]) + ' num_agents ' + str(num_agents[j])
    # for i in range(num_exp):
    #     print time_results[:,:,i]

    # print '~~~~~~~~~~~~~~~~~~~~~~~~~~'
    # print np.mean(time_results, axis = 2)

    # filename = 'objsize' + str(obj_size) + '_numexp' + str(num_exp) + '_timelimit' + str(TIME_LIMIT) + '_m' + str(m)
    # np.save(filename, time_results)

    probability_results = np.zeros([probabilities.size, num_exp])
    for i in range(probabilities.size):
        for k in range(num_exp):
            t = dr.main(m,
                        m,
                        0,
                        4,
                        1,
                        5000,
                        probabilities[i],
                        TIME_LIMIT=TIME_LIMIT)
            probability_results[i, k] = t
            print 'Time ' + str(t) + ' prob ' + str(probabilities[i])
    for i in range(num_exp):
        print probability_results[:, i]

    print '~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print np.mean(probability_results, axis=1)

    filename = 'probability_results_objsize' + str(obj_size) + '_numexp' + str(
        num_exp) + '_timelimit' + str(TIME_LIMIT) + '_m' + str(m) + '_r' + str(
            4)
    np.save(filename, probability_results)
コード例 #4
0
ファイル: hello.py プロジェクト: zabihyousuf/ramhacks19
def download(filename):
    BUCKET_NAME = 'danielyenegeta.com'  # replace with your bucket name
    driver.main(filename)
    KEY = filename + ".pdf"  # replace with your object key

    # Create an S3 client
    s3 = boto3.client('s3')
    s3.upload_file(KEY, BUCKET_NAME, KEY)
    os.remove(KEY)

    s3 = boto3.resource('s3')

    try:
        s3.Bucket(BUCKET_NAME).download_file(KEY, filename + 'report.pdf')
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Code'] == "404":
            print("The object does not exist.")
        else:
            raise

    return render_template('/home.html')
コード例 #5
0
ファイル: main.py プロジェクト: mmohades/SafeFace
def loop():

    global touched
    while True:
        if GPIO.input(TouchPin) == GPIO.LOW:
            touched = False
        else:
            print("Touched")
            write_lcd("take_pic")
            touched = True
            result = main()
            write_lcd(result["status"])
            sleep(2)
コード例 #6
0
ファイル: bbbar.py プロジェクト: toyokazu-sekiguchi/depoDM
def run_driver(mass, sigmav):
    str_mass = str(mass)
    str_sigmav = str(sigmav)

    f1 = "constraints/bbbar/bbbar_" + str_mass + "GeV_" + str_sigmav + "_params.ini"
    contents1 = []
    for s in contents0:
        contents1.append(
            s.replace("XXX_YYY",
                      str_mass + "GeV_" + str_sigmav + "cm^3sec^{-1}").replace(
                          "XXX", str_mass).replace("YYY", str_sigmav))

    with open(f1, "w") as f:
        f.writelines(contents1)

    return driver.main(f1, 0)
コード例 #7
0
ファイル: update.py プロジェクト: AtomicLemon/SpotifyGist
# -*- coding: utf-8 -*-
import subprocess

from github import Github
from github.InputFileContent import InputFileContent

from credentials import CREDS
from driver import main
from driver import getlongterm

subprocess.call(["python", "driver.py"])

g = Github(CREDS['TOKEN'])
spotify_gist = g.get_gist(CREDS['GIST_ID'])
#spotify_gist_long_term = g.get_gist('20d9ea0342b543a1460fd13be64a7c60')
f = InputFileContent(main())
eggs = InputFileContent(getlongterm())
spotify_gist.edit('🎧 My music activity',
                  {'🎧 My music activity over the last 4 weeks': f})
#spotify_gist_long_term.edit('🎧 My music activity over the last 6 months',
#                  {'🎧 My music activity over the last 6 months': eggs})
spotify_gist.edit('🎧 My music activity',
                  {'🎧 My music activity over the last 6 months': eggs})
コード例 #8
0
ファイル: redo.py プロジェクト: sud03r/code-samples
import sys
sys.path.insert(0, './src')
import driver

if len(sys.argv) < 2:
	print 'Usage: %s dataset-dir' % sys.argv[0]
else:
	dataset = sys.argv[1] + '/cifar-10-batches-py/';
	driver.main(dataset)
コード例 #9
0
import driver

global RETRIEVAL_LOW_CC, RETRIEVAL_HIGH_CC, STRATEGY_HIGH_CC, STRATEGY_LOW_CC
global INCR_RIGHT, INCR_WRONG, DECR_WRONG
global epoch, learning_rate, n_problems, strategies, ndups, DR_threshold, experiment_label

ndups = 3 # Number of replicates of each combo of params -- usually 3 unless testing.

strategies = [ADD.count_from_either_strategy, ADD.random_strategy, ADD.count_from_one_once_strategy,
              ADD.count_from_one_twice_strategy, ADD.min_strategy] # ADD.random_strategy

# The settings.experiment_label is used by the analyzer to label the
# results file because we set these by exec(), this has to have an
# extra set of "\"quotes\"" around it.

scan_spec = {"settings.experiment_label": ["\"201508091017 Scanning n problems but should do some dynamic retrieval near the end\""],
             "settings.n_problems": [1000,5000],
             "settings.RETRIEVAL_LOW_CC": [0.9],
             "settings.RETRIEVAL_HIGH_CC": [1.0],
             "settings.STRATEGY_LOW_CC": [0.9],
             "settings.STRATEGY_HIGH_CC": [1.0],
             "settings.epoch": [10],
             "settings.INCR_RIGHT": [5],
             "settings.INCR_WRONG": [1],
             "settings.DECR_WRONG": [0.5],
             "settings.learning_rate": [0.1],
             "settings.DR_threshold": [0.8]}

if __name__ == '__main__':
    driver.main()
コード例 #10
0
ファイル: runtest.py プロジェクト: OS2World/APP-SERVER-Zope
def main():
    opts = []
    args = sys.argv[1:]
    quiet = 0
    unittesting = 0
    if args and args[0] == "-q":
        quiet = 1
        del args[0]
    if args and args[0] == "-Q":
        unittesting = 1
        del args[0]
    while args and args[0].startswith('-'):
        opts.append(args[0])
        del args[0]
    if not args:
        prefix = os.path.join("tests", "input", "test*.")
        if tests.utils.skipxml:
            xmlargs = []
        else:
            xmlargs = glob.glob(prefix + "xml")
            xmlargs.sort()
        htmlargs = glob.glob(prefix + "html")
        htmlargs.sort()
        args = xmlargs + htmlargs
        if not args:
             sys.stderr.write("No tests found -- please supply filenames\n")
             sys.exit(1)
    errors = 0
    for arg in args:
        locopts = []
        if arg.find("metal") >= 0 and "-m" not in opts:
            locopts.append("-m")
        if not unittesting:
            print arg,
            sys.stdout.flush()
        if tests.utils.skipxml and arg.endswith(".xml"):
            print "SKIPPED (XML parser not available)"
            continue
        save = sys.stdout, sys.argv
        try:
            try:
                sys.stdout = stdout = StringIO()
                sys.argv = [""] + opts + locopts + [arg]
                driver.main()
            finally:
                sys.stdout, sys.argv = save
        except SystemExit:
            raise
        except:
            errors = 1
            if quiet:
                print sys.exc_type
                sys.stdout.flush()
            else:
                if unittesting:
                    print
                else:
                    print "Failed:"
                    sys.stdout.flush()
                traceback.print_exc()
            continue
        head, tail = os.path.split(arg)
        outfile = os.path.join(
            head.replace("input", "output"),
            tail)
        try:
            f = open(outfile)
        except IOError:
            expected = None
            print "(missing file %s)" % outfile,
        else:
            expected = f.readlines()
            f.close()
        stdout.seek(0)
        if hasattr(stdout, "readlines"):
            actual = stdout.readlines()
        else:
            actual = readlines(stdout)
        if actual == expected:
            if not unittesting:
                print "OK"
        else:
            if unittesting:
                print
            else:
                print "not OK"
            errors = 1
            if not quiet and expected is not None:
                showdiff(expected, actual)
    if errors:
        sys.exit(1)
コード例 #11
0
import driver, chordMappings

maxHalfLifeInMinutes = 0.1
numberOfAtoms = 50
chordMapping = chordMappings.CMajToFMaj()

driver.main(maxHalfLifeInMinutes, numberOfAtoms, chordMapping)
コード例 #12
0
def viewscore(request):

    stud_ans = request.POST.getlist('ans')
    reload_count = request.POST.get('reload_count')
    back_pressed = request.POST.get('back_pressed')
    tab_switch_count = request.POST.get('tab_switch_count')

    print "reload count is "
    print reload_count
    print "back pressed?"
    print back_pressed
    print "tab_switch_count"
    print tab_switch_count

    test_code = request.session['test_code']
    test_instance = Test.objects.get(test_code=test_code)
    ques_nos_string = test_instance.question_nos
    ques_nos_list = ques_nos_string.split(",")
    final_score_list = []
    scores = []
    s_email = request.session['s_email']
    for i in range(len(ques_nos_list)):
        train_file = QuestionBank.objects.get(id=ques_nos_list[i]).train_file
        student_answer = stud_ans[i]
        print "Evaluating answer no. " + str(i)
        print "Training file used is " + str(train_file)
        # blockPrint()
        scores.append(driver.main([student_answer], train_file))
        enablePrint()

    print scores
    score1_LSA = scores[0]['lsa']
    score1_LSA = int(score1_LSA[0])
    score1_IG = scores[0]['ig']
    score1_IG = int(score1_IG[0])
    score2_LSA = scores[1]['lsa']
    score2_LSA = int(score2_LSA[0])
    score2_IG = scores[1]['ig']
    score2_IG = int(score2_IG[0])
    final_score1 = int(math.ceil((float(score1_LSA) + float(score1_IG)) / 2))
    final_score2 = int(math.ceil((float(score2_LSA) + float(score2_IG)) / 2))
    # marks = str(final_score1.append(",").append(final_score2))
    marks = str(final_score1) + ", " + str(final_score2)
    print "Final marks are "
    print marks
    test_result = Test_Result.objects.create(
        test=test_instance,
        user_email=s_email,
        test_marks=marks,
        reload_count=str(reload_count),
        back_pressed=str(back_pressed),
        tab_switch_count=str(tab_switch_count))
    template = loader.get_template('short_answer/viewscore.html')

    context = {
        'score1_LSA': str(score1_LSA),
        'score1_IG': str(score1_IG),
        'score2_LSA': str(score2_LSA),
        'score2_IG': str(score2_IG)
    }
    return HttpResponse(template.render(context, request))
コード例 #13
0
ファイル: coarsegrind.py プロジェクト: jballands/CoarseGrind
#
# CoarseGrind: The automated Virginia Tech course grinding script.
# (C)2013 All rights reserved. Created with love by Jonathan Ballands.
#
# ATTENTION: Distribution of this script via means other than GitHub is
# prohibited. To download, please visit: github.com/jballands/coarsegrind
#
# For more information, visit jonathanballands.me./portfolio/coarsegrind.html
#
# coarsegrind.py
# File that is run to start CoarseGrind.
#

import sys, driver

# Start CoarseGrind
driver.main(sys.argv[1:])
sys.exit(0)
コード例 #14
0
def main():
    try:
        connect()
        driver.main()
    except:
        main()
コード例 #15
0
import os
import driver
import numpy

input_ = "sudokus_start.txt"
result_ = "sudokus_finish.txt"

# Read all the sudokus
input_file = open(input_)
in_sudokus = input_file.readlines()
result_file = open(result_)
ou_sudokus = result_file.readlines()

# Iterate over all the sudokus
for sudoku_in, sudoku_res in zip(in_sudokus, ou_sudokus):
    line_in = sudoku_in[:-1]
    line_ou = sudoku_res[:-1]

    # Pass throught the solver
    result = driver.main(line_in, "Out.txt")
    if result != line_ou:
        print("Sudoku solved ")
        print(result)
        
コード例 #16
0
ファイル: __main__.py プロジェクト: jhilbs3/pocketKnife
def main():
    driver.main()