import os
import subprocess
import sys
import time
import xlrd
import openpyxl
import shutil
from datetime import datetime,timedelta
import re
import pandas as pd
import numpy as np
import plotly.offline as py
import plotly.graph_objs as go
import plotly.io as pio
import plotly.figure_factory as ff
import json
import difflib
ORCA_MAX_COUNT = 22
CMD_RETRY_MAX = 10
def genResult(self, fig, reportName, logpath = None, NeedPic=True, width=650, height=480):
if logpath == None:
logpath = self.getLogPath()
folderPath = logpath
if not os.path.exists(folderPath):
os.makedirs(folderPath)
path_output = folderPath+"\\"+reportName+".html"
py.plot(fig, filename=path_output,auto_open=False)
if NeedPic == True:
#计数器
if self.image_count >= ORCA_MAX_COUNT:
pio.orca.shutdown_server()
self.wait(2)
self.image_count = 0
else:
self.image_count +=1
path_output_pic = logpath+"\\"+reportName+"."+self.imgType
if not os.path.exists(path_output_pic):
mf = open(path_output_pic, 'w')
mf.close()
try:
pio.orca.shutdown_server()
self.wait(4)
pio.write_image(fig,path_output_pic, width=width, height=height)
except Exception as e:
self.Log("out put png retry "+ reportName)
pio.orca.shutdown_server()
self.wait(4)
pio.orca.ensure_server()
self.wait(4)
self.image_count = 0
pio.write_image(fig,path_output_pic, width=width, height=height)