def test_callback(evpath, evname):
	print "test_callback: evpath=", evpath, "evname = ", evname
	excelfileloader = ExcelFileLoader.ExcelFileLoader()
	trainIDs = excelfileloader.loadfile(evpath+'/'+evname)

	for l in trainIDs:
        	print l
Exemplo n.º 2
0
def excelFileChanged_callback(evpath, evname):
    global trainNum2ID
    print "new Excel File has been uploaded: newpath=", evpath, "new file name = ", evname
    # saving folder and filenames into configuration file
    serverConfiguration.setExcelFileNameForSchedule(evname)
    excelfileloader = ExcelFileLoader.ExcelFileLoader()
    trainNum2ID = excelfileloader.loadfile(evpath + '/' + evname)
    Trains = bigTable.initializeTrainTables(trainNum2ID, NUMBER_OF_SENSORS)
    for l in trainNum2ID:
        print str(l) + "->" + str(trainNum2ID[l])
Exemplo n.º 3
0
def excelFileChanged_callback(evpath, evname):
    global trainNum2ID
    print "new Excel File has been uploaded: newpath=", evpath, "new file name = ", evname

    # saving folder and filenames into configuration file
    serverConfiguration.setExcelFileNameForSchedule(evname)

    excelfileloader = ExcelFileLoader.ExcelFileLoader()
    trainIDs = excelfileloader.loadfile(evpath + '/' + evname)
    #TODO: convert trainIDs to trainNum2ID
    trainNum2ID = convertTrainList2Dict(trainIDs)

    for l in trainNum2ID:
        print str(l) + "->" + str(trainNum2ID[l])
Exemplo n.º 4
0
    trainDict = dict()
    for val1, val2 in trainIDlist:
        trainDict[int(val1)] = int(val2)

    print "result of convertion from list of trains to dicitionary ->", trainDict
    return trainDict


serverConfiguration = ServerConfiguration.ServerConfiguration(
    'server.cfg')  # load Server Configuration from server.cfg
Excel_foldername = serverConfiguration.getExcelFolderNameForSchedule()
Excel_filename = serverConfiguration.getExcelFileNameForSchedule()

print 'Excel Folder =', Excel_foldername, 'and filename =', Excel_filename

excelFileLoader = ExcelFileLoader.ExcelFileLoader()
#trainIDList = excelFileLoader.loadfile(Excel_foldername + '/' + Excel_filename)
trainNum2ID = excelFileLoader.loadfile(Excel_foldername + '/' + Excel_filename)

print 'TrainNum2ID: ', trainNum2ID
#### another quick fix -> converting back from trainID to trainNum
ID2TrainNum = dict()
for t in trainNum2ID:
    ID2TrainNum[trainNum2ID[t]] = t
print 'ID2TrainNum: ', ID2TrainNum
##################################################################

#trainNum2ID = convertTrainList2Dict(trainIDList)
# in order to start file validator that will watch the we need to create new thread

	excelfileloader = ExcelFileLoader.ExcelFileLoader()
	trainIDs = excelfileloader.loadfile(evpath+'/'+evname)

	for l in trainIDs:
        	print l


########## main ##############

serverConfiguration = ServerConfiguration.ServerConfiguration('server.cfg')
foldername = serverConfiguration.getExcelFolderNameForSchedule()
filename = serverConfiguration.getExcelFileNameForSchedule()

print 'Folder=  ',foldername, ' filename= ', filename

excelfileloader = ExcelFileLoader.ExcelFileLoader()
trainIDs = excelfileloader.loadfile(foldername+'/'+filename)

for l in trainIDs:
        print l

print 'Starting the file validator ...'
#excelFileValidator = ExcelFileValidator.ExcelFileValidator( foldername, filename , test_callback) #("webservers/excelsrc", "excel1.xlsx", test_callback)

def ExcelFileValidatorThreadStarter():
	excelFileValidator = ExcelFileValidator.ExcelFileValidator( foldername, filename , test_callback) #("webservers/excelsrc", "excel1.xlsx", test_callback)
	excelFileValidator.startFileWatcher()

#excelFileValidatorThread = threading.Thread(target = ExcelFileValidatorThreadStarter())

#excelFileValidatorThread.daemon = True