I want to change the created file to an owner other than root.
http://stackoverflow.com/questions/25791311/creating-a-file-with-python-using-sudo-makes-its-owner-root
chOwn1.py
import os
os.chown("path/to/file", uid, gid)
chOwn2.py
import os
uid = int(os.environ.get('SUDO_UID'))
gid = int(os.environ.get('SUDO_GID'))
os.chown("path/to/file", uid, gid)
It is unconfirmed how the SUDO_UID and SUDO_GID parts correspond to the user pi.
https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=73924 Maybe I should check / etc / passwd.
Recommended Posts