Ejemplo n.º 1
0
    def get_log(self,start_date='1/1/2001 00:00:00',\
                end_date='1/30/2001 00:00:00',period=900):

        self.log_start_date = start_date
        self.log_end_date = end_date
        self.log_period = period

        int_column_start = 1
        int_column_increment = 1
        flt_column_start = 1.0
        flt_column_increment = 1.0

        int_column = int_column_start
        flt_column = flt_column_start

        tmp = ''
        log = None
        f = None
        column_names = ('timestamp','intColumn','fltColumn')
        log_name = 'test'
        s_date = mktime(strptime(start_date,'%m/%d/%Y %H:%M:%S'))
        e_date = mktime(strptime(end_date,'%m/%d/%Y %H:%M:%S'))
          
        # add save off the current
        tmp = properties.LOGFILE_DIRECTORY
        try:
            f = open(os.path.join(tmp,log_name + '.log'),'w')
            #create the file
            while s_date <= e_date:
                f.write('{\'timestamp\':' + str(s_date) + ',' + \
                        '\'intColumn\':' + str(int_column) + ',' + \
                        '\'fltColumn\':' + str(flt_column) + '}\n')
                int_column = int_column + int_column_increment
                flt_column = flt_column + flt_column_increment
                s_date = s_date + period

            l = Log(log_name)
            l.configure(column_names,max_return_length=200000)

        finally:      
            # switch back the environment variable
            properties.set('LOGFILE_DIRECTORY', tmp)
            f.close()
        return l
Ejemplo n.º 2
0
accordance with section (3) of the GNU General Public License.         
    
This exception does not invalidate any other reasons why a work         
based on this file might be covered by the GNU General Public         
License.
"""
#!/usr/bin/env python-mpx

from mpx.lib.log import Log
import time
import thread

log = Log("test")

#comfiguring what we want to log ( the fields)
log.configure(("column1",))

def test1(l,value,number_of_times=10):
    print "test1()"
    #start time
    counter = 0      
    while counter < number_of_times:
        #adding some values
        print "calling add entry"
        l.add_entry((value,))
        counter = counter + 1
        
        
thread1Counter=1
thread2Counter=11
thread3Counter=4
Ejemplo n.º 3
0
accordance with section (3) of the GNU General Public License.         
    
This exception does not invalidate any other reasons why a work         
based on this file might be covered by the GNU General Public         
License.
"""
#!/usr/local/bin/python2.2

from mpx.lib.log import Log
import time
import sys
#creating the log
l = Log("tmp")

#comfiguring what we want to log ( the fields)
l.configure(["timestamp","KWh","Temp F"])

counter = 0

#start time
t = int(time.time())
x = 0
ADD = 1
TRIM = 0
TRIM_NAME = ""
TRIM_VALUE =""
TRIM_NOT_SET = 1

if len(sys.argv) > 1:
    ADD =  int(sys.argv[1])
Ejemplo n.º 4
0
accordance with section (3) of the GNU General Public License.         
    
This exception does not invalidate any other reasons why a work         
based on this file might be covered by the GNU General Public         
License.
"""
#!/usr/bin/env python-mpx

from mpx.lib.log import Log
import time
import thread

log = Log("test")

#comfiguring what we want to log ( the fields)
log.configure(("column1", ))


def test1(l, value, number_of_times=10):
    print "test1()"
    #start time
    counter = 0
    while counter < number_of_times:
        #adding some values
        print "calling add entry"
        l.add_entry((value, ))
        counter = counter + 1


thread1Counter = 1
thread2Counter = 11