def main(): mks.init_logging(_LOGGER, loglevel=logging.INFO) argopts = docopt(__doc__) # Force use root account rootRequire() # Debug mode if not argopts['--debug']: sys.tracebacklimit = 0 ############################### # Enable / Disable ############################### if argopts['enable']: if argopts['sender']: enableSender(sendername=argopts['SENDERTYPE'], **argopts) if argopts['sensor']: enableSensor(sensorname=argopts['SENSORNAME'], sensorlibraryname=argopts['SENSORLIBRARYNAME'], **argopts) if argopts['disable']: if argopts['sender']: disableSender(sendertype=argopts['SENDERTYPE'], **argopts) if argopts['sensor']: disableSensor(sensorname=argopts['SENSORNAME'], **argopts) if argopts['remove']: if argopts['sensor']: removeSensor(sensorname=argopts['SENSORNAME']) if argopts['check']: checkMkSensors() if argopts['list']: if argopts['senders']: showSendersList() if argopts['sensors']: showSensorsList()
def main(): mks.init_logging(_LOGGER, loglevel=logging.INFO) argopts = docopt(__doc__) # Force use root account rootRequire() # Debug mode if not argopts["--debug"]: sys.tracebacklimit = 0 ############################### # Enable / Disable ############################### if argopts["enable"]: if argopts["sender"]: enableSender(sendername=argopts["SENDERTYPE"], **argopts) if argopts["sensor"]: enableSensor(sensorname=argopts["SENSORNAME"], sensorlibraryname=argopts["SENSORLIBRARYNAME"], **argopts) if argopts["disable"]: if argopts["sender"]: disableSender(sendertype=argopts["SENDERTYPE"], **argopts) if argopts["sensor"]: disableSensor(sensorname=argopts["SENSORNAME"], **argopts) if argopts["remove"]: if argopts["sensor"]: removeSensor(sensorname=argopts["SENSORNAME"]) if argopts["check"]: checkMkSensors() if argopts["list"]: if argopts["senders"]: showSendersList() if argopts["sensors"]: showSensorsList()
import os import re import sys import glob import logging import stat from distutils.spawn import find_executable from docopt import docopt from tabulate import tabulate from lib import mks _LOGGER = logging.getLogger(__name__) mks.init_logging(logger=_LOGGER, loglevel=mks.LOGSEVERITY['DEBUG']) def rootRequire(): """Check if run root session""" if not os.geteuid() == 0: sys.exit('This command must be run as root') def enableSensor(sensorname, sensorlibraryname, **kwargs): """ Enable new sensor configuration - Create supervisor configuration - Create sensor user script from template - Create YAML configuration from sensor template """
import os import re import sys import glob import logging import stat from distutils.spawn import find_executable from docopt import docopt from tabulate import tabulate from lib import mks _LOGGER = logging.getLogger(__name__) mks.init_logging(logger=_LOGGER, loglevel=mks.LOGSEVERITY["DEBUG"]) def rootRequire(): """Check if run root session""" if not os.geteuid() == 0: sys.exit("This command must be run as root") def enableSensor(sensorname, sensorlibraryname, **kwargs): """ Enable new sensor configuration - Create supervisor configuration - Create sensor user script from template - Create YAML configuration from sensor template """