From 770acfd68a6c4cbf2e62bb9b129b8ccc446f01ab Mon Sep 17 00:00:00 2001 From: z411 Date: Mon, 1 Apr 2019 16:52:42 -0300 Subject: oekaki: Usando os.path.join PS: En realidad esta es la forma correcta de trabajar con directorios en Python. Lo ideal sería corregir la aplicación completa para que se utilice (en vez de concats ordinarios) y quitar el trailing slash desde los directorios en la configuración. --- cgi/oekaki.py | 6 +++--- cgi/weabot.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'cgi') diff --git a/cgi/oekaki.py b/cgi/oekaki.py index 14c3a1d..e20316c 100644 --- a/cgi/oekaki.py +++ b/cgi/oekaki.py @@ -116,7 +116,7 @@ def oekaki(self, path_split): board = setBoard(path_split[3]) ip = inet_aton(self.environ["REMOTE_ADDR"]) - fname = "%s/%s/temp/%d.png" % (Settings.IMAGES_DIR, board['dir'], ip) + fname = os.path.join(Settings.IMAGES_DIR, board['dir'], "temp", str(ip) + ".png") if path_split[4] == 'b64': page = write_from_base64(fname, self.formdata['image']) @@ -139,7 +139,7 @@ def oekaki(self, path_split): ts = int(time.time()) ip = inet_aton(self.environ["REMOTE_ADDR"]) - fname = "%s/%s/temp/%d.png" % (Settings.IMAGES_DIR, board['dir'], ip) + fname = os.path.join(Settings.IMAGES_DIR, board['dir'], "temp", str(ip) + ".png") oek = 'no' if 'filebase' in self.formdata: @@ -213,4 +213,4 @@ def write_from_shi(fname, fp): with open(fname, 'wb') as f: f.write(img) - return "OK" \ No newline at end of file + return "OK" diff --git a/cgi/weabot.py b/cgi/weabot.py index a85c2e7..5757df2 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -599,7 +599,7 @@ class weabot(object): # process files if oek_file: try: - fname = "%s/%s/temp/%s.png" % (Settings.IMAGES_DIR, board['dir'], oek_file) + fname = os.path.join(Settings.IMAGES_DIR, board['dir'], "temp", oek_file + ".png") with open(fname, 'rb') as f: file = f.read() except: -- cgit v1.2.1-18-gbd029 From 8c5281cea797d2004087adf7642c5b8447e1b5f9 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 2 Apr 2019 16:12:51 +0000 Subject: Este parámetro no viene en todos los casos. --- cgi/weabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cgi') diff --git a/cgi/weabot.py b/cgi/weabot.py index 5757df2..f5451d9 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -39,7 +39,7 @@ class weabot(object): self.start = start_response - if self.environ["QUERY_STRING"] != "rawpost": + if self.environ.get("QUERY_STRING") != "rawpost": self.formdata = getFormData(self) self.output = "" -- cgit v1.2.1-18-gbd029