Exemplo n.º 1
0
def index():
    name = None
    form = NameForm()
    if form.validate_on_submit():
        name = form.name.data
        form.name.data = ''
    return render_template('123.html', form=form, name=name)
Exemplo n.º 2
0
def Review_Extraction():
    name = None
    form = NameForm()
    if form.validate_on_submit():

        name = form.name.data

        old_width = pandas.get_option('display.max_colwidth')
        pandas.set_option('display.max_colwidth', -1)

        df = review_content.review_fc(name)
        form.name.data = ''
        columns = ['Person', 'SBV', 'speech_content', 'sentence']
        return render_template('review_extraction.html',
                               title='Zh_Cola',
                               form=form,
                               tables=[
                                   df.to_html(classes='data',
                                              escape=True,
                                              index=True,
                                              sparsify=False,
                                              border=1,
                                              index_names=False,
                                              header=True,
                                              columns=columns)
                               ],
                               titles=df.columns.values)

        pandas.set_option('display.max_colwidth', old_width)
    else:
        return render_template('review_extraction.html',
                               title='Zh_Cola',
                               form=form)
Exemplo n.º 3
0
def index():
    form = NameForm()
    if form.validate_on_submit():
        # Create new db entry for current game session with name. Or can do this at the end.
        session['name'] = form.name.data
        session['score'] = 0
        return redirect(url_for("play"))
    return render_template("enter-name.html", form=form)
Exemplo n.º 4
0
def GetCustomer():
    form = NameForm()

    if form.validate_on_submit():
        full_name = form.full_name.data
        customer = Customer.query.filter_by(full_name=full_name).first()
        search_cust_id = customer.cust_id
        return redirect(url_for('result', search_cust_id=search_cust_id))

    return render_template('form.html', title='Get Customer', form=form)
Exemplo n.º 5
0
def index():
    name = None
    form = NameForm()

    if form.validate_on_submit():
        name = form.name.data
        print(form.name.data)
        form.name.data = ""
        return redirect(url_for("user", name=name))

    return render_template("index.html", form=form, name=name)
Exemplo n.º 6
0
def form():
    form = NameForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            name = request.form['name']
            surname = request.form['surname']
            age = request.form['age']
            user = Name(name=name, surname=surname, age=age)
            db.session.add(user)
            db.session.commit()
            return redirect(url_for('home'))
    return render_template('nameform.htm', form=form)
Exemplo n.º 7
0
def hello():
    form = NameForm()

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()
        return redirect("")

    data = User.query.all()
    return render_template('bootstrap-form.html', form=form, data=data)
Exemplo n.º 8
0
def charAdder():
    form = NameForm()
    if form.validate_on_submit():
        nameGen.titles.append(form.title.data)
        nameGen.names.append(form.name.data)
        nameGen.descriptors.append(form.descriptor.data)
        flash('Added {} {} the {}'.format(form.name.data, form.title.data,
                                          form.descriptor.data))
        return redirect('/index')
    return render_template('charadder.html',
                           title='Character Adder',
                           form=form)
Exemplo n.º 9
0
def get_name(request):
   # if this is a POST request we need to process the form data
   if request.method == 'POST':
      # create a form instance and populate it with data from the request:
      form = NameForm(request.POST)
      # check whether it's valid:
      if form.is_valid():
         # process the data in form.cleaned_data as required
         return HttpResponseRedirect('/thanks/')

    # if a GET (or any other method) we'll create a blank form
   else:
      form = NameForm()

   return render(request, 'name.html', {'form': form})
Exemplo n.º 10
0
def StopMultipleJobs(request):
    print "KILL ALL"
    form = NameForm(request.POST)
    my_stb = request.POST.getlist('check2')
    print len(my_stb)
    counter_4 = 0
    while counter_4 < len(my_stb):
        print str(my_stb[counter_4])
        x = str(my_stb[counter_4])
        print x.split(",")[0]
        print x.split(",")[1]
        my_job = x.split(",")[0]
        my_build = int(x.split(",")[1])
        j = jenkins.Jenkins('http://localhost:8080', 'jenkins', 'jenkins123')
        try:
            queue_info = j.get_build_info(my_job, my_build)
            print "...Job is in progress: "
            j.stop_build(my_job, my_build)
        except jenkins.NotFoundException:
            print "......JOB IN QUEUE"
            j.cancel_queue(my_build)
        counter_4 = counter_4 + 1
    assert isinstance(request, HttpRequest)

    return HttpResponseRedirect("home")

    return render(request, "app/JobStatusFile.json",
                  RequestContext(request, {}))
Exemplo n.º 11
0
def updateform(id):
    query = Name.query.get(id)
    if query:
        form = NameForm(request.form, obj=query)
        if request.method == 'POST' and form.validate_on_submit:
            name = request.form['name']
            surname = request.form['surname']
            age = request.form['age']
            query.name = name
            query.surname = surname
            query.age = age
            db.session.add(query)
            db.session.commit()
            flash('Name updated successfully')
            return redirect(url_for('home'))
    return render_template('updateform.htm', form=form)
Exemplo n.º 12
0
def test():
    form = NameForm()
    return render_template('test.html', title='not sure', form=form)
Exemplo n.º 13
0
def Revo_view(request):
    if request.method == 'POST':
        form = NameForm(request.POST)
    else:
        form = NameForm()
    print request.POST.getlist('checks')
    print request.POST.getlist('optradio')

    form = NameForm(request.POST)
    stb1 = request.POST.getlist('optradio')
    list1 = request.POST.getlist('checks')
    cd1 = "<command>"
    cd2 = "</command>"
    test_runner_path2 = "cd C:\git_new\evo_automation\ tests\TestRunner"
    # request.POST.getlist('check1')

    STB = ', '.join(stb1)

    TestSuite = ', '.join(list1)
    # TestSuite1 = "REG_AGREED_SUITE02"
    report_location = "C:\git_new\evo_automation\ tests\TestRunner\ReportFile C:\git_new\evo_automation\ reports"

    # mycommand2 = cd1 + test_runner_path2 + "\n" + STB + "\n" + TestSuite + "\nTrue \n" + report_location + cd2
    mycommand2 = cd1 + "import time" + "\n" + "time.sleep(500)" + cd2
    print "mycommand2", mycommand2

    myNewJob = STB
    myXML = "<?xml version='1.0' encoding='UTF-8'?><project><actions/><description></description><keepDependencies>false</keepDependencies><properties/><scm class='hudson.scm.NullSCM'/><canRoam>true</canRoam><disabled>false</disabled><blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding><blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding><triggers/><concurrentBuild>false</concurrentBuild><builders><hudson.plugins.python.Python plugin='[email protected]'><command>RawComamnd</command></hudson.plugins.python.Python></builders><publishers/><buildWrappers/></project>"

    j = jenkins.Jenkins('http://localhost:8080', 'jenkins', 'jenkins123')

    if not j.job_exists(myNewJob):
        j.create_job(myNewJob, myXML)
        j.enable_job(myNewJob)
        jobConfig = j.get_job_config(myNewJob)
        ###### print "Before RECONFIG"
        ###### print j.get_job_config(myNewJob)

        ######Start: to retrieve previous command######
        tree = ET.XML(jobConfig)
        with open("temp.xml", "w") as f:
            f.write(ET.tostring(tree))

        document = parse('temp.xml')
        actors = document.getElementsByTagName("command")

        for act in actors:
            for node in act.childNodes:
                if node.nodeType == node.TEXT_NODE:
                    r = "{}".format(node.data)

        prev_command = cd1 + r + cd2
        ######End: to retrieve previous command######

        shellCommand = jobConfig.replace(prev_command, mycommand2)
        j.reconfig_job(myNewJob, shellCommand)

        ###### print "RECONFIG"
        ###### print j.get_job_config(myNewJob)

        j.build_job(myNewJob)

        # #####  Start: code to get job status   ######
        current_build_number = j.get_job_info(myNewJob)['nextBuildNumber']
        print "Current Build Number : ", current_build_number
        print "Job Building In Progress -"
        time.sleep(15)
        build_info = j.get_build_info(myNewJob, current_build_number)

        if str(build_info['result']) == 'SUCCESS':
            print "+++++    BUILD COMPLETED"
            print build_info['displayName']
        elif str(build_info['result']) == 'FAILURE':
            print "XXXXX    BUILD FAILED"
            print build_info['displayName']
        elif str(build_info['result']) == 'None':
            print "......   JOB IN PROGRESS"
            print build_info['displayName']
        else:
            print "HOLA"
            print build_info['displayName']
        #####  End: code to get job status   ######

        #####  Start: code to get Job Start Time   ######
        startTime1 = str(build_info['timestamp'])
        # print startTime1
        ####reduce the time by 5 hrs as tfhe jenkin time is coming 5 hrs extra##########
        startTime1 = int(startTime1) - 18000000
        startTime2 = float(startTime1) / 1000
        # print (startTime2)
        # print time.gmtime(startTime2)
        print time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(startTime2))

    else:
        j.enable_job(myNewJob)
        jobConfig = j.get_job_config(myNewJob)
        print "Before RECONFIG"
        print j.get_job_config(myNewJob)
        tree = ET.XML(jobConfig)
        with open("temp.xml", "w") as f:
            f.write(ET.tostring(tree))

        document = parse('temp.xml')
        actors = document.getElementsByTagName("command")

        for act in actors:
            for node in act.childNodes:
                if node.nodeType == node.TEXT_NODE:
                    r = "{}".format(node.data)

        prev_command = cd1 + r + cd2

        shellCommand = jobConfig.replace(prev_command, mycommand2)
        j.reconfig_job(myNewJob, shellCommand)

        print "RECONFIG"
        print j.get_job_config(myNewJob)

        j.build_job(myNewJob)

        # #####  Start: code to get job status   ######
        current_build_number = j.get_job_info(myNewJob)['nextBuildNumber']
        print "Current Build Number : ", current_build_number

        prv_build_number = j.get_job_info(myNewJob)['lastBuild']['number']
        print "Last Build Number :", prv_build_number

        i = 0
        while (i < 6) and (current_build_number != prv_build_number):
            print "Status In Progress -", i
            time.sleep(2)
            i = i + 1
            prv_build_number = j.get_job_info('sample')['lastBuild']['number']
        else:
            print "Job completed -", current_build_number

        try:

            build_info = j.get_build_info(myNewJob, current_build_number)
            startTime1 = str(build_info['timestamp'])
            # print startTime1
            ####reduce the time by 5 hrs as tfhe jenkin time is coming 5 hrs extra##########
            startTime1 = int(startTime1) - 18000000
            startTime2 = float(startTime1) / 1000
            # print (startTime2)
            # print time.gmtime(startTime2)
            print time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(startTime2))
            #####  Start: code to get Job Start Time   ######
            if str(build_info['result']) == 'SUCCESS':
                print "+++++    BUILD COMPLETED"
                status = "JOB COMPLETED"
                print build_info['displayName']
            elif str(build_info['result']) == 'FAILURE':
                print "XXXXX    BUILD FAILED"
                status = "JOB FAILED"
                print build_info['displayName']
            elif str(build_info['result']) == 'None':
                print "......   JOB IN PROGRESS"
                status = "JOB IN PROGRESS"
                print build_info['displayName']
            else:
                print "HOLA"
                print build_info['displayName']
        except jenkins.NotFoundException:
            print "......JOB IN QUEUE"
            status = "JOB IN QUEUE"
            startTime2 = 000000
            pass
        #####  End: code to get job status   ######

        #####  Start: code to get Job Start Time   ######

        logToJobFile(
            str(STB) + "," + str(TestSuite) + "," + str(current_build_number) +
            "," + str(status) + "," +
            time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(startTime2)))

        return HttpResponseRedirect("home")

    return render(request, 'app/layout.html', {'form': form})
Exemplo n.º 14
0
def Revo_view(request):
    if request.method == 'POST':
        form = NameForm(request.POST)
    else:
        form = NameForm()
    print request.POST.getlist('check1')
    print request.POST.getlist('checks')
    ###start: passing username
    # if request.method == 'POST':
    # form = BootstrapAuthenticationForm(request.POST)
    # else:
    # form = BootstrapAuthenticationForm()

    # username = request.POST.getlist('username')
    # print username
    ###end: passing username
    cd1 = "<command>"
    cd2 = "</command>"
    test_runner_path2 = "cd C:\git_new\evo_automation\ tests\TestRunner"
    report_location = "C:\git_new\evo_automation\ tests\TestRunner\ReportFile C:\git_new\evo_automation\ reports"
    mycommand2 = cd1 + "import time" + "\n" + "time.sleep(500)" + cd2
    myXML_1 = "<?xml version='1.0' encoding='UTF-8'?><project><actions/><description></description><keepDependencies>false</keepDependencies><properties><hudson.model.ParametersDefinitionProperty><parameterDefinitions><hudson.model.StringParameterDefinition><name>param1</name><description></description><defaultValue></defaultValue></hudson.model.StringParameterDefinition><hudson.model.StringParameterDefinition><name>param2</name><description></description><defaultValue></defaultValue></hudson.model.StringParameterDefinition></parameterDefinitions></hudson.model.ParametersDefinitionProperty></properties><scm class='hudson.scm.NullSCM'/><canRoam>true</canRoam><disabled>false</disabled><blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding><blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding><triggers/><concurrentBuild>false</concurrentBuild><builders><hudson.plugins.python.Python plugin='[email protected]'><command>i am a new job</command></hudson.plugins.python.Python></builders><publishers/><buildWrappers/></project>"
    myXML = "<?xml version='1.0' encoding='UTF-8'?><project><actions/><description></description><keepDependencies>false</keepDependencies><properties/><scm class='hudson.scm.NullSCM'/><canRoam>true</canRoam><disabled>false</disabled><blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding><blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding><triggers/><concurrentBuild>false</concurrentBuild><builders><hudson.plugins.python.Python plugin='[email protected]'><command>RawComamnd</command></hudson.plugins.python.Python></builders><publishers/><buildWrappers/></project>"

    j = jenkins.Jenkins('http://localhost:8080', 'jenkins', 'jenkins123')

    form = NameForm(request.POST)
    my_stb = request.POST.getlist('check1')
    my_test_suite = request.POST.getlist('checks')
    count1 = 0
    for s in my_stb:
        count2 = 0
        for t in my_test_suite:
            print my_stb[count1], ' : ', my_test_suite[count2]

            if not j.job_exists(my_stb[count1]):
                j.create_job(my_stb[count1], myXML_1)
                j.enable_job(my_stb[count1])
                jobConfig = j.get_job_config(my_stb[count1])

                tree = ET.XML(jobConfig)
                with open("temp.xml", "w") as f:
                    f.write(ET.tostring(tree))

                document = parse('temp.xml')
                actors = document.getElementsByTagName("command")

                for act in actors:
                    for node in act.childNodes:
                        if node.nodeType == node.TEXT_NODE:
                            r = "{}".format(node.data)

                prev_command = cd1 + r + cd2

                shellCommand = jobConfig.replace(prev_command, mycommand2)
                j.reconfig_job(my_stb[count1], shellCommand)
                j.build_job(my_stb[count1], {'param1': my_test_suite[count2]})

            else:
                j.enable_job(my_stb[count1])
                jobConfig = j.get_job_config(my_stb[count1])
                print "Before RECONFIG"
                #                 print j.get_job_config(my_stb[count1])
                tree = ET.XML(jobConfig)
                with open("temp.xml", "w") as f:
                    f.write(ET.tostring(tree))

                document = parse('temp.xml')
                actors = document.getElementsByTagName("command")

                for act in actors:
                    for node in act.childNodes:
                        if node.nodeType == node.TEXT_NODE:
                            r = "{}".format(node.data)

                prev_command = cd1 + r + cd2

                shellCommand = jobConfig.replace(prev_command, mycommand2)
                j.reconfig_job(my_stb[count1], shellCommand)

                print "RECONFIG"
                #                 print j.get_job_config(my_stb[count1])
                j.build_job(my_stb[count1], {'param1': my_test_suite[count2]})
                count2 = count2 + 1
#                 j.build_job(name, parameters, token)
        count1 = count1 + 1

    return HttpResponseRedirect("home")

    return render(request, 'app/layout.html', {'form': form})