From ff6bf1b045fa810989a3efc78624123d3fc97f19 Mon Sep 17 00:00:00 2001 From: z411 Date: Mon, 1 Apr 2019 04:28:52 -0300 Subject: Reimplementado oekaki en Python y otros cambios - Portados algoritmos de guardado de imagen a Python e incorporados en weabot - Ahora los dibujos temporales se guardan en el directorio del board (adiĆ³s oek_temp) - (Temporal) Los dibujos no se borran si no que se guardan como .bak - Arreglado bug donde se pierde el dibujo si hubo cualquier problema al subir --- cgi/weabot.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index c38a972..a85c2e7 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -38,7 +38,9 @@ class weabot(object): self.environ["PATH_INFO"] = self.environ["PATH_INFO"][11:] self.start = start_response - self.formdata = getFormData(self) + + if self.environ["QUERY_STRING"] != "rawpost": + self.formdata = getFormData(self) self.output = "" @@ -597,15 +599,23 @@ class weabot(object): # process files if oek_file: try: - fname = "%s/oek_temp/%s.png" % (Settings.HOME_DIR, oek_file) - with open(fname) as f: + fname = "%s/%s/temp/%s.png" % (Settings.IMAGES_DIR, board['dir'], oek_file) + with open(fname, 'rb') as f: file = f.read() - os.remove(fname) except: raise UserError, "Imposible leer la imagen oekaki." if file and not noimage: post = processImage(post, file, t, file_original, (spoil and board['allow_spoilers'] == '1')) + + if oek_file: + # Remove temporary oekaki file if everything went right + #os.remove(fname) + # TODO: We will rename the file for now. We don't want lost work. + try: + os.rename(fname, fname + ".bak") + except: + pass # Just keep it if anything went wrong # slip if board["slip"] != '0': -- cgit v1.2.1-18-gbd029