Notebook
'elapsedDuration', 'elapsedDurationMs', 'entryId', 'splitDateTime', 'splitDateTimeLocal', 'splitPointId', 'splitPointTimeId', 'stageTimeDuration', 'stageTimeDurationMs', 'startDateTime', 'startDateTimeLocal', 'stageId', 'class', 'code', 'distance', 'name', 'drivercode', 'elapsedDurationS'
if __name__=='__main__': #Preview splits for a couple of drivers display(splits[splits['drivercode'].isin(['PAD','NEU'])])
if __name__=='__main__': s2 = getDriverSplitsReport(conn, rally, 'SS3', 'LAT', rc, typ, 'overall') display(HTML(s2))if __name__=='__main__': s2 = getDriverSplitsReport(conn, rally, 'SS11', 'PAD', rc, typ, 'previous') display(HTML(s2))#Replace by Dakar tools import os import time from selenium import webdriver def getTableImage(url, fn='dummy_table', basepath='.', path='.', delay=5, height=420, width=800): ''' Render HTML file in browser and grab a screenshot. ''' #should be a tmp file? #fname='testmap.html' #tmpurl='file://{path}/{mapfile}'.format(path=os.getcwd(),mapfile=fn) #folium_map.save(fn) browser = webdriver.Chrome() browser.set_window_size(width, height) browser.get(url) #Give the map tiles some time to load time.sleep(delay) imgpath='{}/{}.png'.format(path,fn) imgfn = '{}/{}'.format(basepath, imgpath) imgfile = '{}/{}'.format(os.getcwd(),imgfn) browser.save_screenshot(imgfile) browser.quit() os.remove(imgfile.replace('.png','.html')) #print(imgfn) return imgpath def getTablePNG(tablehtml,basepath='.', path='testpng', fnstub='testhtml'): ''' Save HTML table as file. ''' if not os.path.exists(path): os.makedirs('{}/{}'.format(basepath, path)) fn='{cwd}/{basepath}/{path}/{fn}.html'.format(cwd=os.getcwd(), basepath=basepath, path=path,fn=fnstub) tmpurl='file://{fn}'.format(fn=fn) with open(fn, 'w') as out: out.write(tablehtml) return getTableImage(tmpurl, fnstub, basepath, path) #print(tmpurl) if __name__=='__main__': getTablePNG(s2)
if __name__=='__main__': #Testing !pip3 install renderer #!pip3 install simple-settings #!pip3 install --upgrade git+https://github.com/istresearch/phantom-snap.git #!pip3 install phantom-snap from phantom_snap.settings import PHANTOMJS from phantom_snap.phantom import PhantomJSRenderer from phantom_snap.imagetools import save_image config = { 'executable': '/usr/local/bin/phantomjs', 'args': PHANTOMJS['args'] + ['--disk-cache=false', '--load-images=true'] } r = PhantomJSRenderer(config) url = 'http://raallydatajunkie.com' html = s2 try: page = r.render(url=url, html=html, img_format='PNG') save_image('.', page) finally: r.shutdown(15)