New Installation on Windows - Issue with Brewpi.py

I found the thread Windows Brew Pi(Spark) Install Instructions and see that @Elco uses (or used) Windows so I am hoping this is a silly issue I am overlooking.

I installed WAMP and Python. I have replicated the various GIT repositories to:

  • C:\WAMP\WWW\BrewPi\brewpi-script
  • C:\WAMP\WWW\BrewPi\brewpi-tools
  • C:\WAMP\WWW\BrewPi\brewpi-www

I created and edited:

  • C:\WAMP\www\brewpi\brewpi-script\settings\config.cfg
  • C:\WAMP\www\brewpi\brewpi-www\config_user.php

Presently, the config.cfg contains:

arduinoHome = C:/Program Files (x86)/Arduino/
avrdudeHome = C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/
avrsizeHome = C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/
avrConf = C:/Program Files (x86)/Arduino/hardware/tools/avr/etc/avrdude.conf

wwwPath = C:/WAMP/www/brewpi/brewpi-www/
port = COM30

I tried to start the script using the command line:

python brewpi.py --config "C:\WAMP\www\brewpi\brewpi-script\settings\config.cfg"

I receive the following error:

  File "brewpi.py", line 250
    os.chmod(dataPath, 0775)  # give group all permissions
                          ^
SyntaxError: invalid token

I am hoping/assuming I missed something simple here since the script seems to not like the 0775 (that’s what the caret is pointing to, not sure how the formatting will translate here) and there’s no chmod in Windows.

Anyone care to point out what silly thing I may have missed?

The spark doesn’t need any of the configs within that file as they’re all for the legacy Arduino version.

To run the script you simply need to run the below command in the brewpi-script folder. (mine is in the brewpi-www folder )

python brewpi.py

You should be able to hit the site if the WAMP sever is set up correctly regardless if the script is running. The script simply starts the connection to spark which is then talked to via a PHP websocket via the UI.

The line that’s erroring is trying to set os permissions for the python script to read/write.

I do have an Arduino actually, and an ESP8266 that works on my RPi setup. I’m just trying to get to the point where the script will run and toss me errors complaining about not finding the Arduino (or the other device) so I can work on that part.

I’m familiar with what chmod does, I’m curious why it is trying to do it on Windows - especially if others have had success running this on Windows. I can comment all of the lines where it does the chmod function but I did not see where anyone else had done that.

WAMP is working, I can hit the web page fine. It’s just getting the script running to the point where it will look for the Arduino where my issue lies.

Mine is running on windows, but on a true end to end windows IIS set up, not with WAMP. So I set up custom permission for the IIS user, then simply dropped the python script in the brewpi-www folder. I didn’t care about any of the “tools” working as it’s just as easy to pull from a repo myself.

The folder it’s trying to give permissions to is the beer data folder for the logging. Where is your brewpi.py folder located and how are you running the command?

Right now it doesn’t really matter that I have WAMP - I’m not using that part yet. I am also not using the tools, I pulled from GitHub manually.

The brewpi.py folder is in C:\WAMP\www\brewpi\brewpi-script and I tried to execute the script as I posted above, and simply by executing ‘python brewpi.py’.

I did a little more digging … is there a version of Python I should be using? I have Python 3.6.0a3 installed. The os.chmod method syntax is different for 2.6 and 3+ apparently, requiring 0o755 instead of 755. If I change lines 250, 253, 401 to use that syntax I am next presented with the error:

  File "brewpi.py", line 776
    except KeyError, e:
                   ^
SyntaxError: invalid syntax

When I dig that up I see that exceptions must be written as ‘except KeyError as e:’ instead of ‘except KeyError, e:’. I make a few more edits and now I get an error more like what I expected:

Traceback (most recent call last):
  File "brewpi.py", line 21, in <module>
    from BrewPiUtil import printStdErr
  File "C:\WAMP\www\brewpi\brewpi-script\BrewPiUtil.py", line 21, in <module>
    import serial
ImportError: No module named 'serial'

So apparently I am missing modules too?

Questions:

  1. What version of Python should I be using
  2. How do I add modules (and which ones)?

I tried the obvious:

>python -m pip install serial
Collecting serial
  Could not find a version that satisfies the requirement serial (from versions: )
No matching distribution found for serial
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

… pretty sure I am headed down the wrong path here.

http://docs.brewpi.com/manual-brewpi-install/python-setup.html

Aha!

Okay I have Python 2.7 installed now, with PIP plus all of those listed on that page except for python-git which does not seem to be available via PIP strangely. I guess I won’t need it if I don’t use the scripts to update.

Thanks for pointing out that page. I knew I couldn’t be too far off the reservation but I was not able to find that page originally.

After getting the correct version of Python, the proper modules (I wonder if I could have done this with Python 3 and the changes I made?) and remembering I needed Legacy branch … things are working. The only remaining issue is I can;t seem to start a new brew.