User avatar
KnightOfPi
Posts: 49
Joined: Sun Dec 28, 2014 12:57 pm
Location: Vienna - Austria
Contact: Website

Decorator for write access to protected files

Fri May 24, 2019 12:43 pm

Hi all!

I always had problems when i tried to automate installation routines for RPi applications when i tried to read and write protected fiels like wpa_supplicant.conf for automated network setup.
So, there might be better ways , but i wrote a Python decorator which gives functions access to all protected files.

If you think that's useful for your tasks, you can find it here:
http://www.knight-of-pi.org/decorator-f ... tem-files/

Happy Hacking!
Check out www.knight-of-pi.org for many beginner-friendly tutorials!

Andyroo
Posts: 3306
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Decorator for write access to protected files

Fri May 24, 2019 1:01 pm

Risky but handy :lol:

Next version - automatic backup of changed files?
Need Pi spray - these things are breeding in my house...

User avatar
scruss
Posts: 2257
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Decorator for write access to protected files

Fri May 24, 2019 2:31 pm

Handy indeed. Some system files won't work as expected if you chgrp/chmod them away from their standard values: I'm thinking particularly of the sudoers file. Caveat [whatever latin for 'user' is].
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Return to “Python”