maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   How to packaging my script? (https://talk.maemo.org/showthread.php?t=61384)

maxximuscool 2010-08-30 08:32

How to packaging my script?
 
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--

==========

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?

maxximuscool 2010-08-30 08:55

Re: [URGEN] How to edit a file as ROOT in python Code?
 
Can anyone teach me?

maxximuscool 2010-08-30 09:41

Re: [URGEN] How to edit a file as ROOT in python Code?
 
Anyone know how to change the file permission for temporary via python?

maxximuscool 2010-08-30 10:59

Re: [URGEN] How to change file permission in python Code?
 
What is the equilvalent of Python to this Xterminal command?

root
chmod -R 666 path/to/file?

juise- 2010-08-30 11:10

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by maxximuscool (Post 802072)
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--

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:
Code:

import os
import stat

os.chmod('/your/file', stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)

(See the documentation of stat module for more info about the flags)

digitalvoid 2010-08-30 11:13

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by maxximuscool (Post 802153)
What is the equilvalent of Python to this Xterminal command?

root
chmod -R 666 path/to/file?

Code:

import os  # if not already done
os.system('chmod -R 666 path/to/file')


maxximuscool 2010-08-30 20:40

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by juise- (Post 802161)
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:
Code:

import os
import stat

os.chmod('/your/file', stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)

(See the documentation of stat module for more info about the flags)

Yes was a bit hurry, I'm testing my little plugin. And hoping to release it very soon to accomidating people who has the problem with their FM Transmitter.

By the way how do i be as root on my python script?

maxximuscool 2010-08-30 21:07

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by digitalvoid (Post 802164)
Code:

import os  # if not already done
os.system('chmod -R 666 path/to/file')


This script doesn't do anything because it doesn't have root access to do anything.

maxximuscool 2010-08-30 21:34

Re: [URGEN] How to change file permission in python Code?
 
IT WORKS!!! o.O A FLUKE!!

maxximuscool 2010-08-30 21:40

Re: [URGEN] How to change file permission in python Code?
 
Woohoo SUCESS!!! Now All I need to do is to packaging it. But how?
Any tutorial lol?

Is this the one?
http://wiki.maemo.org/PyMaemo/Scratc...ackaging_guide

rolan900d 2010-08-30 21:42

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by maxximuscool (Post 802679)
Woohoo SUCESS!!! Now All I need to do is to packaging it. But how?
Any tutorial lol?

In a hurry again???
ROFL

maxximuscool 2010-08-30 22:26

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by rolan900d (Post 802683)
In a hurry again???
ROFL

Lol I forgot to get rid of URGEN part.
Yeah I got the script working and I'm eager to share it with people here.

TorstenT 2010-08-30 22:59

Re: [URGEN] How to change file permission in python Code?
 
Quote:

Originally Posted by maxximuscool (Post 802711)
Yeah I got the script working and I'm eager to share it with people here.

The following code is just an example. You have to change the control files and the data contents. N900 uses standard debian packages. You can search google for deb build scripts.

On a Linux system (e.g. Ubuntu) you can type the following:

Code:

mkdir packagetest
cd packagetest

wget http://torsten-traenkner.de/wissen/n900/mplayer-touchcontrol_1.0_armel.deb

# extract debian package
ar xv mplayer-touchcontrol_1.0_armel.deb

# extract data and control parts
mkdir data
mkdir control
tar xzvf data.tar.gz -C data
tar xzvf control.tar.gz -C control

# modify the data
cd data

# compress the data
tar czvf ../data.tar.gz *

# create MD5 checksums
find . -type f ! -regex '.*/DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum | sort -k2 > ../control/md5sums

# compress control
cd ../control
tar czvf ../control.tar.gz *
cd ..

# create package
ar -r mplayer-touchcontrol_1.0_armel.deb debian-binary control.tar.gz data.tar.gz



All times are GMT. The time now is 09:52.

vBulletin® Version 3.8.8