fix plot errors
parent
e91d2948d1
commit
4631ed96f6
8
bot.py
8
bot.py
|
|
@ -8,7 +8,7 @@ import logging
|
|||
import requests
|
||||
import schedule
|
||||
|
||||
logging.basicConfig(format='%(levelname)s %(name)s:%(message)s', level=logging.DEBUG)
|
||||
logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s:%(message)s', level=logging.DEBUG, datefmt="%Y.%m.%d %H:%M:%S")
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def parse_time(string):
|
||||
|
|
@ -73,7 +73,11 @@ def post_plot(config):
|
|||
from plot import get_plot
|
||||
with NamedTemporaryFile() as target:
|
||||
image_url = 'https://api.telegram.org/bot{token}/sendPhoto'.format(token=config['token'])
|
||||
files = {'photo': get_plot(target)}
|
||||
photo, last = get_plot(target)
|
||||
files = {'photo': photo}
|
||||
if last + datetime.timedelta(days=1) < datetime.datetime.today():
|
||||
log.info("skipping image, no new updates...")
|
||||
return
|
||||
for chat in config['groups']:
|
||||
files['photo'].seek(0)
|
||||
values = {"chat_id":config['groups'][chat]}
|
||||
|
|
|
|||
4
plot.py
4
plot.py
|
|
@ -49,7 +49,7 @@ def plot(raw, target="wiai.png"):
|
|||
plt.figtext(0.5, 0.25, "created: "+str(date.today()), ha="center")
|
||||
plt.figtext(0.5, 0.2, str(first[0])+" → "+str(last[0]), ha="center")
|
||||
plt.savefig(target, format="PNG", transparent=True, bbox_inches="tight")
|
||||
return target
|
||||
return target, last[0]
|
||||
|
||||
|
||||
def local(target):
|
||||
|
|
@ -59,7 +59,7 @@ def local(target):
|
|||
|
||||
|
||||
def prod(target):
|
||||
plot(requests.get('https://isfswiaiopen.wiai.de/log').json(), target=target)
|
||||
return plot(requests.get('https://isfswiaiopen.wiai.de/log').json(), target=target)
|
||||
|
||||
def get_plot(target):
|
||||
return plot(requests.get('https://isfswiaiopen.wiai.de/log').json(), target=target)
|
||||
|
|
|
|||
Loading…
Reference in New Issue