コード例 #1
0
def main(argv):
    try:
        opts, args = getopt.getopt(argv,'iftLam:',[\
        'ignorecomment',\
        'firebase',\
        'thingspeak',\
        'retrythsk',\
        'thingspeaksnr',\
        'fiware',\
        'sensorcloud',\
        'grovestreams',\
        'loggw',\
        'addr',\
        'wappkey',\
        'raw',\
        'mongodb'])

    except getopt.GetoptError:
        print 'post_processing_gw '+\
        '-i/--ignorecomment '+\
        '-f/--firebase '+\
        '-t/--thingspeak '+\
        '--retrythsk '+\
        '--thingspeaksnr '+\
        '--fiware '+\
        '--sensorcloud '+\
        '--grovestreams '+\
        '-L/--loggw '+\
        '-a/--addr '+\
        '--wappkey '+\
        '--raw '+\
        '-m/--mongodb'

        sys.exit(2)

    for opt, arg in opts:
        if opt in ("-i", "--ignorecomment"):
            print("will ignore commented lines")
            global _ignoreComment
            _ignoreComment = 1

        elif opt in ("-f", "--firebase"):
            print("will enable firebase support")
            global _firebase
            _firebase = True
            global firebase_uploadSingleData
            from FireBase import firebase_uploadSingleData

        elif opt in ("-t", "--thingspeak"):
            print("will enable thingspeak support")
            global _thingspeak
            _thingspeak = True
            global thingspeak_uploadSingleData, thingspeak_uploadMultipleData
            from ThingSpeak import thingspeak_uploadSingleData, thingspeak_uploadMultipleData

        elif opt in ("--retrythsk"):
            print("will enable thingspeak retry")
            global thingspeak_setRetry
            from ThingSpeak import thingspeak_setRetry
            #set retry to True
            thingspeak_setRetry(True)

        elif opt in ("--thingspeaksnr"):
            print("will plot snr instead of seq")
            global _thingspeaksnr
            _thingspeaksnr = True

        elif opt in ("--fiware"):
            print("will enable fiware support")
            global _fiware
            _fiware = True

        elif opt in ("--sensorcloud"):
            print("will enable sensorcloud support")
            global _sensorcloud
            _sensorcloud = True
            global sensorcloud_uploadSingleData
            from SensorCloud import sensorcloud_uploadSingleData

        elif opt in ("--grovestreams"):
            print("will enable grovestreams support")
            global _grovestreams
            _grovestreams = True
            global grovestreams_uploadSingleData
            from GroveStreams import grovestreams_uploadSingleData

        elif opt in ("-L", "--loggw"):
            print("will log gateway message prefixed by ^$")
            global _logGateway
            _logGateway = 1

        elif opt in ("-a", "--addr"):
            global _gwaddr
            _gwaddr = arg
            print("overwrite: will use _" + str(_gwaddr) +
                  " for gateway and telemetry log files")

        elif opt in ("--wappkey"):
            global _wappkey
            _wappkey = 1
            global _validappkey
            _validappkey = 0
            print("will check for correct app key")

        elif opt in ("--raw"):
            global _rawFormat
            _rawFormat = 1
            print(
                "raw output from gateway. post_processing_gw will handle packet format"
            )

        elif opt in ("-m", "--mongodb"):
            print(
                "will enable local MongoDB support, max months to store is " +
                arg)
            global _mongodb
            _mongodb = True

            global add_document, remove_if_new_month, mongodb_set_max_months
            from MongoDB import add_document, remove_if_new_month, mongodb_set_max_months
            #setting max months
            mongodb_set_max_months(int(arg))
コード例 #2
0
#open json file to retrieve enabled clouds
f = open(os.path.expanduser(cloud_filename), "r")
string = f.read()
f.close()

#change it into a python array
json_array = json.loads(string)

#retrieving all cloud declarations
clouds = json_array["clouds"]

#here we check for our own script entry
#
for cloud in clouds:
    if "CloudMongoDB.py" in cloud["script"]:
        mongodb_set_max_months(cloud["max_months_to_store"])
        print "MongoDB with max months to store is %d" % cloud[
            "max_months_to_store"]

# main
# -------------------


def main(ldata, pdata, rdata, tdata, gwid):

    now = datetime.datetime.utcnow()

    # this is common code to process packet information provided by the main gateway script (i.e. post_processing_gw.py)
    # these information are provided in case you need them
    arr = map(int, pdata.split(','))
    dst = arr[0]
コード例 #3
0
#open json file to retrieve enabled clouds
f = open(os.path.expanduser(cloud_filename),"r")
string = f.read()
f.close()
	
#change it into a python array
json_array = json.loads(string)

#retrieving all cloud declarations
clouds = json_array["clouds"]

#here we check for our own script entry
#
for cloud in clouds:
	if "CloudMongoDB.py" in cloud["script"]:
		mongodb_set_max_months(cloud["max_months_to_store"])
		print "MongoDB with max months to store is %d" % cloud["max_months_to_store"]


# main
# -------------------

def main(ldata, pdata, rdata, tdata, gwid):

	now = datetime.datetime.utcnow()
	
	# this is common code to process packet information provided by the main gateway script (i.e. post_processing_gw.py)
	# these information are provided in case you need them	
	arr = map(int,pdata.split(','))
	dst=arr[0]
	ptype=arr[1]				
コード例 #4
0
def main(argv):
	try:
		opts, args = getopt.getopt(argv,'iftLam:',[\
		'ignorecomment',\
		'firebase',\
		'thingspeak',\
		'retrythsk',\
		'thingspeaksnr',\
		'fiware',\
		'sensorcloud',\
		'grovestreams',\
		'loggw',\
		'addr',\
		'wappkey',\
		'raw',\
		'mongodb'])
		
	except getopt.GetoptError:
		print 'post_processing_gw '+\
		'-i/--ignorecomment '+\
		'-f/--firebase '+\
		'-t/--thingspeak '+\
		'--retrythsk '+\
		'--thingspeaksnr '+\
		'--fiware '+\
		'--sensorcloud '+\
		'--grovestreams '+\
		'-L/--loggw '+\
		'-a/--addr '+\
		'--wappkey '+\
		'--raw '+\
		'-m/--mongodb'
		
		sys.exit(2)
	
	for opt, arg in opts:
		if opt in ("-i", "--ignorecomment"):
			print("will ignore commented lines")
			global _ignoreComment
			_ignoreComment = 1
			
		elif opt in ("-f", "--firebase"):
			print("will enable firebase support")
			global _firebase
			_firebase = True
			global firebase_uploadSingleData
			from FireBase import firebase_uploadSingleData

		elif opt in ("-t", "--thingspeak"):
			print("will enable thingspeak support")
			global _thingspeak
			_thingspeak = True
			global thingspeak_uploadSingleData, thingspeak_uploadMultipleData
			from ThingSpeak import thingspeak_uploadSingleData, thingspeak_uploadMultipleData
			
		elif opt in ("--retrythsk"):
			print("will enable thingspeak retry")
			global thingspeak_setRetry
			from ThingSpeak import thingspeak_setRetry
			#set retry to True
			thingspeak_setRetry(True)

		elif opt in ("--thingspeaksnr"):
			print("will plot snr instead of seq")
			global _thingspeaksnr
			_thingspeaksnr = True
			
		elif opt in ("--fiware"):
			print("will enable fiware support")
			global _fiware
			_fiware = True

		elif opt in ("--sensorcloud"):
			print("will enable sensorcloud support")
			global _sensorcloud
			_sensorcloud = True
			global sensorcloud_uploadSingleData
			from SensorCloud import sensorcloud_uploadSingleData

		elif opt in ("--grovestreams"):
			print("will enable grovestreams support")
			global _grovestreams
			_grovestreams = True
			global grovestreams_uploadSingleData
			from GroveStreams import grovestreams_uploadSingleData
															
		elif opt in ("-L", "--loggw"):
			print("will log gateway message prefixed by ^$")
			global _logGateway
			_logGateway = 1	

		elif opt in ("-a", "--addr"):
			global _gwaddr
			_gwaddr = arg
			print("overwrite: will use _"+str(_gwaddr)+" for gateway and telemetry log files")
			
		elif opt in ("--wappkey"):
			global _wappkey
			_wappkey = 1
			global _validappkey
			_validappkey=0
			print("will check for correct app key")

		elif opt in ("--raw"):
			global _rawFormat
			_rawFormat = 1
			print("raw output from gateway. post_processing_gw will handle packet format")
						
		elif opt in ("-m", "--mongodb"):
			print("will enable local MongoDB support, max months to store is "+arg)
			global _mongodb
			_mongodb = True
			
			global add_document, remove_if_new_month, mongodb_set_max_months
			from MongoDB import add_document, remove_if_new_month, mongodb_set_max_months
			#setting max months
			mongodb_set_max_months(int(arg))