menu/lcdmenu.py
def install():
    """Install this into a system. Must be root"""

    # First - do we the correct libraries installed?
    print("Testing that we have the right libraries...")
    try:
        import RPLCD.i2c
        import gpiozero
    except ImportError:
        print("ERROR: Please install the RPLCD and gpiozero Python libraries")
        return

    from os import system
    print("Probing whether " + SERVICE + " already exists...")
    properties = probe_system_service(SERVICE)
    if properties[LOAD_STATE] == "loaded":
        print("... " + properties[ACTIVE_STATE] + " " + properties[SUB_STATE])
        print("Stopping service...")
        system("systemctl stop " + SERVICE)
    else:
        print("... " + properties[LOAD_STATE])

    print("Copying this file to " + SYSTEMD_EXEC_FILE)
    try:
        import shutil
        shutil.copyfile(__file__, SYSTEMD_EXEC_FILE)
    except IOError:
        print("ERROR: Cannot copy the file to " +
              SYSTEMD_EXEC_FILE +
              ": Do you have the right permissions?")
        return

    print("Creating systemctl configuration file at " + SYSTEMD_CONF_FILENAME)
    try:
        f = open(SYSTEMD_CONF_FILENAME, "w")
        f.write(SYSTEMD_CONF)
        f.close()
    except IOError:
        print("ERROR: Cannot copy the file to " +
              SYSTEMD_CONF_FILENAME +
              ": Do you have the right permissions?")
        return

    print("Reloading systemctl daemon...")
    system("systemctl daemon-reload")

    if properties[LOAD_STATE] != "loaded":
        print("Enabling " + SERVICE + " to start on boot...")
        system("systemctl enable " + SERVICE)

    print("Starting " + SERVICE + "...")
    system("systemctl start " + SERVICE)
Install this into a system. Must be root
Install this into a system. Must be root
Install this into a system . Must be root
def install():
    print("Testing that we have the right libraries...")
    try:
        import RPLCD.i2c
        import gpiozero
    except ImportError:
        print("ERROR: Please install the RPLCD and gpiozero Python libraries")
        return
    from os import system
    print("Probing whether " + SERVICE + " already exists...")
    properties = probe_system_service(SERVICE)
    if properties[LOAD_STATE] == "loaded":
        print("... " + properties[ACTIVE_STATE] + " " + properties[SUB_STATE])
        print("Stopping service...")
        system("systemctl stop " + SERVICE)
    else:
        print("... " + properties[LOAD_STATE])
    print("Copying this file to " + SYSTEMD_EXEC_FILE)
    try:
        import shutil
        shutil.copyfile(__file__, SYSTEMD_EXEC_FILE)
    except IOError:
        print("ERROR: Cannot copy the file to " +
              SYSTEMD_EXEC_FILE +
              ": Do you have the right permissions?")
        return
    print("Creating systemctl configuration file at " + SYSTEMD_CONF_FILENAME)
    try:
        f = open(SYSTEMD_CONF_FILENAME, "w")
        f.write(SYSTEMD_CONF)
        f.close()
    except IOError:
        print("ERROR: Cannot copy the file to " +
              SYSTEMD_CONF_FILENAME +
              ": Do you have the right permissions?")
        return
    print("Reloading systemctl daemon...")
    system("systemctl daemon-reload")
    if properties[LOAD_STATE] != "loaded":
        print("Enabling " + SERVICE + " to start on boot...")
        system("systemctl enable " + SERVICE)
    print("Starting " + SERVICE + "...")
    system("systemctl start " + SERVICE)
def install ( ) : print ( "Testing that we have the right libraries..." ) try : import RPLCD . i2c import gpiozero except ImportError : print ( "ERROR: Please install the RPLCD and gpiozero Python libraries" ) return from os import system print ( "Probing whether " + SERVICE + " already exists..." ) properties = probe_system_service ( SERVICE ) if properties [ LOAD_STATE ] == "loaded" : print ( "... " + properties [ ACTIVE_STATE ] + " " + properties [ SUB_STATE ] ) print ( "Stopping service..." ) system ( "systemctl stop " + SERVICE ) else : print ( "... " + properties [ LOAD_STATE ] ) print ( "Copying this file to " + SYSTEMD_EXEC_FILE ) try : import shutil shutil . copyfile ( __file__ , SYSTEMD_EXEC_FILE ) except IOError : print ( "ERROR: Cannot copy the file to " + SYSTEMD_EXEC_FILE + ": Do you have the right permissions?" ) return print ( "Creating systemctl configuration file at " + SYSTEMD_CONF_FILENAME ) try : f = open ( SYSTEMD_CONF_FILENAME , "w" ) f . write ( SYSTEMD_CONF ) f . close ( ) except IOError : print ( "ERROR: Cannot copy the file to " + SYSTEMD_CONF_FILENAME + ": Do you have the right permissions?" ) return print ( "Reloading systemctl daemon..." ) system ( "systemctl daemon-reload" ) if properties [ LOAD_STATE ] != "loaded" : print ( "Enabling " + SERVICE + " to start on boot..." ) system ( "systemctl enable " + SERVICE ) print ( "Starting " + SERVICE + "..." ) system ( "systemctl start " + SERVICE )
Install this into a system.
Install this into a system .
"""Install this into a system. Must be root""" # First - do we the correct libraries installed?