Beispiel #1
0
def run(settings):
    """
	run
		settings - 	takes a settings dictionary,
					can be correctly formatted by calling create_settings
					with valid parameters
	"""
    print settings
    print "Loading operations.py..."
    ol = OperationsLoader(currrent_path + OPERATIONS_PATH)
    settings[SETTINGS_OPERATIONS] = ol.load(settings[SETTINGS_OUTPUT],
                                            settings[SETTINGS_VARIABLES])

    print "Loading Transformers (parsers)..."
    settings[SETTINGS_TRANSFORMERS] = [
        PassTransformer(TRANSFORMER_NAME_PASS),
        WriteTransformer(TRANSFORMER_NAME_WRITE),
        ReadTransformer(TRANSFORMER_NAME_READ)
    ]
    settings[SETTINGS_PYLOGGERENV] = '%s/visualize/' % currrent_path
    settings[SETTINGS_MAIN] = settings[SETTINGS_PYLOGGERENV] + path.basename(
        settings[SETTINGS_MAIN])

    if settings[SETTINGS_PYLOGGERENV] not in sys.path:
        print "Creating temporary visualization environment & adding to sys.path at:\n%s" % settings[
            SETTINGS_PYLOGGERENV]
        sys.path.insert(0, settings[SETTINGS_PYLOGGERENV])
    create_env(settings)

    print "Creating Header..."
    files = [settings[SETTINGS_ROOTDIR] + f for f in settings[SETTINGS_FILES]]
    header = create_header(2.0, settings[SETTINGS_VARIABLES], files)
    if w is not None:
        print "Sending header to LogStreamManager"
        w.send(header)

    print "Creating/Overwriting output file at:%s" % settings[SETTINGS_OUTPUT]
    open(settings[SETTINGS_OUTPUT], 'w').close()

    print "Running main file:\n%s" % settings[SETTINGS_MAIN]
    execfile(settings[SETTINGS_MAIN], globals())

    print "Removing %s from sys.path" % settings[SETTINGS_PYLOGGERENV]
    sys.path.remove(settings[SETTINGS_PYLOGGERENV])

    print "Formatting json buffer from output..."
    processor = LogPostProcessor(settings[SETTINGS_OUTPUT])
    output = processor.process(settings[SETTINGS_VARIABLES])
    dump_json(header, output, settings[SETTINGS_OUTPUT])

    print "Removing visualization environment..."
    system('rm -rf %s' % settings[SETTINGS_PYLOGGERENV])

    print "Done! Output stored at:\n%s" % settings[SETTINGS_OUTPUT]
Beispiel #2
0
def run(settings):
	"""
	run
		settings - 	takes a settings dictionary,
					can be correctly formatted by calling create_settings
					with valid parameters
	"""
	print settings
	print "Loading operations.py..."
	ol = OperationsLoader(currrent_path+OPERATIONS_PATH)
	settings[SETTINGS_OPERATIONS] = ol.load(settings[SETTINGS_OUTPUT],settings[SETTINGS_VARIABLES])
	
	print "Loading Transformers (parsers)..."
	settings[SETTINGS_TRANSFORMERS] = [PassTransformer(TRANSFORMER_NAME_PASS), WriteTransformer(TRANSFORMER_NAME_WRITE), ReadTransformer(TRANSFORMER_NAME_READ)]
	settings[SETTINGS_PYLOGGERENV] = '%s/visualize/' % currrent_path
	settings[SETTINGS_MAIN] = settings[SETTINGS_PYLOGGERENV] + path.basename(settings[SETTINGS_MAIN])
	
	if settings[SETTINGS_PYLOGGERENV] not in sys.path:
		print "Creating temporary visualization environment & adding to sys.path at:\n%s" % settings[SETTINGS_PYLOGGERENV]
		sys.path.insert(0,settings[SETTINGS_PYLOGGERENV])
	create_env(settings)
	
	print "Creating Header..."
	files = [settings[SETTINGS_ROOTDIR]+f for f in settings[SETTINGS_FILES]]
	header = create_header(2.0,settings[SETTINGS_VARIABLES],files)
	if w is not None:
		print "Sending header to LogStreamManager"
		w.send(header)
	
	print "Creating/Overwriting output file at:%s" % settings[SETTINGS_OUTPUT]
	open(settings[SETTINGS_OUTPUT],'w').close()
	
	print "Running main file:\n%s" % settings[SETTINGS_MAIN]
	execfile(settings[SETTINGS_MAIN],globals())
	
	print "Removing %s from sys.path" % settings[SETTINGS_PYLOGGERENV]
	sys.path.remove(settings[SETTINGS_PYLOGGERENV])

	print "Formatting json buffer from output..."
	processor = LogPostProcessor(settings[SETTINGS_OUTPUT]) 
	output 	  = processor.process(settings[SETTINGS_VARIABLES])
	dump_json(header,output,settings[SETTINGS_OUTPUT])

	print "Removing visualization environment..."
	system('rm -rf %s' % settings[SETTINGS_PYLOGGERENV])

	print "Done! Output stored at:\n%s" % settings[SETTINGS_OUTPUT]
Beispiel #3
0
def put(statement):
    with open(outfile, 'a') as f:
        f.write('%s,' % str(statement))
        f.close()
    if w is not None:
        print w.send(dumps({JSON_BODY: [statement], JSON_HEADER: None}))
Beispiel #4
0
def put(statement):
    with open(outfile, 'a') as f:
        f.write('%s,' % str(statement))
        f.close()
    if w is not None:
        print w.send(dumps({JSON_BODY : [statement], JSON_HEADER : None}))