timofurrer / w1thermsensor

A Python package and CLI tool to work with w1 temperature sensors like DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other devices.
MIT License
493 stars 113 forks source link

w1thermsensor get -p 12 needs to be root #40

Closed klint-k closed 6 years ago

klint-k commented 6 years ago

/bin/sh: 1: cannot create /sys/bus/w1/devices/28-0316b56fb3ff/w1_slave: Permission denied Traceback (most recent call last): File "/usr/bin/w1thermsensor", line 9, in load_entry_point('w1thermsensor==1.0.3', 'console_scripts', 'w1thermsensor')() File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke return callback(args, **kwargs) File "/usr/lib/python3/dist-packages/w1thermsensor/cli.py", line 145, in get sensor.set_precision(precision, persist=False) File "/usr/lib/python3/dist-packages/w1thermsensor/core.py", line 280, in set_precision raise W1ThermSensorError("Failed to change resolution to {0} bit".format(precision)) w1thermsensor.errors.W1ThermSensorError: Failed to change resolution to 12 bit

timofurrer commented 6 years ago

Yes, it does need root permissions. Running the command with sudo should work perfectly on a standard raspbian.

Did you try?

klint-k commented 6 years ago

Hello,

Yes I tried.

This python script is past what I know, is there an error catch that will remind me to use sudo?

Klint

From: Timo Furrer [mailto:notifications@github.com] Sent: September 1, 2017 12:40 AM To: timofurrer/w1thermsensor w1thermsensor@noreply.github.com Cc: Klint Krossa klint-k@telus.net; Author author@noreply.github.com Subject: Re: [timofurrer/w1thermsensor] w1thermsensor get -p 12 needs to be root (#40)

Yes, it does need root permissions. Running the command with sudo should work perfectly on a standard raspbian.

Did you try?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/timofurrer/w1thermsensor/issues/40#issuecomment-326502747 , or mute the thread https://github.com/notifications/unsubscribe-auth/AHxR59uObRSjKTFNsr-61spri5weGVHFks5sd6bSgaJpZM4PJojG . https://github.com/notifications/beacon/AHxR53rd8UxhTCD5hKbFsAny6tdg6MSXks5sd6bSgaJpZM4PJojG.gif

timofurrer commented 6 years ago

The doc string of the W1ThermSensor.set_precision method already noted, that you might have to be root to change the precision.

In addition I've added a hint to the exception message and released v1.0.5.

Thanks :beers:

klint-k commented 6 years ago

Thanks for your help :) I hope that I helped. Klint