Esempio n. 1
0
 def onShutdown(self, message):
     logger.info('Shutdown by user request')
     messageboard.post('ExitThread', True)
     for thread in self.workerThreads:
         thread.stop()
     print('System shutdown')
     shutdown()
Esempio n. 2
0
def mercury():
    if request.method == 'POST':
        try:
            shutdown()
            return 'Success', 200
        except Exception:
            return 'FAIL', 400
    elif request.method == 'GET':
        return 'Shutdown server is listening', 200
Esempio n. 3
0
def mercury():
    if request.method == 'POST':
        try:
            shutdown()
            return 'Success', 200
        except:
            return 'FAIL', 400
    elif request.method == 'GET':
        return 'Shutdown server is listening', 200
Esempio n. 4
0
def run(conf, halt, unzip):
    """ Run.

    Args:
      conf: Redable object consists of conf file.
      halt: If True, shutdown the VM this program running on.
      unzip: If True and downloaded files are zipped, unzip them.
    """
    try:
        # Loading conf.
        obj = yaml.load(conf)

        # Prepare packages.
        if APT in obj:
            LOGGER.info("Installing apt packages.")
            apt(obj[APT])

        # Prepare sources.
        if SOURCE in obj:
            LOGGER.info("Downloading source files.")
            source(obj[SOURCE])

        # Prepare data.
        if DATA in obj:
            for url in obj[DATA]:
                LOGGER.info("Loading %s", url)
                download(url, unzip)

        # Run command.
        for i, com in enumerate(obj[RUN]):
            with open(TEMPPATH.format(i), "w") as fp:
                LOGGER.info("Running %s", com)
                execute(com, fp)

        # Upload results.
        dest = obj[RESULT]
        if not dest.endswith("/"):
            dest += "/"
        LOGGER.info("Uploading stdout.")
        upload(TEMPPATH.format("*"), dest)
        if UPLOAD in obj:
            for pat in obj[UPLOAD]:
                LOGGER.info("Uploading %s", pat)
                upload(pat, dest)

        # Garbage collection.
        for path in glob.iglob(TEMPPATH.format("*")):
            os.remove(path)

    finally:
        # Shutdown.
        if halt:
            shutdown.shutdown()
Esempio n. 5
0
#!/usr/bin/python3

from sysupdate import systemupdateupgrade
from keys import keysmodify
from shutdown import shutdown
import sys,os
from pathlib import Path

helpfilepath=os.path.join(Path(__file__).resolve().parent,"help.txt")


if __name__=="__main__":
    args=sys.argv
    if ("--help" in args) or ("-h" in args) or (len(args)==1) or (len(args)>4):
        with open (helpfilepath,'r') as f:
            print(f.read())
        
    elif not set(args[1:]).issubset(set(['--update','--keys','--shutdown'])):
        print("Invalid Inputs")
    else:
        if "--keys" in args:
            keysmodify(log_message="key Modify ran from z command")
        if "--update" in args:
            systemupdateupgrade(log_message="System update ran from z command")
        if "--shutdown" in args:
            shutdown(log_message="shutdown ran from z command")        
Esempio n. 6
0
def shutdown_view():
    shutdown()
    flash('System will shutdown...', 'danger')
    return redirect('/')
Esempio n. 7
0
	def Execute(self):
		shutdown.shutdown()
Esempio n. 8
0
        response = eventhandle.handle(data, cur_thread)
        self.request.send(response)
#------------
main=SocketServer.TCPServer((ip,port),Handle)
#    main.bind((ipbuffer,port))
run=True
closed="Rushtrough"
#------------
try:
    main=SocketServer.TCPServer((ip,port),Handle)
#    main.bind((ipbuffer,port))
    run=True
    closed="Rushtrough"
except:
    import shutdown
    shutdown.shutdown("porterror")
print(translate.openport(str(ip),str(port)))
print "nie"
main.serve_forever()
print "jupp"
while run:
    main.listen(backlog)
    connection=["q",3]#main.accept()
    conn_socket=connection[0]
    conn_address=connection[1]
    actionfile=open("console.txt","r")
    action=actionfile.readlines()
    try:
        if action[0]==".stop":
            closed="ok"
            run=False
Esempio n. 9
0
def kill():
	""" Shut down the computer. """
	shutdown.shutdown()
Esempio n. 10
0
        return 1
    if argc == 2:
        configurationFile = argv[1]

    configUpdate(configurationFile)

    if SUSPEND_TO_MEMORY:
        if not hasPrivilegesToShutdown():
            print '%s: You need to have root privileges to run this script!' % (MAIN_SCRIPT_NAME)
            return 1

    logInit('{0}/{1}-log.txt'.format(WORKING_DIR, path.splitext(MAIN_SCRIPT_NAME)[0]))
    grabLoopExitStatus = 0
    try:
        grabLoopExitStatus = grabLoop(WORKING_DIR, CAMERAS_LIST, SUSPEND_TO_MEMORY)
    except Exception as e:
        #catch ANY exception
        logAppend('{0}: unrecovable exception {1}'.format(MAIN_SCRIPT_NAME, e))
        return 2  #severe error
    if grabLoopExitStatus == 1:
        logAppend('%s: stopped by the User' % (MAIN_SCRIPT_NAME))
    return grabLoopExitStatus

if __name__ == "__main__":
    ret = main(len(argv), argv)
    if ret is not None:
        if ret == 2 and SUSPEND_TO_MEMORY:
            logAppend('%s: system will shut down in %d minutes' % (MAIN_SCRIPT_NAME, TIME_BEFORE_SHUTDOWN))
            shutdown(TIME_BEFORE_SHUTDOWN)
        exit(ret)
Esempio n. 11
0
def startshutdown():
	shutdown()
Esempio n. 12
0
             bewegung.nullposition(led)
             bewegung.angst(led)
             
             
         if joy.rightTrigger() >= 1:
             if joy.dpadLeft():
                 bewegung.linkskurve()
             if joy.dpadDown():
                 bewegung.rueckwaerts_fahren()
             if joy.dpadRight():
                 bewegung.rechtskurve() 
             if joy.dpadUp():
                 bewegung.vorwaerts_fahren()
         else: 
             bewegung.anhalten()
             
         
         if joy.leftBumper():
             bewegung.hals_ausfahren()
         if joy.rightBumper():
             bewegung.hals_einfahren()
             
             
         # Herunterfahren
         if joy.Start() and joy.Back():
                 gpio.cleanup()
                 shutdown.shutdown()
             
 
 except KeyboardInterrupt:
    gpio.cleanup()