![]() |
2010-08-30
, 08:55
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#2
|
![]() |
2010-08-30
, 09:41
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#3
|
![]() |
2010-08-30
, 10:59
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#4
|
![]() |
2010-08-30
, 11:10
|
|
Posts: 186 |
Thanked: 192 times |
Joined on Jan 2010
@ Finland
|
#5
|
My python code is at:
/usr/lib/hildon-desktop
Location of my shortcut:
/usr/share/applications/hildon-status-menu/
How do i edit a file as root inside python code?
The file I want to change is class as "root" rw-r--r--
import os import stat os.chmod('/your/file', stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
The Following User Says Thank You to juise- For This Useful Post: | ||
![]() |
2010-08-30
, 11:13
|
Posts: 200 |
Thanked: 300 times |
Joined on Nov 2009
@ The Netherlands
|
#6
|
What is the equilvalent of Python to this Xterminal command?
root
chmod -R 666 path/to/file?
import os # if not already done os.system('chmod -R 666 path/to/file')
The Following 2 Users Say Thank You to digitalvoid For This Useful Post: | ||
![]() |
2010-08-30
, 20:40
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#7
|
In a hurry, are you?
First of all, to change permissions on file owned by root, your code needs to be root.
Second, the methods you are looking for are os.chown() (for changing owner, if you need to) and os.chmod() (for changing permissions). The library reference is your friend:
http://docs.python.org/library/os.html
So, to change the permission:
(See the documentation of stat module for more info about the flags)Code:import os import stat os.chmod('/your/file', stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
![]() |
2010-08-30
, 21:07
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#8
|
Code:import os # if not already done os.system('chmod -R 666 path/to/file')
![]() |
2010-08-30
, 21:34
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#9
|
![]() |
2010-08-30
, 21:40
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#10
|
/usr/lib/hildon-desktop
Location of my shortcut:
/usr/share/applications/hildon-status-menu/
How do i edit a file as root inside python code?
The file I want to change is class as "root" rw-r--r--
==========
As above I'm writing a small plugin and wanted to know how to do the packaging. Can someone link me to the handy tutorial?
Install Preenv games into eMMC| Click Here to get rid of Uboot screen
My N900 running at 250-1150Mhz
Unlocking your FM-transmitter to 76.0Mhz - 107.9Mhz range - CLICK HERE.
Last edited by maxximuscool; 2010-08-30 at 22:25.