Exemple #1
0
def launch_onenote():
    BetaScript(
        "Run C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"
    )
    time.sleep(1.5)
    BetaScript("send {enter}")
    time.sleep(1)
    kill("onenote.exe")
Exemple #2
0
def launch_start_up_programs():
    warmups = [[
        "powershell start microsoft-edge:http://bing.com", "MicrosoftEdge.exe"
    ], ["control.exe /name Microsoft.NetworkAndSharingCenter", None]]
    for cmd, killcmd in warmups:
        for x in range(2):
            do(cmd, "ignore")
            time.sleep(2 - x)
            kill(killcmd, True)
Exemple #3
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.3)
#    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > /tmp/file1 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" % file1);
#   time.sleep(0.1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
#   time.sleep(0.1)
#    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > /tmp/file2 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" % file2);


    time.sleep(3 *  CGI_SPIN_TIME)
    time.sleep(5) # this doesn't hurt
    if util.is_server_alive(cmd) == -1:
        util.error("Ouch! Server is dead!"
                   " Your bounded buffered may not be well protected");

    # time1 = os.path.getmtime(file1)
    # time2 = os.path.getmtime(file2)

    time_decimal1 = str(os.path.getmtime(file1))
    time_decimal2 = str(os.path.getmtime(file2))

   
    # print time_decimal1
    # print time_decimal2

    passed = Decimal(time_decimal1).compare_total(Decimal(time_decimal2)) != -1

    # passed = time1 > time2

    if passed:
        print ""
        print "#####################################"
        print "GOOD! you implement SFF correctly"
        print "#####################################"
        print ""
        count = count + 1
    else:
        print ""
        print "#####################################"
        print "Oh oh! ERROR ERROR!"
        print "SFF is not implemented correctly"
        print "#####################################"
        print ""
        sys.exit(-1)

    util.kill()
Exemple #4
0
def launch_start_up_programs():
    warmups = [
        ["powershell start microsoft-edge:http://bing.com", "MicrosoftEdge.exe"],
        ["control.exe /name Microsoft.NetworkAndSharingCenter", None]
    ]
    for cmd, killcmd in warmups:
        for x in range(2):
            do(cmd, "ignore")
            time.sleep(2-x)
            kill(killcmd, True)
Exemple #5
0
def setup_onenote():
    BetaScript("Run C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE")

    kill()
    time.sleep(2)
    BetaScript("send {right}\nsleep 200\nsend {enter}")
    time.sleep(1)
    BetaScript("send a")
    time.sleep(1)
    kill("onenote.exe")
    BetaScript("send {enter}")
Exemple #6
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.3)
    #    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > /tmp/file1 &");
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" %
        file1)
    #   time.sleep(0.1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    #   time.sleep(0.1)
    #    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > /tmp/file2 &");
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" %
        file2)

    time.sleep(3 * CGI_SPIN_TIME)
    time.sleep(5)  # this doesn't hurt
    if util.is_server_alive(cmd) == -1:
        util.error("Ouch! Server is dead!"
                   " Your bounded buffered may not be well protected")

    time1 = os.path.getmtime(file1)
    time2 = os.path.getmtime(file2)

    print time1
    print time2

    passed = time1 > time2

    if passed:
        print ""
        print "#####################################"
        print "GOOD! you implement SFF correctly"
        print "#####################################"
        print ""
        count = count + 1
    else:
        print ""
        print "#####################################"
        print "Oh oh! ERROR ERROR!"
        print "SFF is not implemented correctly"
        print "#####################################"
        print ""
        sys.exit(-1)

    util.kill()
Exemple #7
0
def resize_cio():
    script = """
    send {LWin}
    sleep 900
    click 723, 303
    sleep 900
    send #{up}
    """

    BetaScript(script)
    time.sleep(1)
    kill()
Exemple #8
0
def change_weather():
    script = """send, {Lwin}
    sleep, 1500
    send, Weather App
    sleep, 2000
    send, {enter}
    sleep, 2000
    send, {tab 2}98052{enter}"""

    BetaScript(script)
    time.sleep(2)
    kill()
Exemple #9
0
def accept_onenote_terms():
    full = "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"
    BetaScript("""
    send {LWin}
    sleep 900
    send onenote 2016
    sleep 500
    send {enter}
    """)
    p("Don't touch anything!")
    time.sleep(4.5)
    kill()
Exemple #10
0
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"

    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res2 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")

    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

    #    s = 1000000 # 1 second
    s = 1000  # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4

    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
Exemple #11
0
def change_edge():
    script = """WinActivate, Start
    sleep, 750
    Send, #{up}
    sleep, 500
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send {enter}
    sleep, 500
    Send, {up}
    sleep, 200
    send, {enter}

    sleep, 750
    send, {tab 5}
    sleep, 500
    send, {space}
    sleep, 500

    send, {tab}{space}
    sleep, 500
    send, {down 2}
    sleep 200
    send {enter}
    sleep, 500
    send, {tab}
    sleep 200
    send, {tab}
    sleep 200
    send, {enter}
    sleep, 500
    send, +{tab}
    sleep, 700
    send, aka.ms/cioS16{enter}"""
    BetaScript(script)
    time.sleep(1.2)
    kill()
Exemple #12
0
    def deal_command(self, socket, data):
        sys.path.append("..")
        import config
        import util
        if '0x01' in data:
            #摄像头操作
            global pid
            pid = Communicate().createCamereDaemon()

        elif '0x02' in data:
            #自定义命令
            cus_command = data.split(':')[1]
            if cus_command != '':
                os.system(cus_command)

        elif '0x03' in data:
            util.kill(pid)
            util.folder_move_all(config.FILE_PATH, config.PIC_PATH)

        elif '0x04' in data:
            Communicate().sendFile(socket, config.LOG_PATH)

        elif '0x05' in data:
            key = data.split(':')[1]
            value = data.split(':')[2]
            if key != '' and value != '':
                util.alter("/home/nvidia/Horus/config.py", key, value)

        elif '0x06' in data:
            global envid
            envid = Communicate().createnvDaemon()

        elif '0x07' in data:
            util.kill(envid)

        elif 'test' in data:
            pass

        else:
            if util.is_json(data):
                with open('/home/nvidia/Horus/mysql/sql.cnf') as json_data:
                    cnf = json.load(json_data)
                    db = create_engine(cnf['db'])
                    s = json.loads(data)
                    insert_data = "insert into tb_mobile_sensor(timestamp,accx,accy,accz,gpsLongitude,gpsLatitude,gpsAltitude,gpsSpeed,gpsBearing,light,deviceID,frequency) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" % (
                        s["time"], s["accx"], s["accy"], s["accz"],
                        s["longitude"], s["latitude"], s["altitude"],
                        s["speed"], s["bearing"], s["lightx"], s["deviceID"],
                        s["frequency"])
                    db.execute(insert_data)
Exemple #13
0
def launch_store():
    scripts = [""";0
    send, #3""",
    """ ;1
    WinActivate, Store
    send #{up}
    sleep 500
    click 2308, 129
    sleep 200
    send Surface""",
    """
    WinActivate, Store
    sleep 300
    send {down}
    sleep 200
    send {down}
    sleep 200
    send {down}
    sleep 200
    send {enter}""",
    """
    WinActivate, Store
    sleep, 500
    PixelGetColor, ESurfaceLogo, 2194, 342, RGB
    MouseMove, 2194, 342
    sleep 200
    send #4
    sleep 200
    send %ESurfaceLogo%
    send, {enter}
    """
    ]

    # Launch surface app then kill
    BetaScript(scripts[0])
    time.sleep(1.5)
    kill()

    # Test if surface icon appears, if not, kill everything and start again
    while True:
        time.sleep(1)
        BetaScript(scripts[0]) # just opens store
        time.sleep(0.5)
        BetaScript(scripts[1]) #
        time.sleep(1)
        if str(BetaScript(scripts[3], True)) == str('0x0078D7'):
            BetaScript(scripts[2])
            return
        else:
            kill("ApplicationFrameHost.exe")
Exemple #14
0
def set_username():
    script = """
    send #{up}
    sleep 500
    click 547 350
    sleep 500
    send {fname} {lname}
    sleep 500
    send {enter}
    """

    do("control userpasswords", "ignore")
    time.sleep(2)
    BetaScript(script.format(fname=usernames()['fname'], lname=usernames()['lname'], enter='{enter}', up='{up}'))
    time.sleep(1)
    kill()
Exemple #15
0
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"
    
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt");
    time.sleep(1)
    res2 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")
                          
    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

#    s = 1000000 # 1 second
    s = 1000 # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4
    
    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
Exemple #16
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static  == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static  == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")
    
    util.kill()
Exemple #17
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")

    util.kill()
Exemple #18
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.3)
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" %
        file1)
    time.sleep(0.3)
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" %
        file2)

    time.sleep(10)
    #count1 = util.get_stat_thread_count(file1)
    #count2 = util.get_stat_thread_count(file2)
    count1 = util.get_stat(file1, "Stat-thread-count")
    count2 = util.get_stat(file2, "Stat-thread-count")

    print "count1 = " + str(count1)
    print "count2 = " + str(count2)

    if cmd.find("SFF") > 0:
        if count1 == 3 and count2 == 2:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count."
                       "Expected count1 = 3 and count2 = 2")

    if cmd.find("FIFO") > 0:
        if count1 == 2 and count2 == 3:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count!"
                       "Expected count1 == 2 and count2 ==3")

    util.kill()
Exemple #19
0
def set_username():
    script = """
    send #{up}
    sleep 500
    click 547 350
    sleep 500
    send {fname} {lname}
    sleep 500
    send {enter}
    """

    do("control userpasswords", "ignore")
    time.sleep(2)
    BetaScript(
        script.format(fname=usernames()['fname'],
                      lname=usernames()['lname'],
                      enter='{enter}',
                      up='{up}'))
    time.sleep(1)
    kill()
Exemple #20
0
def launch_native_apps():
    launch_weather = """send, {Lwin}
    sleep, 1500
    send, Weather
    sleep, 2000
    send, {enter}"""

    launch_store = """send, #3
    sleep, 500"""

    launch_surface = """send {Lwin}
    sleep 500
    send surface
    sleep 500
    send {enter}"""

    for script in [launch_weather, launch_store, launch_surface]:
        for x in range(2):
            BetaScript(script)
            time.sleep(2 - x)
            kill("ApplicationFrameHost.exe")
Exemple #21
0
def launch_native_apps():
    launch_weather = """send, {Lwin}
    sleep, 1500
    send, Weather
    sleep, 2000
    send, {enter}"""

    launch_store = """send, #3
    sleep, 500"""

    launch_surface = """send {Lwin}
    sleep 500
    send surface
    sleep 500
    send {enter}"""

    for script in [launch_weather, launch_store, launch_surface]:
        for x in range(2):
            BetaScript(script)
            time.sleep(2-x)
            kill("ApplicationFrameHost.exe")
Exemple #22
0
def install_office():
    office_login()
    f = download_office_exe()
    do(f)

    while True:
        p("Checking to see if build completed...")
        time.sleep(3),
        check = os.path.exists(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16")
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\excel.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\lync.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\msaccess.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\mspub.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\onenote.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\outlook.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\powerpnt.exe"
        )
        check = check and os.path.isfile(
            "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\winword.exe"
        )
        if check:
            time.sleep(5)
            kill("OfficeC2RClient.exe", True)
            return True
        else:
            p("Error Code: MA_365II")
Exemple #23
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()
Exemple #24
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()
Exemple #25
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.3)
    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" % file1);
    time.sleep(0.3)
    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" % file2);
    
    time.sleep(10)
    #count1 = util.get_stat_thread_count(file1)
    #count2 = util.get_stat_thread_count(file2)
    count1 = util.get_stat(file1, "Stat-thread-count")
    count2 = util.get_stat(file2, "Stat-thread-count")

    print "count1 = " + str(count1)
    print "count2 = " + str(count2)

    if cmd.find("SFF") > 0:
        if count1 == 3 and count2 == 2:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count."
                       "Expected count1 = 3 and count2 = 2")

    if cmd.find("FIFO") > 0:
        if count1 == 2 and count2 == 3:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count!"
                       "Expected count1 == 2 and count2 ==3")
    
    util.kill()
Exemple #26
0
def install_office():
    office_login()
    f = download_office_exe()
    do(f)

    while True:
        p("Checking to see if build completed...")
        time.sleep(3),
        check = os.path.exists("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\excel.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\lync.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\msaccess.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\mspub.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\onenote.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\outlook.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\powerpnt.exe")
        check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\winword.exe")
        if check:
            time.sleep(5)
            kill("OfficeC2RClient.exe", True)
            return True
        else:
            p("Error Code: MA_365II")
Exemple #27
0
def test(cmd):
    global expected
    global got
    global count

    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    expected = ['MAGIC:a', 'MAGIC:bb', 'MAGIC:ccc']

    commands.getoutput("rm -rf %s" % tmpfile)
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    commands.getoutput("rm -rf " + file3)

    os.system("./testclient localhost 2010 /output10.cgi >> /dev/null &")
    time.sleep(1)
    #    os.system("./testclient localhost 2010 /testdata/file1.txt > /tmp/file1 &");
    os.system("./testclient localhost 2010 /testdata/file1.txt > %s &" % file1)
    time.sleep(1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(1)
    #    os.system("./testclient localhost 2010 /testdata/file2.txt > /tmp/file2 &");
    os.system("./testclient localhost 2010 /testdata/file2.txt > %s &" % file2)
    time.sleep(1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(1)
    #    os.system("./testclient localhost 2010 /testdata/file3.txt > /tmp/file3 &");
    os.system("./testclient localhost 2010 /testdata/file3.txt > %s &" % file3)

    time.sleep(10 + 2 * CGI_SPIN_TIME + 2)

    if util.is_server_alive(cmd) == -1:
        util.error("Ouch! Server is dead!"
                   " Your bounded buffered may not be well protected")

    time1 = os.path.getmtime(file1)
    time2 = os.path.getmtime(file2)
    time3 = os.path.getmtime(file3)

    res1 = commands.getoutput("cat " + file1)
    res2 = commands.getoutput("cat " + file2)
    res3 = commands.getoutput("cat " + file3)

    print res1
    print res2
    print res3

    print expected[0]
    pos1 = res1.find(expected[0])
    print expected[1]
    pos2 = res2.find(expected[1])
    print expected[2]
    pos3 = res3.find(expected[2])

    print time1
    print time2
    print time3

    print pos1
    print pos2
    print pos3

    passed = time1 < time2 and time2 < time3
    passed = passed and pos1 > 0 and pos2 > 0 and pos3 > 0

    if passed:
        print ""
        print "#####################################"
        print "GOOD! you passed this iteration"
        print "There may be more..."
        print "#####################################"
        print ""
        count = count + 1
    else:
        print ""
        print "#####################################"
        print "Oh oh! ERROR ERROR!"
        print "FIFO is not implemented correctly"
        print "#####################################"
        print ""
        sys.exit(-1)

    util.kill()
Exemple #28
0
def test(cmd):
    global expected
    global got
    global count

    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    expected = ['MAGIC:a', 'MAGIC:bb', 'MAGIC:ccc']

    commands.getoutput("rm -rf %s" % tmpfile)
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    commands.getoutput("rm -rf " + file3)

    os.system("./testclient localhost 2010 /output10.cgi >> /dev/null &");
    time.sleep(1)
#    os.system("./testclient localhost 2010 /testdata/file1.txt > /tmp/file1 &");
    os.system("./testclient localhost 2010 /testdata/file1.txt > %s &" % file1);
    time.sleep(1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(1)
#    os.system("./testclient localhost 2010 /testdata/file2.txt > /tmp/file2 &");
    os.system("./testclient localhost 2010 /testdata/file2.txt > %s &" % file2);
    time.sleep(1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(1)
#    os.system("./testclient localhost 2010 /testdata/file3.txt > /tmp/file3 &");
    os.system("./testclient localhost 2010 /testdata/file3.txt > %s &" % file3);



    time.sleep(10 +  2 * CGI_SPIN_TIME + 2);

    if util.is_server_alive(cmd) == -1:
        util.error("Ouch! Server is dead!"
                   " Your bounded buffered may not be well protected");

    time1 = os.path.getmtime(file1)
    time2 = os.path.getmtime(file2)
    time3 = os.path.getmtime(file3)
   
    res1 = commands.getoutput("cat " + file1);
    res2 = commands.getoutput("cat " + file2);
    res3 = commands.getoutput("cat " + file3);
    
    print res1
    print res2
    print res3
    
    print expected[0]
    pos1 = res1.find(expected[0])
    print expected[1]
    pos2 = res2.find(expected[1])
    print expected[2]
    pos3 = res3.find(expected[2])

    print time1
    print time2
    print time3

    print pos1
    print pos2
    print pos3

    passed = time1 < time2 and time2 < time3 
    passed = passed and pos1 > 0 and pos2 > 0 and pos3 > 0

    if passed:
        print ""
        print "#####################################"
        print "GOOD! you passed this iteration"
        print "There may be more..."
        print "#####################################"
        print ""
        count = count + 1
    else:
        print ""
        print "#####################################"
        print "Oh oh! ERROR ERROR!"
        print "FIFO is not implemented correctly"
        print "#####################################"
        print ""
        sys.exit(-1)

    util.kill()
Exemple #29
0
    def deal_command(self, socket, data):
        sys.path.append("..")
        import util
        if '0x01' in data:
            #打开摄像头
            util.Logprint(2, data)
            cmd = '/home/nvidia/Horus/opencamera'
            subprocess.Popen(cmd,
                             shell=True,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)

        elif '0x02' in data:
            #自定义命令
            util.Logprint(2, data)
            cus_command = data.split(':')[1]
            if cus_command != '':
                os.system(cus_command)

        elif '0x03' in data:
            util.Logprint(2, data)
            #关闭摄像头
            pids = psutil.pids()
            for pid in pids:
                p = psutil.Process(pid)
                #                if "python" in p.name():
                #                    ss=p.cmdline()
                #                    if len(ss)>0:
                #                        if ss[1]=="/home/nvidia/Horus/opencamera.py":
                #                            util.kill(pid)
                #                    util.Logprint(1,data)
                if "opencamera" in p.name():
                    util.kill(pid)

        elif '0x04' in data:
            #发送日志
            # Communicate().sendFile(socket,config.LOG_PATH)
            pass

        elif '0x05' in data:
            import util  #更新config的level值
            util.Logprint(2, data)
            #设置config
            key = data.split(':')[1]
            value = data.split(':')[2]
            #修改K-V
            with open('/home/nvidia/Horus/config.cnf') as f:
                cnf = json.load(f)
                cnf[key] = value
                jsonstr = json.dumps(cnf, ensure_ascii=False, sort_keys=True)
                util.replace('/home/nvidia/Horus/config.cnf', jsonstr)
        elif '0x06' in data:
            util.Logprint(2, data)
            #打开环境传感器
            global envid
            envid = Communicate().createnvDaemon()

        elif '0x07' in data:
            util.Logprint(2, data)
            #关闭环境传感器
            util.kill(envid)
        elif '0x08' in data:
            util.Logprint(2, data)
            obddata = data[5:]
            if util.is_json(obddata):
                with open('/home/nvidia/Horus/config.cnf') as json_data:
                    cnf = json.load(json_data)
                    db = create_engine(cnf['db'])
                    s = json.loads(obddata)
                    insert_data = "insert into tb_obd(timestamp,longitude,latitude,altitude,speed) values (%s,%s,%s,%s,%s)" % (
                        s["timestamp"], s["longitude"], s["latitude"],
                        s["altitude"], s["speed"])
                    db.execute(insert_data)
        elif '0x09' in data:
            util.Logprint(2, data)
            pids = psutil.pids()
            for pid in pids:
                p = psutil.Process(pid)
                if "python" in p.name():
                    ss = p.cmdline()
                    if len(ss) > 0:
                        if ss[1] == "Horus.py":
                            util.kill(pid)
                    util.Logprint(1, data)
                if "Horus" in p.name():
                    util.kill(pid)

#
        elif 'test' in data:
            util.Logprint(1, data)
            #心跳测试和数据库表的条目查询
            Communicate().dbquery(socket)
            pass

        else:
            util.Logprint(1, data)
            #手机端json数据
            if util.is_json(data):
                with open('/home/nvidia/Horus/config.cnf') as json_data:
                    cnf = json.load(json_data)
                    db = create_engine(cnf['db'])
                    s = json.loads(data)
                    insert_data = "insert into tb_mobile_sensor(timestamp,accx,accy,accz,gpsLongitude,gpsLatitude,gpsAltitude,gpsSpeed,gpsBearing,light,deviceID,frequency) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" % (
                        s["time"], s["accx"], s["accy"], s["accz"],
                        s["longitude"], s["latitude"], s["altitude"],
                        s["speed"], s["bearing"], s["lightx"], s["deviceID"],
                        s["frequency"])
                    db.execute(insert_data)
Exemple #30
0
def set_pen_settings():
    test = """WinActivate, Surface
    sleep 500
    send #{up}
    sleep 500
    PixelGetColor, UError, 1630, 1568
    sleep 200
    send !{tab}
    sleep 500
    send %UError%{enter}
    """

    script = ["""WinActivate, Surface
    sleep, 500
    send #{up}
    sleep 500
    send {down}
    sleep 200
    send {enter}
    """, """
    WinActivate, Surface
    sleep 500
    send #{up}
    sleep 500
    send {tab}
    sleep 200
    send {tab}
    sleep 200
    send {enter}
    sleep 200
    send {down}
    sleep 200
    send {down}
    sleep 200
    send {down}
    sleep 200
    send {down}
    sleep 200
    send {enter}
    sleep 400
    send {tab}
    sleep 200
    send {enter}
    sleep 1000
    send C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE
    sleep 200
    send {enter}"""]

    BetaScript(script[0])
    time.sleep(2)
    while True:
        if str(BetaScript(test, True)) == str('0xF'):
            break
        else:
            input("PLEASE PAIR PEN! HIT {ENTER} WHEN YOU DO.")
            time.sleep(3)

    BetaScript(script[1])
    time.sleep(2)

    kill("SurfaceApp.exe", True)
Exemple #31
0
def download_office_exe():
    script1 = """WinActivate, Office 365
    sleep 500
    PixelGetColor, EOfficeLogo, 525, 385, RGB ;0x0D9390F
    PixelGetColor, EUpperBar, 814, 217, RGB ;0x000000
    PixelGEtColor, ENotify, 2392, 211, RGB ; 0xF
    PixelGetColor, EInstall, 2052, 717, RGB ;0x0D9390F
    PixelGetColor, EWord, 899, 676, RGB ;0x2B579A
    PixelGetColor, EExcel, 1111, 642, RGB ;0x207346
    PixelGetColor, EOnenote, 1621, 663, RGB ;0x80397B
    ;0xD9390F0x0000000xD9390F0x2B579A0x2073460xD1B7CF
    ;0xD9390F0x0000000xD9390F0x2B579A0x2073460x80397B
    Send, !{tab}
    sleep, 500
    Send, %EOfficeLogo%%EUpperBar%%EInstall%%EWord%%EExcel%%EOnenote%%ENotify%{enter}"""

    script2 = """send, #1
    sleep 1000
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {space}
    sleep 250
    send, {tab}{space}
    sleep, 250
    send, {tab}{enter}"""

    while True:
        time.sleep(3)
        if str(BetaScript(script1, True)) != str(
                "0xD9390F0x0000000xD9390F0x2B579A0x2073460x80397B0xF"):
            p("Will try again in 3 seconds...")
        else:
            break

    BetaScript(script2)

    while True:
        time.sleep(15)
        check = os.listdir("C:\\Users\\CIO\\Downloads\\")
        okay = False
        for f in check:
            if f.startswith("Setup") and "O365ProPlus" in f and f.endswith(
                    '.exe'):
                okay = f
                break
        if okay:
            break
        else:
            p("Will try again in 15 seconds...")

    kill()
    return "C:\\Users\\CIO\\Downloads\\" + f
Exemple #32
0
def download_office_exe():
    script1 = """WinActivate, Office 365
    sleep 500
    PixelGetColor, EOfficeLogo, 525, 385, RGB ;0x0D9390F
    PixelGetColor, EUpperBar, 814, 217, RGB ;0x000000
    PixelGEtColor, ENotify, 2392, 211, RGB ; 0xF
    PixelGetColor, EInstall, 2052, 717, RGB ;0x0D9390F
    PixelGetColor, EWord, 899, 676, RGB ;0x2B579A
    PixelGetColor, EExcel, 1111, 642, RGB ;0x207346
    PixelGetColor, EOnenote, 1621, 663, RGB ;0x80397B
    ;0xD9390F0x0000000xD9390F0x2B579A0x2073460xD1B7CF
    ;0xD9390F0x0000000xD9390F0x2B579A0x2073460x80397B
    Send, !{tab}
    sleep, 500
    Send, %EOfficeLogo%%EUpperBar%%EInstall%%EWord%%EExcel%%EOnenote%%ENotify%{enter}"""

    script2 = """send, #1
    sleep 1000
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {tab}
    sleep, 250
    send, {space}
    sleep 250
    send, {tab}{space}
    sleep, 250
    send, {tab}{enter}"""

    while True:
        time.sleep(3)
        if str(BetaScript(script1, True)) != str("0xD9390F0x0000000xD9390F0x2B579A0x2073460x80397B0xF"):
            p("Will try again in 3 seconds...")
        else:
            break


    BetaScript(script2)

    while True:
        time.sleep(15)
        check = os.listdir("C:\\Users\\CIO\\Downloads\\")
        okay = False
        for f in check:
            if f.startswith("Setup") and "O365ProPlus" in f and f.endswith('.exe'):
                okay = f
                break
        if okay:
            break
        else:
            p("Will try again in 15 seconds...")

    kill()
    return "C:\\Users\\CIO\\Downloads\\" + f
Exemple #33
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    commands.getoutput("rm -rf " + file3)
    commands.getoutput("rm -rf " + file4)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.6)
#    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > /tmp/file1 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" % file1);
    time.sleep(0.1)
#    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > /tmp/file2 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" % file2);
    time.sleep(0.1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.1)
#    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > /tmp/file3 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" % file3);
    time.sleep(0.1)
#    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > /tmp/file4 &");
    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" % file4);
    time.sleep(0.1)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");

    time.sleep(4 * CGI_SPIN_TIME + 3)

    if util.is_server_alive(cmd) == -1:
        util.error("Ouch! Server is dead!"
                   " Your bounded buffered may not be well protected");

    time1 = os.path.getmtime(file1)
    time2 = os.path.getmtime(file2)
    time3 = os.path.getmtime(file3)
    time4 = os.path.getmtime(file4)
  
    print "time1 = " + str(time1)
    print "time2 = " + str(time2)
    print "time3 = " + str(time3)
    print "time4 = " + str(time4)


    print "expected = " + "time1 >= time2 and time3 > time4 and time4 >= time1"
    passed = time1 >= time2 and time3 > time4 and time4 >= time1

    if passed:
        print ""
        print "#####################################"
        print "GOOD! you implement SFF correctly"
        print "#####################################"
        print ""
        count = count + 1
    else:
        print ""
        print "#####################################"
        print "Oh oh! ERROR ERROR!"
        print "SFF is not implemented correctly"
        print "#####################################"
        print ""
        sys.exit(-1)

    util.kill()