Closed jprucks closed 5 years ago
I ran into a similar problem with getting a permission error on the .json
files. The solution for me was to double check that there are read/write permissions on both of those files. You can try running ls -l currentweather.json
to double check there is a rw
flag enabled.
Other than that I did make some changes to the way info is written to those files prior to the 1.0.0 release version so I can let my clock run for a few days and see if I can reproduce the problem. If you want to take a look that code lives in apicaller.py
.
EDIT #2: I don't know what I'm talking about, but either way, here's a larger block of code. Doubt it'll help much.
Thanks for the reply! Flag appears to be enabled, consistent crashes after the first call now. I realized the error messages originate a little different each time, and if it matters, I did exceed the API call limit the first day. However, I have only made a couple calls each day since then, so I don't believe that's the issue. Here's the full block of code, beginning after I started the program for the first time with the text placed where I wanted it:
09/05/19 19:07:00 : Maxed out API calls to AccuWeather. Attempting to use cached current weather data...
09/05/19 19:07:00 : Maxed out API calls to AccuWeather. Attempting to use cached forecast data...
09/05/19 20:07:00 : Generating current weather data from AccuWeather...
Traceback (most recent call last):
File "./PiClock.py", line 283, in <module>
if (not piClock.process()):
File "/home/pi/PiClock/appbase.py", line 68, in process
self.run()
File "./PiClock.py", line 198, in run
self.getData()
File "./PiClock.py", line 28, in getData
self.caller.getAndParse()
File "/home/pi/PiClock/apicaller.py", line 16, in getAndParse
self.getData()
File "/home/pi/PiClock/apicaller.py", line 33, in getData
with open('currentweather.json', 'w') as f:
PermissionError: [Errno 13] Permission denied: 'currentweather.json'
pi@raspberrypi_matrix:~/PiClock $ sudo python3 ./PiClock.py --led-rows=64 --led-cols=64 --led-chain=2
09/05/19 22:31:28 : Generating current weather data from AccuWeather...
09/05/19 22:31:28 : Generating forecast data from AccuWeather...
Press CTRL-C to stop execution
09/05/19 23:31:28 : Generating current weather data from AccuWeather...
Traceback (most recent call last):
File "./PiClock.py", line 283, in <module>
if (not piClock.process()):
File "/home/pi/PiClock/appbase.py", line 68, in process
self.run()
File "./PiClock.py", line 198, in run
self.getData()
File "./PiClock.py", line 28, in getData
self.caller.getAndParse()
File "/home/pi/PiClock/apicaller.py", line 16, in getAndParse
self.getData()
File "/home/pi/PiClock/apicaller.py", line 33, in getData
with open('currentweather.json', 'w') as f:
PermissionError: [Errno 13] Permission denied: 'currentweather.json'
pi@raspberrypi_matrix:~/PiClock $ sudo python3 ./PiClock.py --led-rows=64 --led-cols=64 --led-chain=2
09/06/19 12:58:24 : Generating current weather data from AccuWeather...
09/06/19 12:58:24 : Generating forecast data from AccuWeather...
Press CTRL-C to stop execution
09/06/19 13:58:24 : Generating current weather data from AccuWeather...
Traceback (most recent call last):
File "./PiClock.py", line 283, in <module>
if (not piClock.process()):
File "/home/pi/PiClock/appbase.py", line 68, in process
self.run()
File "./PiClock.py", line 198, in run
self.getData()
File "./PiClock.py", line 28, in getData
self.caller.getAndParse()
File "/home/pi/PiClock/apicaller.py", line 16, in getAndParse
self.getData()
File "/home/pi/PiClock/apicaller.py", line 33, in getData
with open('currentweather.json', 'w') as f:
PermissionError: [Errno 13] Permission denied: 'currentweather.json'
pi@raspberrypi_matrix:~/PiClock $ sudo python3 ./PiClock.py --led-rows=64 --led-cols=64 --led-chain=2
09/06/19 23:50:10 : Generating current weather data from AccuWeather...
09/06/19 23:50:10 : Generating forecast data from AccuWeather...
Press CTRL-C to stop execution
09/07/19 00:50:10 : Generating current weather data from AccuWeather...
Traceback (most recent call last):
File "./PiClock.py", line 283, in <module>
if (not piClock.process()):
File "/home/pi/PiClock/appbase.py", line 68, in process
self.run()
File "./PiClock.py", line 198, in run
self.getData()
File "./PiClock.py", line 28, in getData
self.caller.getAndParse()
File "/home/pi/PiClock/apicaller.py", line 16, in getAndParse
self.getData()
File "/home/pi/PiClock/apicaller.py", line 33, in getData
with open('currentweather.json', 'w') as f:
PermissionError: [Errno 13] Permission denied: 'currentweather.json'
pi@raspberrypi_matrix:~/PiClock $ sudo python3 ./PiClock.py --led-rows=64 --led-cols=64 --led-chain=2
09/08/19 01:32:00 : Generating current weather data from AccuWeather...
09/08/19 01:32:00 : Generating forecast data from AccuWeather...
Press CTRL-C to stop execution
09/08/19 02:32:00 : Generating current weather data from AccuWeather...
Traceback (most recent call last):
File "./PiClock.py", line 283, in <module>
if (not piClock.process()):
File "/home/pi/PiClock/appbase.py", line 68, in process
self.run()
File "./PiClock.py", line 198, in run
self.getData()
File "./PiClock.py", line 28, in getData
self.caller.getAndParse()
File "/home/pi/PiClock/apicaller.py", line 16, in getAndParse
self.getData()
File "/home/pi/PiClock/apicaller.py", line 33, in getData
with open('currentweather.json', 'w') as f:
PermissionError: [Errno 13] Permission denied: 'currentweather.json'
pi@raspberrypi_matrix:~/PiClock $ ls -l currentweather.json
-rw-r--r-- 1 pi pi 4469 Sep 8 01:32 currentweather.json
pi@raspberrypi_matrix:~/PiClock $ ls -l apicaller.py
-rw-r--r-- 1 pi pi 2541 Sep 4 16:02 apicaller.py
pi@raspberrypi_matrix:~/PiClock $
So, this is over my head. I'm hoping that I can get all of this working, and figure out how to implement the DarkSky API, because the calls aren't limited as tightly and they offer good near-term forecast data for precip (the hourly forecast graph would look cool on a matrix as well).
Try chmod 777 currentweather.json
. Do the same for forecast.json
.
It needs full read/write permissions since it's not being run directly by the user.
That appears to have fixed it. Thank you for your patience, I understand now!
Hello! Thanks again, your code has been really helpful, being able to see how you accomplished this. Aside from the issue I had on first install (the utility program doesn't seem to create location.py), I've noticed that it crashes after a random length of time. Here is the terminal output:
Now, it's possible I have screwed something up, but I don't think so. All I have done is adjust the position of the text to fit a chain of two Adafruit 64x64 matrix panels. Running the command again brings it back up like normal. Additionally, it doesn't always crash after one call to the API.