Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor issues #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Minor issues #2

wants to merge 1 commit into from

Conversation

castilma
Copy link

I found some minor things. See the review for details.

Copy link
Author

@castilma castilma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are unhappy with some changes, or want more, tell me.

@@ -38,25 +38,23 @@ def get_DHT11_data():
# guarantee the timing of calls to read the sensor).
# If this happens try again!

for i in range(1, 3):
tries = 2
for i in range(1, tries + 1):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in line 31 says read_retry() is being used, but read() is used. And we're only trying 2 times.

print('started')
try:
humidity, temperatureDHT = Adafruit_DHT.read(
Adafruit_DHT.DHT11, 17)
if humidity is not None and temperatureDHT is not None:
return humidity, temperatureDHT
sleep(2)
print('{}. DHT Measurement failed. Starting next try'.format(i))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prints [...] Starting next try even after the last try.

except ValueError:
print('Sensor not found')
break
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy of lines 36-39.

print('Error creating folder: ' + str(e) ) # errno 17= File existed
else:
pass
print('Folder created')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really mode 0o777? How about at most 0o775?

if e.errno != 17:
print('Error creating folder: ' + str(e) ) # errno 17= File existed
else:
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a good situation to abort? But maybe not. I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant