Exemplo n.º 1
0
        http_request(url, method, data, chk)


# the absolute path of the connector
working_dir = os.path.dirname(os.path.abspath(__file__)) + os.sep

# LOAD CONFIGURATION

# load configuration object with configuration file rest.conf.json
config = ciao.load_config(working_dir)

# name of the connector
name = config["name"]

# CREATE LOGGER

log_config = config["log"] if "log" in config else None
logger = ciao.get_logger(name, logconf=log_config, logdir=working_dir)

# CALL BASE CONNECTOR

#Call a base connector object to help connection to ciao core
ciao_connector = ciao.BaseConnector(name, logger, async=True)

#register an handler to manage data from core/mcu
ciao_connector.receive(handler)

# start the connector thread
ciao_connector.start()
Exemplo n.º 2
0

#shared dictionary
shd = {}
shd["loop"] = True
shd["basepath"] = os.path.dirname(os.path.abspath(__file__)) + os.sep

#read configuration
#TODO
# verify configuration is a valid JSON
json_conf = open(shd["basepath"] + "restserver.json.conf").read()
shd["conf"] = json.loads(json_conf)
#init log

logger = ciaotools.get_logger("restserver",
                              logconf=shd["conf"],
                              logdir=shd["basepath"])

#forking to make process standalone
try:
    pid = os.fork()
    if pid > 0:
        # Save child pid to file and exit parent process
        runfile = open("/var/run/restserver-ciao.pid", "w")
        runfile.write("%d" % pid)
        runfile.close()
        sys.exit(0)

except OSError, e:
    logger.critical("Fork failed")
    sys.exit(1)
Exemplo n.º 3
0
# load parameters
smtp_sender = config["params"]["sender"]
smtp_user = config["params"]["user"]
smtp_pwd = config["params"]["password"]
smtp_host = config["params"]["host"]
smtp_port = config["params"]["port"]
smtp_ssl = config["params"]["ssl"]
smtp_tls = config["params"]["tls"]
smtp_auth = config["params"]["auth"]

# name of the connector
name = config["name"]

# CREATE LOGGER

log_config = config["log"] if "log" in config else None
logger = ciaotools.get_logger(name, logconf=log_config, logdir=working_dir)


# CALL BASE CONNECTOR

#Call a base connector object to help connection to ciao core
ciao_connector = ciaotools.BaseConnector(name, logger)

#register an handler to manage data from core/mcu
ciao_connector.receive(handler)

# start the connector thread
ciao_connector.start()
Exemplo n.º 4
0
		logger.debug("Request answer: %s" % result)
	except Exception, e:
		logger.error("Request issue: %s" % e)

#shared dictionary
shd = {}
shd["loop"] = True
shd["basepath"] = os.path.dirname(os.path.abspath(__file__)) + os.sep

#read configuration
# TODO: verify configuration is a valid JSON
json_conf = open(shd["basepath"]+"phant.json.conf").read()
shd["conf"] = json.loads(json_conf)

#init log
logger = ciaotools.get_logger("phant", logconf=shd["conf"], logdir=shd["basepath"])

#forking to make process standalone
try:
	pid = os.fork()
	if pid > 0:
		# Save child PID to file and exit parent process
		runfile = open("/var/run/phant-ciao.pid", "w")
		runfile.write("%d" % pid)
		runfile.close()
		sys.exit(0)

except OSError, e:
	logger.critical("Fork failed")
	sys.exit(1)
Exemplo n.º 5
0
        logger.error("Request issue: %s" % e)


#shared dictionary
shd = {}
shd["loop"] = True
shd["basepath"] = os.path.dirname(os.path.abspath(__file__)) + os.sep

#read configuration
# TODO: verify configuration is a valid JSON
json_conf = open(shd["basepath"] + "phant.json.conf").read()
shd["conf"] = json.loads(json_conf)

#init log
logger = ciaotools.get_logger("phant",
                              logconf=shd["conf"],
                              logdir=shd["basepath"])

#forking to make process standalone
try:
    pid = os.fork()
    if pid > 0:
        # Save child PID to file and exit parent process
        runfile = open("/var/run/phant-ciao.pid", "w")
        runfile.write("%d" % pid)
        runfile.close()
        sys.exit(0)

except OSError, e:
    logger.critical("Fork failed")
    sys.exit(1)
Exemplo n.º 6
0
	shd["loop"] = False

#shared dictionary
shd = {}
shd["loop"] = True
shd["basepath"] = os.path.dirname(os.path.abspath(__file__)) + os.sep


#read configuration
#TODO
# verify configuration is a valid JSON
json_conf = open(shd["basepath"]+"restserver.json.conf").read()
shd["conf"] = json.loads(json_conf)
#init log

logger = ciaotools.get_logger("restserver", logconf=shd["conf"], logdir=shd["basepath"])

#forking to make process standalone
try:
	pid = os.fork()
	if pid > 0:
		# Save child pid to file and exit parent process
		runfile = open("/var/run/restserver-ciao.pid", "w")
		runfile.write("%d" % pid)
		runfile.close()
		sys.exit(0)

except OSError, e:
	logger.critical("Fork failed")
	sys.exit(1)