def make_image(data, filepath, title, labels, major_labels): custom_style = Style(background='#fff', plot_background='transparent', title_font_size=14, guide_stroke_dasharray='1,0', major_guide_stroke_dasharray='1,0', foreground='rgba(0, 0, 0, .87)', foreground_strong='rgba(0, 0, 0, .87)', foreground_subtle='rgba(0, 0, 0, .87)', stroke_opacity='1', stroke_opacity_hover='1', stroke_width=10, stroke_width_hover=10, opacity='1', opacity_hover='1', colors=('#C5D4B5BB', '#3D7930')) print(custom_style.to_dict()) r = get_range(data) config = Config() config.interpolate = 'cubic' config.style = custom_style config.width = 400 config.height = 225 config.explicit_size = True config.margin_left = 0 config.margin_right = 0 config.margin_top = 10 config.margin_bottom = 30 config.show_minor_x_labels = False config.truncate_label = -1 config.show_legend = False config.include_x_axis = True config.range = r config.show_dots = False chart = pygal.Line(config) chart.title = ("Throughput (%s, Mb/s)" % (title)) chart.x_labels = labels chart.x_labels_major = major_labels chart.y_labels = [ x for x in range(0, r[1] + 1, 100 if (r[1] > 550) else 50) ] chart.add(None, data, fill=True) chart.add(None, data) #with open(filepath, 'w') as output: # output.write(chart.render()) chart.render_to_png(filepath)
def get_price_chart(self, stat): config = Config() config.show_legend = False config.human_readable = True config.x_label_rotation = 90 config.pretty_print = True config.min_scale = 12 config.height = 480 price_chart = pygal.Line(config) price_chart.title = '售价走势图' price_chart.x_labels = map( lambda x: x.date_created.strftime("%Y-%m-%d"), stat) price_chart.add('价格', [row.price for row in stat]) return price_chart.render_data_uri()
def PygalConfigFile(): config = Config() config.human_readable = True config.height = 250 config.width = 700 config.style = NeonStyle config.show_minor_y_labels = True config.x_label_rotation = 25 config.value_font_size = 8 config.title_font_size = 8 config.legend_font_size = 8 config.legend_box_size = 12 config.label_font_size = 6 return (config)
def PygalConfigFileBlue(): configB = Config() configB.human_readable = True configB.height = 250 configB.width = 700 configB.style = NeonStyle configB.show_minor_y_labels = True configB.x_label_rotation = 25 configB.value_font_size = 8 configB.title_font_size = 8 configB.legend_font_size = 8 configB.legend_box_size = 12 configB.label_font_size = 6 configB.colors = ['#000099', '#009999'] return (configB)
def define_config(): """Defines some configuration settings for the pygal plot.""" config = Config() config.show_legend = False config.human_readable = True config.fill = False config.height = 1000 config.width = 2000 config.x_label_rotation = 300 config.show_legend = False config.x_labels_major_every = 200 # 200 config.show_minor_x_labels = False config.show_dots = False config.fill = True config.logarithmic = False return config
def draw_line(valxy): import pygal from pygal import Config from pygal.style import Style config = Config() custom_style = Style(background='white', foreground='#000', foreground_strong='#000', foreground_subtle='#000', opacity='.9', opacity_hover='.6', plot_background='#fff', transition='100ms', label_font_size=12, major_label_font_size=12, value_font_family='Arial', font_family='Arial', major_label_font_family='Sans', colors=('#3333CC', '#3333CC', '#3333CC', '#3333CC'), guide_stroke_dasharray='2,7', major_guide_stroke_dasharray='2,7') config.margin_left = 0 config.margin_bottom = 0 config.width = 350 config.height = 350 config.x_title = "Angle, degrees" config.y_title = "Overlaps, %" config.explicit_size = True config.show_x_guides = False config.show_y_guides = True xy_chart = pygal.XY(config, show_legend=False, dots_size=3, style=custom_style) #interpolate='quadratic', #xy_chart.title = "Overlaps in oscillation range" xy_chart.add('', valxy) #xy_chart.y_labels = [int(phibg), int(phend)] # col=20 # stp=1 # for val in range(int(phibg), int(phend), stp): # xy_chart.add("", [{'value': val, 'color': 'rgb(%s, 0, 0)' % (col)}], # stroke_style={'width': 1, 'linejoin': 'round', 'linecap': 'round', 'linejoin': 'round'}) # col=col+stp return xy_chart.render(is_unicode=True)
def visualization(self, img, prediction): """Plot list of predictions on barchart Args: img (np.array): image as array prediction (list): array of emotions probabilities Returns: list: barchart as array """ config = Config() config.show_legend = False config.print_labels = True config.show_y_labels = False config.show_y_guides = False config.show_x_guides = False config.max_scale = 12 config.width = img.width config.height = img.height custom_style = Style(background='transparent', plot_background='transparent', foreground='transparent', colors=('#19d5ff', '#19d5ff', '#19d5ff', '#19d5ff', '#19d5ff'), opacity='.8', value_label_font_size=img.width // 30, value__label_font_family='monospace') labels = ['Angry', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral'] data = list(zip(prediction, labels)) data_dict = [] for val, label in data: data_dict.append({'value': val, 'label': label}) bar_chart = pygal.HorizontalBar(config=config, style=custom_style) bar_chart.add('', data_dict) imgByteArr = BytesIO() bar_chart.render_to_png(imgByteArr) #pygal, no comments #bar = Image.open('./tmp.png') bar = Image.open(imgByteArr) return bar
def pie(data, inner_radius=0): config = Config() #config.show_legend = False config.height = 300 config.width = 300 #config.print_values=True #config.print_labels=True #config.half_pie=True config.value_formatter = lambda x: f'{x}%' # config.style= RedBlueStyle( # value_font_size=15, # value_label_font_size=15, # value_colors=()) #config.legend_at_bottom=True #config.legend_at_bottom_columns=3 config.dynamic_print_values = True config.inner_radius = inner_radius graph = pygal.Pie(config, title="Number of Dogs Owned") for item in data: graph.add(item, data[item]) #[{'value': data[item], 'label':item}]) graph_data = graph.render_data_uri() return graph_data
def draw_position(groups, filename="position.svg", dir="images", drawSource=True, drawReceptors=True): ''' plot sources' and receptors' position ''' from pygal import Config config = Config() config.title = "Position" config.show_lengend = False config.height = 500 config.stroke = False config.dots_size = 2.5 plot = pygal.XY(config, x_title="X/m", y_title="Y/m", show_x_guides=True, print_labels=True, style=pygal.style.styles["default"](value_font_size=2)) if drawSource: src = groups.sourceInfo meta = [] for line in src: name = line[0] coor = line[1:3].astype(float) * 1000 meta.append({'value': tuple(coor), 'label': name}) plot.add("sources", meta) if drawReceptors: recep = groups.receptors meta = [] for line in recep: name = line[0] coor = line[1:3].astype(float) * 1000 meta.append({'value': tuple(coor), 'label': name, 'dots_size': 2}) plot.add("receptors", meta) plot.render_to_file(pathlib.Path(dir) / filename)
def get_sale_chart(self, stat, df): config = Config() config.show_legend = False config.human_readable = True # config.fill = True config.x_label_rotation = 90 config.pretty_print = True config.min_scale = 12 config.height = 480 # config.print_values = True # config.print_values_position = 'top' # config.value_font_size=30 sale_chart = pygal.Line(config) sale_chart.title = '销量与销售额' sale_chart.x_labels = map( lambda x: x.date_created.strftime("%Y-%m-%d"), stat) price_se = df.price.convert_objects(convert_numeric=True) sale_se = df.sale_num.diff().fillna(0) sale_chart.add('销量', [row for row in sale_se]) sale_chart.add('销售额', [row for row in price_se.mul(sale_se)], secondary=True) # return sale_chart.render() return sale_chart.render_data_uri()
def identify(self, filename): self.report["filename"] = os.path.basename(filename) self.report["filename_absolute"] = filename self.report["filemimetype"] = utils.file_mimetype(filename) self.report["filemagic"] = utils.file_magic(filename) if self.report["filemimetype"] in self.pcapmimetypes: self.report["filecategory"] = "CAP" self.report["filetype"] = "PCAP" self.logger.info( "Identified %s as type %s (%s)" % (self.report["filename"], self.report["filetype"], self.report["filemimetype"]) ) else: self.logger.info( "File %s of type %s is not supported in the current version" % (self.report["filename"], self.report["filemimetype"]) ) return None self.logger.debug("Calculating file hashes for %s" % (self.report["filename"])) self.report["hashes"]["crc32"] = utils.file_hashes(filename, "crc32") self.report["hashes"]["md5"] = utils.file_hashes(filename, "md5") self.report["hashes"]["sha1"] = utils.file_hashes(filename, "sha1") self.report["hashes"]["sha256"] = utils.file_hashes(filename, "sha256") self.report["hashes"]["sha512"] = utils.file_hashes(filename, "sha512") self.report["hashes"]["ssdeep"] = utils.file_hashes(filename, "ssdeep") self.logger.info("Completed crc32/md5/sha{1,256,512}/ssdeep hash calculations") if self.config["enable_entropy_compression_stats"]: self.logger.debug("Collecting entropy compression stats for %s" % (self.report["filename"])) stats = utils.entropy_compression_stats(filename) self.report["filesize"] = stats["filesizeinbytes"] self.report["fileminsize"] = float(stats["minfilesize"]) self.report["filecompressionratio"] = float(stats["compressionratio"]) self.report["fileentropy"] = float(stats["shannonentropy"]) # if entropy falls within the 0 - 1 or 7 - 8 range, categorize as suspicious if (self.report["fileentropy"] > 0 and self.report["fileentropy"] < 1) or self.report["fileentropy"] > 7: self.report["fileentropy_category"] = "SUSPICIOUS" else: self.report["fileentropy_category"] = "NORMAL" self.logger.info("Completed entropy compression stats collection") else: stats = {} if self.config["enable_bytefreq_histogram"]: self.logger.debug("Generating Byte-Frequency histogram for %s" % (self.report["filename"])) config = Config() config.x_title = "Bytes" config.y_title = "Frequency" config.x_scale = 0.25 config.y_scale = 0.25 config.width = 900 config.height = 300 config.title_font_size = 9 config.tooltip_font_size = 0 config.tooltip_border_radius = 0 config.no_data_text = "" config.show_legend = False config.show_only_major_dots = True config.human_readable = False config.show_y_labels = False config.fill = True config.style = CleanStyle bar_chart = pygal.Bar(config) if "bytefreqlist" in stats.keys(): bar_chart.add("", stats["bytefreqlist"]) self.report["filebytefreqhistogram"] = bar_chart.render(is_unicode=False) self.logger.info("Completed Byte-Frequency histogram generation") # testing and db support to identify visually similar files/sessions if self.config["enable_file_visualization"]: self.logger.debug("Generating file visualization for %s" % (self.report["filename"])) self.report["filevis_png"] = utils.file_to_pngimage(filename) self.report["filevis_png_bw"] = utils.file_to_pngimage(filename, enable_colors=False) self.logger.info("Completed file visualization generation") return dict(self.report)
def get(self): self._context.error = '' step = self.get_argument("step", 0) self._context.next = self.get_next_url() #获取用户uid user_info = None uid = self.get_secure_cookie('uid', None) if (step == '1' or step == '2' or step == '3' or step == 'end') and (not uid): self.redirect('/reg/?step=0') return else: #获取用户信息 user_info = self.user.getItem(uid) if urlparse.urlparse(self._context.next).path == '/reg': self._context.next = '/index' if step == '0': self.assignDirection() if uid: self._context.user_info = user_info self._context.area = ','.join( self.d.getDistrictParents(user_info['area_id'], res=[])) else: self._context.user_info = None self._handler_template = 'user/reg.html' elif step == '1': #判断用户是否保存到cookie中 if not uid: self.redirect('/reg/?step=0') #获取用户信息 user_info = self.user.getItem(uid) self._context.user_info = user_info self._context.user_email = user_info['user_email'] #判断是否给用户发送了邮件 self._context.is_send = True uv = UserVerify() uv_info = uv.getVerifyInfo(uid) if uv_info: #不需要发送邮件 self._context.is_send = False #验证url没有过期 now = int(time.mktime(datetime.datetime.now().timetuple())) if user_info[ 'is_verify'] != 1 and utiles.formateDateToTimestamp( uv_info['verify_expire_time']) > now: self._context.error = ErrorMessage.error_message['016'] elif user_info[ 'is_verify'] != 1 and utiles.formateDateToTimestamp( uv_info['verify_expire_time']) <= now: self._context.is_send = True self._handler_template = 'user/reg_step_1.html' elif step == '2': #判断是否给用户发送了邮件 ret = self.checkTokenUrl(uid) self._context.is_send = True if ret['code'] == 'success' else False if ret['code'] == 'error': self._context.error = ret['msg'] self._handler_template = 'user/reg_step_1.html' else: list = self.getChaList() self._context.list = list self._context.ids = ','.join( [str(item['id']) for item in list]) self._handler_template = 'user/reg_step_2.html' elif step == '3': ut = UserBfiTest() ut_info = ut.queryOne(filterString=[('uid', uid)], fields=ut._table_columns) if ut_info: #获取性格测试平均值 sysconfig = SysConfig() bfi_vals = sysconfig.getConfig('bfi_total') bfi_user_total = int( sysconfig.getConfig('bfi_user_total')['val']) #建立雷达图 config = Config() config.explicit_size = True config.width = 500 config.height = 450 config.label_font_size = 14 config.x_label_rotation = 1 radar_chart = pygal.Radar(config) radar_chart.title = u'人格初测结果' radar_chart.x_labels = [ u'开放性O', u'神经质N', u'宜人性A', u'外向型E', u'尽职性C' ] radar_chart.add(user_info['user_name'], [ int(ut_info['O_val']), int(ut_info['N_val']), int(ut_info['A_val']), int(ut_info['E_val']), int(ut_info['C_val']) ]) radar_chart.add(u'平均值', [ bfi_vals['O'] / bfi_user_total, bfi_vals['N'] / bfi_user_total, bfi_vals['A'] / bfi_user_total, bfi_vals['E'] / bfi_user_total, bfi_vals['C'] / bfi_user_total ]) self._context.radar = radar_chart.render() #评价 self._context.N_msg = BfiCharacterTest.transform( 'N', int(ut_info['N_val']))[0] self._context.O_msg = BfiCharacterTest.transform( 'O', int(ut_info['O_val']))[0] self._context.A_msg = BfiCharacterTest.transform( 'A', int(ut_info['A_val']))[0] self._context.E_msg = BfiCharacterTest.transform( 'E', int(ut_info['E_val']))[0] self._context.C_msg = BfiCharacterTest.transform( 'C', int(ut_info['C_val']))[0] #从人格特点推荐好友 #活动推荐 else: self._context.radar = None self._handler_template = 'user/reg_step_3.html' #跳转到活动列表页 elif step == 'end': self.redirect('/activity') self.render(self._handler_template) return
def identify(self, filename): self.report['filename'] = os.path.basename(filename) self.report['filename_absolute'] = filename self.report['filemimetype'] = utils.file_mimetype(filename) self.report['filemagic'] = utils.file_magic(filename) if self.report['filemimetype'] in self.pcapmimetypes: self.report['filecategory'] = 'CAP' self.report['filetype'] = 'PCAP' self.logger.info('Identified %s as type %s (%s)' % (self.report['filename'], self.report['filetype'], self.report['filemimetype'])) else: self.logger.info('File %s of type %s is not supported in the current version' % (self.report['filename'], self.report['filemimetype'])) return None self.logger.debug('Calculating file hashes for %s' % (self.report['filename'])) self.report['hashes']['crc32'] = utils.file_hashes(filename, 'crc32') self.report['hashes']['md5'] = utils.file_hashes(filename, 'md5') self.report['hashes']['sha1'] = utils.file_hashes(filename, 'sha1') self.report['hashes']['sha256'] = utils.file_hashes(filename, 'sha256') self.report['hashes']['sha512'] = utils.file_hashes(filename, 'sha512') self.report['hashes']['ssdeep'] = utils.file_hashes(filename, 'ssdeep') self.logger.info('Completed crc32/md5/sha{1,256,512}/ssdeep hash calculations') if self.config['enable_entropy_compression_stats']: self.logger.debug('Collecting entropy compression stats for %s' % (self.report['filename'])) stats = utils.entropy_compression_stats(filename) self.report['filesize'] = stats['filesizeinbytes'] self.report['fileminsize'] = float(stats['minfilesize']) self.report['filecompressionratio'] = float(stats['compressionratio']) self.report['fileentropy'] = float(stats['shannonentropy']) # if entropy falls within the 0 - 1 or 7 - 8 range, categorize as suspicious if (self.report['fileentropy'] > 0 and self.report['fileentropy'] < 1) or self.report['fileentropy'] > 7: self.report['fileentropy_category'] = 'SUSPICIOUS' else: self.report['fileentropy_category'] = 'NORMAL' self.logger.info('Completed entropy compression stats collection') else: stats = {} if self.config['enable_bytefreq_histogram']: self.logger.debug('Generating Byte-Frequency histogram for %s' % (self.report['filename'])) config = Config() config.x_title = 'Bytes' config.y_title = 'Frequency' config.x_scale = .25 config.y_scale = .25 config.width = 900 config.height = 300 config.title_font_size = 9 config.tooltip_font_size = 0 config.tooltip_border_radius = 0 config.no_data_text = "" config.show_legend = False config.show_only_major_dots = True config.human_readable = False config.show_y_labels = False config.fill = True config.style = CleanStyle bar_chart = pygal.Bar(config) if 'bytefreqlist' in stats.keys(): bar_chart.add('', stats['bytefreqlist']) self.report['filebytefreqhistogram'] = bar_chart.render(is_unicode=False) self.logger.info('Completed Byte-Frequency histogram generation') # testing and db support to identify visually similar files/sessions if self.config['enable_file_visualization']: self.logger.debug('Generating file visualization for %s' % (self.report['filename'])) self.report['filevis_png'] = utils.file_to_pngimage(filename) self.report['filevis_png_bw'] = utils.file_to_pngimage(filename, enable_colors=False) self.logger.info('Completed file visualization generation') return dict(self.report)
def analyze(self): self.report.filebasename = file_basename(self.config.filename) self.report.filedirname = file_dirname(self.config.filename) self.report.filemimetype = file_mimetype(self.config.filename) magicresult = file_magic(self.config.filename) self.report.filemagic = "%s (%s)" % (magicresult["match"]["longname"], magicresult["match"]["shortname"]) if magicresult["match"] else None self.report.hashes.crc32 = file_hashes(self.config.filename, 'crc32') self.report.hashes.md5 = file_hashes(self.config.filename, 'md5') self.report.hashes.sha1 = file_hashes(self.config.filename, 'sha1') self.report.hashes.sha256 = file_hashes(self.config.filename, 'sha256') self.report.hashes.sha512 = file_hashes(self.config.filename, 'sha512') self.report.hashes.ssdeep = file_hashes(self.config.filename, 'ssdeep') with nostdout(): self.report.subfiles = file_subfiles(self.config.filename) # this might take some time to finish # based on the filesize, runtime might increase # will be autodisabled based on statsfilesizelimit config option if self.config.enableentropycompressionstats: stats = objdict(file_entropy_compression_stats(self.config.filename)) self.report.filesize = stats.filesizeinbytes self.report.fileminsize = float(stats.minfilesize) self.report.filecompressionratio = float(stats.compressionratio) self.report.fileentropy = float(stats.entropy) self.report.fileentropycategory = stats.entropycategory # this might take some time to finish # based on the filesize, runtime might increase # should be autodisabled based on (statsfilesizelimit) config option if self.config.enablefilevisualization: self.report.visual.pngrgb = file_to_pngimage(self.config.filename) self.report.visual.pnggray = file_to_pngimage(self.config.filename, enable_colors=False) rh = identicon(self.report.hashes.sha256) self.report.visual.identicon = rh.identicon if rh.success else None config = Config() config.x_title = 'Bytes' config.y_title = 'Frequency' config.x_scale = .25 config.y_scale = .25 config.width = 900 config.height = 300 config.title_font_size = 9 config.tooltip_font_size = 0 config.tooltip_border_radius = 0 config.no_data_text = "" config.show_legend = False config.show_only_major_dots = True config.human_readable = False config.show_y_labels = False config.fill = True config.style = CleanStyle bar_chart = pygal.Bar(config) # if enableentropycompressionstats config option is disabled, stats won't be generated above # as such we need to explicitly generate, on-demand if not stats: stats = objdict(file_entropy_compression_stats(self.config.filename)) bar_chart.add('', stats.bytefreqlist) self.report.visual.bytefreqhistogram = bar_chart.render(is_unicode=False) # pygal inserts a copyright symbol in rendered chart output # need to explicitly clean it before returning pygalregex = re.compile(r"\xc2\xa9") self.report.visual.bytefreqhistogram = pygalregex.sub("", self.report.visual.bytefreqhistogram) else: self.report.visual.pngrgb = None self.report.visual.pnggray = None self.report.visual.identicon = None self.report.visual.bytefreqhistogram = None # done with analysis, normalize report and return self.report = dict_normalize(self.report)
def create_chartguardian(id_station, station): data_status = dict() data_time = dict() list_status = list() list_time = list() station_name = str() station_id = str() data_down = list() data_up = list() data_label = list() last_problem = str() status_alert = str() provider_alert = str() mediatype_alert = str() streamuri_alert = str() stationid_alert = str() ts = int(time.time()) date_query = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') with drt.connect(db=data_config[env_app]['RETHINK-DB']) as conn: cursor_up = drt.table(data_config[env_app]['RETHINK-TABLE']).filter((drt.row["date"] == date_query) & (drt.row["station_id"] == id_station)).run(conn) cursor_down = drt.table(data_config[env_app]['RETHINK-TABLE']).filter((drt.row["date"] == date_query) & (drt.row["station_id"] == id_station)).run(conn) for document_down in cursor_down: station_name = document_down["station_name"] station_id = document_down["station_id"] if len(document_down["status_array"]) < 31: print("Size array status DOWN") print(len(document_down["status_array"])) start_point = 0 else: start_point = len(document_down["status_array"]) - 31 stat_array = document_down["status_array"] provider_alert = document_down["provider"] mediatype_alert = stream_config[env_app][station]['media-type'] streamuri_alert = stream_config[env_app][station]['uri-stream'] stationid_alert = id_station for index, item in enumerate(stat_array[start_point:]): status_len = len(document_down["status_array"]) ts = int(item["time"]) date_down = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S') #[None, None, None, None, None, None, {'value': 0, 'label': '10:10:10'} if item["status"] == "down": item_down = { 'value': 0, 'label': date_down } item_label = date_down data_down.append(item_down) data_label.append(item_label) last_problem = date_down status_alert = item["status"] else: item_none = None data_down.append(item_none) item_label = None data_label.append(item_label) ts = int(item["time"]) date_day = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') data_status.update({ index: item["status"] }) data_time.update({ index: date_day }) list_status.append(item["status"]) list_time.append(date_day) for document_up in cursor_up: print("==== document_up ===") print(document_up) station_name = document_up["station_name"] station_id = document_up["station_id"] if len(document_up["status_array"]) < 31: print("Size array status UP") len(document_up["status_array"]) start_point = 0 else: start_point = len(document_up["status_array"]) - 31 stat_array = document_up["status_array"] for index, item in enumerate(stat_array[start_point:]): status_len = len(document_up["status_array"]) #{'value': 1, 'label': ''} if item["status"] == "up": print("====== ITEM STATUS =====") print(item) status_val = 1 status_label = "Sin Problemas" item_up = { 'value': 1, 'label': '' } data_up.append(item_up) else: status_val = 0 status_label = "Problemas" item_down = None data_up.append(item_down) try: custom_style = Style( opacity='.6', opacity_hover='.9', transition='400ms ease-in', label_font_family='Liberation Mono', label_font_size=8, major_label_font_size=10, colors=('#e74c3c', '#2980b9', '#e67e22', '#E87653', '#E89B53')) configpg = Config() configpg.human_readable = True configpg.fill = False configpg.x_title='Ultimo Problema: ' + last_problem configpg.show_y_labels=False configpg.legend_at_bottom_columns=False configpg.legend_at_bottom=True configpg.width=850 configpg.height=400 configpg.print_labels=False configpg.margin_bottom=30 configpg.x_label_rotation=60 configpg.range=(0, 1) configpg.show_y_labels=True configpg.pretty_print=True extra_args = { 'ACL': 'public-read', 'CacheControl': 'no-cache, no-store, must-revalidate' } line_chart = pygal.Line(style=custom_style, config=configpg) line_chart.title = station_name + ' - ' + date_query line_chart.x_labels = (data_label) line_chart.x_labels_major = (data_label) line_chart.add('Problemas', data_down , allow_interruptions=True, dots_size=5, stroke_style={'width': 4, 'linecap': 'round', 'linejoin': 'round'}) line_chart.add('Activo',data_up , allow_interruptions=True, show_dots=True, dots_size=5, stroke_style={'width': 4, 'linecap': 'round', 'linejoin': 'round'}) line_chart.add('Rango: 30 minutos', None) line_chart.render_to_png(station_id + '-' + date_query + '.png') #connection.close() #connection.close() upload_s3 = s3.upload_file(station_id + '-' + date_query + '.png', bucket_name, env_app+'/'+station_id + '-' + str(ts) + '.png', ExtraArgs=extra_args) os.remove(station_id + '-' + date_query + '.png') print(last_problem) alert_data = { 's3_key': env_app+'/'+station_id + '-' + str(ts) + '.png', 'time_alert': last_problem } if status_alert == "down": #alert_error(status_alert, station_name, provider_alert, ts, mediatype_alert, streamuri_alert, stationid_alert, date_query, alert_data) streaming_alert(status_alert, station_name, provider_alert, ts, mediatype_alert, streamuri_alert, stationid_alert, date_query, alert_data) return alert_data else: message = "No se tiene data que mostrar" print(message) return message except IOError as e: print("Se tiene un problema") print(e) message = e return message #create_chartguardian("tv-capital", "capital-tv")