Exemplo n.º 1
0
def system_shutdown():
    if not check_admin(request_user):
        return jsonify(build_error(ERROR_NOT_AUTHORIZED, "Insufficient privileges for request.")), UNAUTHORIZED

    sh.shutdown()
    
    return jsonify(), ACCEPTED
Exemplo n.º 2
0
def shutdown_pi():
    global led_thread_run
    global emergency_led_run
    log("Shutting down...")
    led_thread_run = False
    emergency_led_run = False
    sleep(0.5)
    shutdown("now")
Exemplo n.º 3
0
def system_shutdown():
    if not check_admin(request_user):
        return jsonify(
            build_error(ERROR_NOT_AUTHORIZED,
                        "Insufficient privileges for request.")), UNAUTHORIZED

    sh.shutdown()

    return jsonify(), ACCEPTED
Exemplo n.º 4
0
def main(args):
    """main
    entry point for worker.

    :param args:
    """
    JOB_ID = os.environ.get('JOB_ID')
    if JOB_ID is None:
        raise Exception('EC2 started without Job ID - exiting now.')

    if args.process_job:
        try:
            print('Received job ID, starting job.')
            sys.stdout.flush()
            process_job_on_worker(JOB_ID)

        except Exception as excpn:
            email.send_infra_failure_email(str(excpn), job_id=JOB_ID)

        finally:
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('SHUTDOWN SOON!')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            sys.stdout.flush()
            time.sleep(120)

    elif args.chk_efs:
        try:
            print('Checking EFS...')
            fs_utils.chk_efs()
        except IOError as ioerror:
            email.send_infra_failure_email(str(ioerror), job_id=JOB_ID)
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('SHUTDOWN SOON!')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            sys.stdout.flush()
            time.sleep(120)
            sh.shutdown('-h', 'now')
Exemplo n.º 5
0
def reboot():
    signals.reboot.send(sender='solarsan')
    signals.shutdown.send(sender='solarsan')
    logger.warning("Rebooting system in %ds..", SHUTDOWN_WAIT)
    time.sleep(SHUTDOWN_WAIT)
    return sh.shutdown('-r', 'now')
Exemplo n.º 6
0
def shutdown():
    signals.shutdown.send(sender='solarsan')
    logger.warning("Shutting system down in %ds..", SHUTDOWN_WAIT)
    time.sleep(SHUTDOWN_WAIT)
    return sh.shutdown('-h', 'now')
Exemplo n.º 7
0
def handle_touch(event):
    wait_blink(2.0)
    with sh.contrib.sudo:
        sh.shutdown("--poweroff", "now")
Exemplo n.º 8
0
 def ui_command_shutdown(self):
     """ shutdown - Shutdown system. """
     #status.tasks.shutdown.delay()
     print sh.shutdown('-h', 'now')