Ejemplo n.º 1
0
def check_cloud_env():
    ses = Session()
    ses.connect(ssh_tools.get_ip())
    system = ses.service("ALSystem")
    version = system.version().split(".")
    if len(version) < 2:
        print version
        sys.exit("wrong version format")
    else:
        if int(version[0]) == 2:
            if int(version[1]) < 4:
                print """Check cloud environment fixture:
                    This script is not made for versions inferior to 2.4.
                    You need to manually set the environment to preproduction. Use Simon's script to do so
                    Once you've done that, remove check_cloud_env fixture from all tests"""
                sys.exit("Exiting program")
            if int(version[1]) > 4:
                alcloud = ses.service("_ALCloud")
            if int(version[1]) == 4:
                alcloud = ses.service("ALCloud")
        if int(version[0]) != 2:
            print """Check cloud environment fixture:
                  This script is made for naoqi version 2.0. You probably need to update it in order to make it work
                  for the version you are using"""
            sys.exit("Exiting program")


    if alcloud.getEnvironment() != "ppd":
        print "Your robot cloud configuration needs to be changed to a preproduction environment."

        #clean prod settings
        #ssh_tools.runcommand('rm -r .local')

        alcloud.setEnvironment("ppd")
        print "Please wait for naoqi to restart..."
        ssh_tools.nao_restart(life=False)

        ses = Session()
        ses.connect(ssh_tools.get_ip())
        if int(version[1]) > 4:
            alcloud = ses.service("_ALCloud")
        if int(version[1]) == 4:
            alcloud = ses.service("ALCloud")

        if alcloud.getEnvironment() == "ppd":
            print "Your configuration has been successfully changed"
        else:
            print "cloud configuration seems to have failed"
            sys.exit("Exiting program")
        return True
    else:
        return False
Ejemplo n.º 2
0
def restart_naoqi():
    ssh_tools.nao_restart()