diff options
author | z411 | 2019-04-01 04:28:52 -0300 |
---|---|---|
committer | z411 | 2019-04-01 04:29:56 -0300 |
commit | ff6bf1b045fa810989a3efc78624123d3fc97f19 (patch) | |
tree | 13f949851ef0bc1d85b1fa5370c484002d5bdfdb /cgi/weabot.py | |
parent | 85790a8a070a9bb4e024beef4fd49c842c7e07d8 (diff) | |
download | weabot-ff6bf1b045fa810989a3efc78624123d3fc97f19.tar.gz weabot-ff6bf1b045fa810989a3efc78624123d3fc97f19.tar.xz weabot-ff6bf1b045fa810989a3efc78624123d3fc97f19.zip |
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
Diffstat (limited to 'cgi/weabot.py')
-rwxr-xr-x | cgi/weabot.py | 18 |
1 files changed, 14 insertions, 4 deletions
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': |