Conversation
castilma
left a comment
There was a problem hiding this comment.
If you are unhappy with some changes, or want more, tell me.
|
|
||
| for i in range(1, 3): | ||
| tries = 2 | ||
| for i in range(1, tries + 1): |
There was a problem hiding this comment.
The comment in line 31 says read_retry() is being used, but read() is used. And we're only trying 2 times.
| if humidity is not None and temperatureDHT is not None: | ||
| return humidity, temperatureDHT | ||
| sleep(2) | ||
| print('{}. DHT Measurement failed. Starting next try'.format(i)) |
There was a problem hiding this comment.
This prints [...] Starting next try even after the last try.
| if i != tries else '')) | ||
| except ValueError: | ||
| print('Sensor not found') | ||
| break |
There was a problem hiding this comment.
When there is no sensor, there is no reason to retry, right?
| # Note that sometimes you won't get a reading and | ||
| # the results will be null (because Linux can't | ||
| # guarantee the timing of calls to read the sensor). | ||
| # If this happens try again! |
There was a problem hiding this comment.
This is a copy of lines 36-39.
| print('Error creating folder: ' + str(e) ) # errno 17= File existed | ||
| else: | ||
| pass | ||
| print('Folder created') |
There was a problem hiding this comment.
Only print the message if makedirs() succeded. Otherwise we didn't create the folder.
| @@ -137,16 +135,16 @@ def logging(): | |||
| print(folderName) | |||
| try: | |||
| os.makedirs(folderName, mode=0o777) | |||
There was a problem hiding this comment.
Really mode 0o777? How about at most 0o775?
| if e.errno != 17: | ||
| print('Error creating folder: ' + str(e) ) # errno 17= File existed | ||
| else: | ||
| pass |
There was a problem hiding this comment.
Maybe this is a good situation to abort? But maybe not. I don't know.
I found some minor things. See the review for details.