From 6a1c6040d2592b00c425f180faf6d3617509b46a Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 22 Dec 2021 09:43:36 +0000 Subject: [PATCH] bugfixes --- server.py | 10 +++++++--- static/app.js | 9 ++------- stockTicker.py | 25 ++++++++++--------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/server.py b/server.py index 7ade3ef..bda24db 100755 --- a/server.py +++ b/server.py @@ -21,6 +21,10 @@ import numpy as np import copy #stock_ticker = StockTicker() #print('API CALLER NOT STARTED') + +#open('log.txt', 'w').close() #wipe logs + + api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py") api_caller.sendline('A') displaying_screensaver = False @@ -238,7 +242,7 @@ def save(): @app.route("/upload", methods = ['PUT', 'POST', 'GET']) def upload(): try: - remove_old_uploads() + images = request.files names = list(request.files.keys()) @@ -458,8 +462,7 @@ def save_weather_settings(input_settings): current_settings['animation'] = input_settings['animation'].lower() current_settings['temp'] = input_settings['temp'].lower() current_settings['wind_speed'] = input_settings['wind_speed'].lower() - current_settings['colour'] = input_settings['colour'].lower() - current_settings['city_colour'] = input_settings['city_colour'].lower() + current_settings['title'] = input_settings['title'] if input_settings['feature'] == 'Daily Forecast': @@ -532,6 +535,7 @@ def save_image_settings(input_settings): del current_settings['feature'] json.dump(current_settings, open('csv/' + filename, 'w+')) + remove_old_uploads() def save_message_settings(input_settings): diff --git a/static/app.js b/static/app.js index 7305b6c..56b6dcf 100755 --- a/static/app.js +++ b/static/app.js @@ -1055,17 +1055,12 @@ function getTradingSettings(page) { function getWeatherSettings(page) { let temp = getSelected(page.querySelectorAll(".temp-select")[0]); let speed = getSelected(page.querySelectorAll(".wind-speed-select")[0]); - let colour = getSelected(page.querySelectorAll(".colour-select")[0]); - let city_colour = getSelected( - page.querySelectorAll(".city-colour-select")[0] - ); + let title = page.querySelectorAll(".title-select")[0].checked; settings = { temp: temp, wind_speed: speed, - colour: colour, - city_colour: city_colour, title: title, }; @@ -1079,7 +1074,7 @@ function getWeatherSettings(page) { let locations_el = page.querySelectorAll(".location-list")[0]; let locations = getListItems(locations_el); settings["locations"] = locations; - + console.log(settings); return settings; } diff --git a/stockTicker.py b/stockTicker.py index 7f640b4..6458658 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2516,8 +2516,10 @@ class StockTicker(): try: GIF = Image.open(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), fle)) + frames = [] + if ind == 0 and all_settings['title']: - frames = [] + title_img = self.openImage('feature_titles/gifs.png') for i, frame in enumerate(ImageSequence.Iterator(GIF)): @@ -2526,25 +2528,18 @@ class StockTicker(): f = self.stitchImage([title_img, frame]) frames.append(f) - - frames[0].save('./display_images/working_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False) - GIF = Image.open('./display_images/working_gif.gif') - GIFs.append(GIF) - else: - frames = [] - - + for i, frame in enumerate(ImageSequence.Iterator(GIF)): frame.thumbnail((99999, 32)) - - frames.append(frame) + f = frame + frames.append(f) - frames[0].save('./display_images/working_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False) - GIF = Image.open('./display_images/working_gif.gif') - GIFs.append(GIF) + frames[0].save('./display_images/working_gif{}.gif'.format(str(ind)), save_all=True, append_images=frames[1:], loop=0, optimize = False) + GIF = Image.open('./display_images/working_gif{}.gif'.format(str(ind))) + GIFs.append(GIF) except Exception as e: @@ -2556,7 +2551,7 @@ class StockTicker(): self.logf.write('. type: ' + str(exc_type)) self.logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))) - + self.logf.write(str(GIFs)) #below code stitches title and GIF together '''