Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
html module in python 3.6.8
#1
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
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 below

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)
Any help is highly appreciated
Reply


Messages In This Thread
html module in python 3.6.8 - by suifra - May-09-2023, 07:24 AM
RE: html module in python 3.6.8 - by buran - May-09-2023, 09:01 AM
RE: html module in python 3.6.8 - by Larz60+ - May-09-2023, 09:02 AM
RE: html module in python 3.6.8 - by buran - May-09-2023, 09:07 AM
RE: html module in python 3.6.8 - by suifra - May-09-2023, 12:07 PM
RE: html module in python 3.6.8 - by Larz60+ - May-09-2023, 02:50 PM
RE: html module in python 3.6.8 - by snippsat - May-09-2023, 03:41 PM
RE: html module in python 3.6.8 - by suifra - May-10-2023, 10:09 AM
RE: html module in python 3.6.8 - by snippsat - May-11-2023, 03:49 PM
RE: html module in python 3.6.8 - by suifra - May-12-2023, 11:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 969 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  reading html and edit chekcbox to html jacklee26 5 3,132 Jul-01-2021, 10:31 AM
Last Post: snippsat
  HTML to Python to Windows .bat and back to HTML perfectservice33 0 1,976 Aug-22-2019, 06:31 AM
Last Post: perfectservice33

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020