Пример #1
0
def upgrade_magicmirror() -> str:
    log.logger.info(f'Request to upgrade MagicMirror')
    process: Group = Group()
    Response(__stream_cmd_output__(process, ['-M', '--GUI']), mimetype='text/plain')
    log.logger.info('Finished installing')

    if utils.get_pids('chromium') and utils.get_pids('node') and utils.get_pids('npm'):
        utils.kill_magicmirror_processes()
        utils.start_magicmirror()

    return json.dumps(True)
Пример #2
0
def stop_magicmirror() -> str:
    '''
    Stop the MagicMirror by killing all Chromium processes

    Parameters:
        None

    Returns:
        bool: Always True only as a signal the process was called
    '''
    # same sort of issue as the start-magicmirror call
    utils.kill_magicmirror_processes()
    return json.dumps(True)
Пример #3
0
def restart_magicmirror() -> str:
    '''
    Restart the MagicMirror by killing all Chromium processes, the
    re-running the startup script for MagicMirror

    Parameters:
        None

    Returns:
        bool: Always True only as a signal the process was called
    '''
    # same issue as the start-magicmirror api call
    utils.kill_magicmirror_processes()
    utils.start_magicmirror()
    return json.dumps(True)
Пример #4
0
def turn_off_raspberrypi() -> str:
    '''
    Shut down the RaspberryPi

    Parameters:
        None

    Returns:
        success (bool): If the command fails, False is returned. If success, the return will never reach the interface
    '''

    log.logger.info('Shutting down RaspberryPi')
    # if success, we'll never get the response, but we'll know if it fails
    utils.kill_magicmirror_processes()
    return_code, _, _ = utils.run_cmd(['sudo', 'shutdown', '-P', 'now'])
    return json.dumps(bool(not return_code))
Пример #5
0
def restart_raspberrypi() -> str:
    '''
    Reboot the RaspberryPi

    Parameters:
        None

    Returns:
        success (bool): If the command fails, False is returned. If success, the return will never reach the interface
    '''

    log.logger.info('Restarting RaspberryPi')
    utils.kill_magicmirror_processes()
    return_code, _, _ = utils.run_cmd(['sudo', 'reboot'])
    # if success, it'll never get the response, but we'll know if it fails
    return json.dumps(bool(not return_code))