maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   Can't write to file from a .desktop file (https://talk.maemo.org/showthread.php?t=48776)

flp 2010-03-30 19:22

Can't write to file from a .desktop file
 
I wrote a very simple python script that opens up a file and writes a single word to it:

#!/usr/bin/env python
log_dir = "/home/user/sleepclock/logs/"
log = open(log_dir + "test", "a")
log.write("HIPPOPOTAMUS")
log.close

If I run this script from the command line, there is a file called "test" in /home/user/sleepclock/logs that contains the single word "HIPPOPOTAMUS". However, when I try to run the python script from a .desktop file that contains the following lines:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=0.1
Encoding=UTF-8
Name=writetofile
Type=Application
Exec=/usr/bin/writetofile.py
X-Osso-Type=application/x-executable

There is no file called "test". The writetofile.py script is in the /usr/bin directory. Any ideas why this isn't working when I use a .desktop file?

flp 2010-03-31 22:56

Re: Can't write to file from a .desktop file
 
I'm still having troubles with this one. Anyone?

gobuki 2010-03-31 23:05

Re: Can't write to file from a .desktop file
 
Try a desktop file with these directives.

Code:

[Desktop Entry]
Name=recaller
Comment=A simple (call) recording widget.
Type=python
X-Path=recaller.py
X-Multiple=true


flp 2010-03-31 23:48

Re: Can't write to file from a .desktop file
 
When I do that nothing shows up under the extras tab at all.

flp 2010-04-05 23:16

Re: Can't write to file from a .desktop file
 
I've tried searching for a tutorial on desktop entries and come up with nada. Could someone point me towards one?

omeriko9 2010-04-05 23:28

Re: Can't write to file from a .desktop file
 
Quote:

Originally Posted by flp (Post 597016)
I've tried searching for a tutorial on desktop entries and come up with nada. Could someone point me towards one?

http://wiki.maemo.org/PyMaemo/Hildon...mantle_only.29

flp 2010-04-12 22:57

Re: Can't write to file from a .desktop file
 
The above tutorial was not useful because that code is for fremantle. When I tried running the example hello world application in diablo, no widget appeared.

I'm just looking for why my original code breaks when I run the script from a desktop script. I've run python code using similar desktop scripts, but for some reason I just can't write to a file using a desktop script.

Anyone have any ideas?

flp 2010-04-29 20:53

Re: Can't write to file from a .desktop file
 
Still having trouble with this one

flp 2010-05-20 19:12

Re: Can't write to file from a .desktop file
 
When i tried calling the desktop file from x-term (not in root shell) i get this error:

File "usr/bin/writetofile.py", line 5, in <module>
log = open(log_dir + "test", "a")
IOError: [Errno 13] Permission denied: '/home/user/sleepclock/logs/test'

Could this be the problem that's occurring when i try to run the script from the icon in the extras menu? And, if so, how do i fix it?

flp 2010-05-25 23:38

Re: Can't write to file from a .desktop file
 
still havin trouble with this. any help would be greatly appreciated!

maacruz 2010-06-02 21:45

Re: Can't write to file from a .desktop file
 
Quote:

Originally Posted by flp (Post 668235)
When i tried calling the desktop file from x-term (not in root shell) i get this error:

File "usr/bin/writetofile.py", line 5, in <module>
log = open(log_dir + "test", "a")
IOError: [Errno 13] Permission denied: '/home/user/sleepclock/logs/test'

Could this be the problem that's occurring when i try to run the script from the icon in the extras menu? And, if so, how do i fix it?

Probably a "test" file owned by root already exists, preventing your script form overwriting it when run as user.
Delete everything in the logs directory and try again.


All times are GMT. The time now is 17:02.

vBulletin® Version 3.8.8