From 9273fc7f50a4a616d6575892b2f2f80203c5a499 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 19 Sep 2020 11:13:08 +0200 Subject: [PATCH 1/4] CHANGELOG --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 197b89f..e68b73e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +3.1 +- Fix version check + 3.0 - UI shows different colours for different types - Better documentation on the website From 07e54acc49fe0d6ff34dc5185b57f4d63406ab92 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 19 Sep 2020 11:36:50 +0200 Subject: [PATCH 2/4] Import http stuff when needed This makes startup faster --- relational/maintenance.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/relational/maintenance.py b/relational/maintenance.py index 954438a..f8cfde9 100644 --- a/relational/maintenance.py +++ b/relational/maintenance.py @@ -18,8 +18,6 @@ # # Stuff non-related to relational algebra, but used for maintenance. -import http.client -import urllib.parse import os.path import pickle import base64 @@ -39,6 +37,8 @@ def send_survey(data) -> int: returns 0 in case of error returns -1 in case of swearwords''' + import urllib.parse + from http.client import HTTPConnection post = '' for i in data.keys(): @@ -53,7 +53,7 @@ def send_survey(data) -> int: params = urllib.parse.urlencode({'survey': post}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} - connection = http.client.HTTPConnection('feedback-ltworf.appspot.com') + connection = HTTPConnection('feedback-ltworf.appspot.com') try: connection.request("POST", "/feedback/relational", params, headers) return connection.getresponse().status @@ -65,7 +65,8 @@ def check_latest_version() -> Optional[str]: '''Returns the latest version available. Heavely dependent on server and server configurations not granted to work forever.''' - connection = http.client.HTTPConnection('feedback-ltworf.appspot.com') + from http.client import HTTPConnection + connection = HTTPConnection('feedback-ltworf.appspot.com') try: connection.request("GET", "/version/relational") r = connection.getresponse() From bd8dd1f03ccb5a190222a06b0e2622f09348e3fd Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 19 Sep 2020 11:39:14 +0200 Subject: [PATCH 3/4] Move swearwords in the function --- relational/maintenance.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/relational/maintenance.py b/relational/maintenance.py index f8cfde9..d6837f3 100644 --- a/relational/maintenance.py +++ b/relational/maintenance.py @@ -28,9 +28,6 @@ from relational import parser from relational.rtypes import is_valid_relation_name -SWEARWORDS = {'fuck', 'shit', 'suck', 'merda', 'mierda', 'merde'} - - def send_survey(data) -> int: '''Sends the survey. Data must be a dictionary. returns the http response. @@ -40,6 +37,8 @@ def send_survey(data) -> int: import urllib.parse from http.client import HTTPConnection + SWEARWORDS = {'fuck', 'shit', 'suck', 'merda', 'mierda', 'merde'} + post = '' for i in data.keys(): post += '%s: %s\n' % (i, data[i].strip()) From 390fc42a2c6f7126734e15be99766794967fce03 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 19 Sep 2020 11:44:10 +0200 Subject: [PATCH 4/4] Check new version from github releases Instead of using my own website. So I no longer need to update it to reflect the latest version. --- relational/maintenance.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/relational/maintenance.py b/relational/maintenance.py index d6837f3..f72c3da 100644 --- a/relational/maintenance.py +++ b/relational/maintenance.py @@ -64,20 +64,17 @@ def check_latest_version() -> Optional[str]: '''Returns the latest version available. Heavely dependent on server and server configurations not granted to work forever.''' - from http.client import HTTPConnection - connection = HTTPConnection('feedback-ltworf.appspot.com') + import json + import urllib.request + try: - connection.request("GET", "/version/relational") - r = connection.getresponse() + req = urllib.request.Request('https://api.github.com/repos/ltworf/relational/releases') + with urllib.request.urlopen(req) as f: + data = json.load(f) + return data[0]['name'] except: return None - # html - s = r.read() - if len(s) == 0: - return None - return s.decode().strip() - class UserInterface: