Closed vfrdirk closed 4 years ago
I'm not sure if it's a problem with the way I'm installing and launching, since I was on Python 2.7 before. I used pip3 and python3 to install requirements and launch the server. And, it was running normally and allowed me to try to upload the file.
@vfrdirk Thanks for testing. Looks like the reciper parser is still not robust enough to handle all the different versions out there ;-) Do you mind sharing the recipe file again?
It worked for me. I'm able to launch and upload recipes. Now I am struggling to get the spoofing to work correctly on mac. I'll play around or try a hardware solution and update.
Is that the identical recipe you posted in the other issue thread? I'll grab that and test again.
Well I came back to try try and sort out the DNS spoofing and found that I am now getting the same error you are posting above. I tried reinstalling the app and requirements.
` * Serving Flask app "server" (lazy loading)
@fotoapparat Nice! Regarding the spoofing, I would love to find an easier solution. Open for suggestions.
OK, the recipe that @fotoapparat shared is failing to upload for me, so I wiped everything and re-cloned the repo, checked out 'py3' branch and started the server. I'm getting syntax errors starting with this:
except Exception as e: logger.error(f"Failed to parse recipe {filename}. {e}") return []
There were several more errors of this exact type, an errant f, which wouldn't pass server startup. Am I the only one? Or is this a structure in P3 and I've got a missing dependency?
@vfrdirk What version of Python 3 are you using? Looks like it may be outdated. The error might be because your Python interpreter can't parse the "f-String" syntax used in the example above (https://docs.python.org/3/reference/lexical_analysis.html#f-strings).
You need at least Python 3.6 or above.
I made some more changes and fixes. I also improved type checking, lintint and setup automated CI testing here on GitHub with GitHub actions.
I have been able to import the OBK Belgian Table Ale recipe now:
I wanted to say thanks for the time and effort you're putting into this.
I'm getting a similar error as yesterday. I've tried on two computers running OSX. Are you on linux? Not that is should matter, but it might. Also, the file isn't uploading/copying to the folder anymore.
127.0.0.1 - - [19/Apr/2020 15:07:32] "POST /upload HTTP/1.1" 500 - 127.0.0.1 - - [19/Apr/2020 15:13:03] "GET / HTTP/1.1" 200 - [2020-04-19 15:13:11,548] ERROR in app: Exception on /upload [POST] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/Applications/picobrew-server-py3/blueprints/frontend.py", line 60, in upload_recipe file.save(filename) File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 3066, in save dst = open(dst, "wb") FileNotFoundError: [Errno 2] No such file or directory: 'recipes/OBK_Belgian_Table_recipe_xml.xml'
So I was able to install tonight on a Linux machine without issue. Server was stable and able upload recipes. Next to try hooking the Zymatic up and seeing if it will interface. Will continue to update as I play around.
@vfrdirk What version of Python 3 are you using? Looks like it may be outdated. The error might be because your Python interpreter can't parse the "f-String" syntax used in the example above (https://docs.python.org/3/reference/lexical_analysis.html#f-strings).
You need at least Python 3.6 or above.
You were correct. The version I had running in the Windows Ubuntu subsystem was 3.5.2. I installed the latest version under Windows and the server is parsing everything correctly and I was also able to upload the Belgian recipe successfully. I also uploaded some others with success. This thing is great!
I wanted to say thanks for the time and effort you're putting into this.
I'm getting a similar error as yesterday. I've tried on two computers running OSX. Are you on linux? Not that is should matter, but it might. Also, the file isn't uploading/copying to the folder anymore.
127.0.0.1 - - [19/Apr/2020 15:07:32] "POST /upload HTTP/1.1" 500 - 127.0.0.1 - - [19/Apr/2020 15:13:03] "GET / HTTP/1.1" 200 - [2020-04-19 15:13:11,548] ERROR in app: Exception on /upload [POST] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/Applications/picobrew-server-py3/blueprints/frontend.py", line 60, in upload_recipe file.save(filename) File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 3066, in save dst = open(dst, "wb") FileNotFoundError: [Errno 2] No such file or directory: 'recipes/OBK_Belgian_Table_recipe_xml.xml'
No, I am on OSX. I am assuming the directory <picobrew_server>/recipes
is not available. :-/ The server should be more defensive here and check/create it to be on the save side. Let me fix this.
@fotoapparat I pushed the fix.
I also uploaded some others with success.
@vfrdirk Please share some of the recipe, which were not able to parse correctly, if don't mind. Right now, the project only support recipes downloaded from the official PicoBrew.com recipe builder, since they use some non-standard tags in their recipes to save the heating/timing schedule for the machine.
Perhaps, I might look into extracting this schedule from more standard BeerXML-formatted recipe if possible. But let's get the update to Python 3 going first.
I don't know if it's necessary. Most of the ones that failed to upload were ones I had meddled with to try and inject the \<PROGRAM> tags into, since that was the original file layout the server was expecting. The ones I downloaded from Pico recently have all uploaded successfully on the new branch containing the \<ZYMATIC> tagging.
I wanted to say thanks for the time and effort you're putting into this. I'm getting a similar error as yesterday. I've tried on two computers running OSX. Are you on linux? Not that is should matter, but it might. Also, the file isn't uploading/copying to the folder anymore. 127.0.0.1 - - [19/Apr/2020 15:07:32] "POST /upload HTTP/1.1" 500 - 127.0.0.1 - - [19/Apr/2020 15:13:03] "GET / HTTP/1.1" 200 - [2020-04-19 15:13:11,548] ERROR in app: Exception on /upload [POST] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/Applications/picobrew-server-py3/blueprints/frontend.py", line 60, in upload_recipe file.save(filename) File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py", line 3066, in save dst = open(dst, "wb") FileNotFoundError: [Errno 2] No such file or directory: 'recipes/OBK_Belgian_Table_recipe_xml.xml'
No, I am on OSX. I am assuming the directory
<picobrew_server>/recipes
is not available. :-/ The server should be more defensive here and check/create it to be on the save side. Let me fix this.@fotoapparat I pushed the fix.
Hey,
I did a fresh install on OSX and loaded the updated version. Every has worked well. Uploaded recipe and showing in Library. Now on to hooking up my Zymatic.
Alright, thanks again for the feedback. I will merge the current version to master now. if you come across any further bugs, don't hesitate to open a new issue.
This was the trace I got when trying to upload a valid-ish XML recipe file.
Traceback (most recent call last): File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/dirk/.local/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(args, kwargs))) File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/dirk/.local/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/home/dirk/picobrew-server/blueprints/frontend.py", line 55, in uploadRecipe file.save(filename) File "/home/dirk/.local/lib/python3.5/site-packages/werkzeug/datastructures.py", line 3070, in save copyfileobj(self.stream, dst, buffer_size) File "/usr/lib/python3.5/shutil.py", line 76, in copyfileobj fdst.write(buf) AttributeError: 'PosixPath' object has no attribute 'write' 127.0.0.1 - - [17/Apr/2020 17:07:15] "POST /upload HTTP/1.1" 500 - [2020-04-17 17:07:17,447] ERROR in app: Exception on /recipes [GET] Traceback (most recent call last): File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/dirk/.local/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(args, kwargs))) File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/dirk/.local/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/dirk/.local/lib/python3.5/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/home/dirk/picobrew-server/blueprints/frontend.py", line 25, in recipes return render_template("recipes.html", recipes=get_recipes()) File "/home/dirk/picobrew-server/blueprints/frontend.py", line 32, in get_recipes recipes = reduce(lambda x,y: x+y, recipes) # flatten TypeError: reduce() of empty sequence with no initial value 127.0.0.1 - - [17/Apr/2020 17:07:17] "GET /recipes HTTP/1.1" 500 - 127.0.0.1 - - [17/Apr/2020 17:09:04] "GET /favicon.ico HTTP/1.1" 404 -