I am new to Python and stuck in an issue, have researched in stackoverflow but couldnt get an answer. The problem statement is as below.
Problem: I was using html module in python 2.x version for displaying data in a dashboard. Due to regulatons we have upgraded to python 3.68 .Post upgradation html module is not working. The object instatntiated from the html module is used for displaying title,body,table etc.
The infrastructure details are as below
Any help is highly appreciated
Problem: I was using html module in python 2.x version for displaying data in a dashboard. Due to regulatons we have upgraded to python 3.68 .Post upgradation html module is not working. The object instatntiated from the html module is used for displaying title,body,table etc.
The infrastructure details are as below
Output:NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
The error displayed in terminal is as below.Error:Traceback (most recent call last):
File "dashbord.py", line 9, in <module>
from html import HTML
ImportError: cannot import name 'HTML'
Source code as below1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import time import sys import os import re import pymongo from pymongo import MongoClient import base64 from datetime import datetime,timedelta from html import HTML d = datetime.today() - timedelta(hours = 0 , minutes = 180 ) d1 = d.strftime( "%d/%B/%Y,%H:%M:%S" ) #threshholdLimitPriceLineProperties=320000 threshholdLimitPriceLineProperties = 130000 h = HTML( 'html' ,'') title = h.title( 'Hotel DASHBOARD With PriceLine' ) def saveFile(): #print "here" conn = MongoClient( "xx.xx.xx.xx:27017" ) #print conn TravelHotelsPricelineDb = conn.travelHotelsPriceline rawLocationsHotelsPricelineDatacount = TravelHotelsPricelineDb.rawLocationsData.count() finishedLocationHotelsPricelineValidDatacount = TravelHotelsPricelineDb.finishedLocationsData.find({ "metaData.status" : "VALID" }).count() with open ( "/home/tomcat/scripts/HotelOutput_new_pricingDataLine_data.txt" , "a" ) as text_file: #text_file.write('{0} {1} {2} {3} {4} {5} {6} {7} {8} \n'.format(d1,rawLocationsDatacount,rawPropertiesDatacount,validHotelCount,Hotel,vacationRental,validLocationCount,rawLocationsHotelsPricelineDatacount,finishedLocationHotelsPricelineValidDatacount)) text_file.write( '{0} {1} {2} \n' . format (d1,rawLocationsHotelsPricelineDatacount,finishedLocationHotelsPricelineValidDatacount)) text_file.close() saveFile() def sortFile(): #print "in sort section" with open ( '/home/tomcat/scripts/HotelOutput_new_pricingDataLine_data.txt' ) as fi, open ( '/home/tomcat/scripts/sortHotel_new_pricingDataLine_data.txt' , 'w' ) as fo: fo.write( '\n' .join( reversed (fi.read().splitlines()))) sortFile() def readFile(): #h1.br #h=HTML('html','') title = h.title( 'HOTEL DASHBOARD' ) h.BODY( bgcolor = "FFFDE7" ) h.b p = h.p( 'HOTEL DETAILS WITH PRICELINE DATA' , ' ' , align = "center" ) h.b h.b h.b t = h.table(border = '2' ,bgcolor = '#B9CFFA' ,align = "center" ) r = t.tr() r.td( 'Date & Time' ,style = "font-weight:bold" ) r.td( 'Raw Hotel Count - PriceLine' ,style = "font-weight:bold" ) r.td( 'Valid Hotel Count - PriceLine' ,style = "font-weight:bold" ) r.td( 'Threshold Limit for Hotel - PriceLine' ,style = "font-weight:bold" ) contents = open ( "/home/tomcat/scripts/sortHotel_new_pricingDataLine_data.txt" , "r" ) for line in contents: line = line.strip() parts = line.split() dateTime = parts[ 0 ] rawLocationsHotelsPricelineDatacount = parts[ 1 ] finishedLocationHotelsPricelineValidDatacount = parts[ 2 ] r.tr() r.td(dateTime) r.td(rawLocationsHotelsPricelineDatacount) if ( int (finishedLocationHotelsPricelineValidDatacount) < = int (threshholdLimitPriceLineProperties) ): r.td(finishedLocationHotelsPricelineValidDatacount,bgcolor = "red" ) else : r.td(finishedLocationHotelsPricelineValidDatacount) r.td( str (threshholdLimitPriceLineProperties)) r.tr() #r.td(bgcolor="grey") #r.td(bgcolor="grey") contents.close() readFile() print (h) |