Esempio n. 1
0
		cur = conn.cursor() 
		for row in all_rows:
			LOG('Deleting: %d: %s %s' % (row[0], row[1], row[2], ))
			cur.execute("DELETE FROM queue WHERE rowid = ?", (row[0],))
		conn.commit()
	except Exception as e:
		LOG(str(e))
		conn.rollback()
		raise e
	finally:
		cur.close() 

#
# main
 
neodisplay(hub_home, 'pushdata_start', 'dummy')

try:
	config = ConfigParser.ConfigParser()
	config.read(hub_home + "/dat/" + "hub.ini")
	CID = config.get("module", "CID")
	SECURE_KEY = config.get("module", "SECURE_KEY")
except Exception as e:
	LOG(str(e))
	raise e

LOG("CID = " + CID)
LOG("SECURE_KEY = " + SECURE_KEY)


while 1:
Esempio n. 2
0
#def neodisplay(name, data):
#	try:
#		f = open(hub_home + '/tmp/' + name + '.dat','w')
#		f.truncate()
#		f.write(data + '\n')
#	except Exception as e:
#		LOG(str(e))
#	finally:
#		f.close()
#


#ser.write("testing")

neodisplay(hub_home, 'pulldata_start', 'dummy')

resetradio()
lt1 = time.time()
try:
        while 1:
		lt2 = time.time()
		# if no data within 5 min, then reset atmega
		if lt2-lt1 > 300:
			resetradio()
			time.sleep(1)
			lt1 = time.time()

                response = ser.readline()
		#response = "DATA#TU12-9K78:t=25:h=27:v=3.3:c=19:10719#\n"
                if not (response == ""):
Esempio n. 3
0
def ping():
	rtt = -1;
	status,result = sp.getstatusoutput("ping -q -W 1 -c 10 8.8.8.8")
	if status == 0:
		status,result = sp.getstatusoutput("echo '" + str(result) + "' |tail -1 |cut -d '/' -f5")
		rtt = int(float(result))
		LOG("AVG rtt=" + str(rtt))
	else:
		LOG("Internet connection is DOWN!")

	return rtt

# main

neodisplay(hub_home, 'rttmon_start', 'dummy')

try:
        config = ConfigParser.ConfigParser()
        config.read(hub_home + "/dat/" + "hub.ini")
        SID = config.get("rttmon", "SID")
except Exception as e:
        LOG(str(e))
        raise e

LOG("SID = " + SID)


try:
	while 1:
		rtt = ping()