OESF Portables Forum
Everything Else => Zaurus - Everything Development => Distros, Development, and Model Specific Forums => Archived Forums => Python => Topic started by: jeffbarish on April 08, 2005, 10:02:05 pm
-
I found some information here about how to install an application in Qtopia, but I can't get it to work. It's possible that I misinterpreted some of the directions that I found, so I thought that perhaps someone could point to my error if I carefully describe what I did.
1. I put my app (myapp.py) in /home/QtPalmtop/bin (which is in my path).
2. I made myapp.py executable. The first line is
#! /usr/bin/env python
The line that calls QPEApplication is:
app = QPEApplication(['myapp.py'])
I do:
from qtpe import QPEApplication
3. I created a file in /home/QtPalmtop/apps/Applications called myapp.desktop. It contains the lines
[Desktop Entry]
Comment=What my program does
Exec=myapp.py
Type=Application
Name=MyApp
4. I rebooted
An icon appears on the Applications page. When I click on it, it changes to the clicked icon and I see an hourglass. Then the hourglass disappears and my app does not run. I presume that it crashed. When I run it from a command prompt (by typing myapp.py), it runs fine. I hope that someone can see what I did wrong -- or can at least suggest a diagnostic procedure. For example, does Qtopia log error messages somewhere? Is there a way to capture error messages emitted during program startup? Thanks.
-
I made some progress.
I use a module (Pyro) with the readonly kopsis image by installing it according to the procedure described by optogeek (69777 (https://www.oesf.org/forums/index.php?showtopic=10825&view=findpost&p=69777)). As I said, the installation works fine when I run my program from a command prompt. However, when I try to run the program from the icon, Qt/Embedded apparently tries to run it as root. I know that Qt/Embedded is trying to run my program as root because the PYTHONPATH as root was wrong. I put the module in /home/zaurus/lib/Python, but because the environment variable got set using $HOME/lib/python, when running as root, Python was looking in /home/root/lib/python. After I hardwired PYTHONPATH to the correct directory in the .bashrc for root, I no longer got an error message about not finding the module.
HOWEVER, I now get the error message:
Qt/Embedded data directory is not owned by user 0
So, I still can't run the program from a command prompt as root (which is not something I want to do anyway), and the program still will not start from the icon. I've been trying to figure out why the program is running as root, but I'm stumped. I know how to get to a properties page by clicking on the icon and holding the button down for a few seconds. On the page that appears, one is able to select whether the program should run as root. That box is not checked (although it doesn't make any difference as far as this problem is concerned). The permissions and ownership on the file I put in /home/QtPalmtop/bin are the same as for other programs in that directory. Likewise for the file I put in /home/QtPalmtop/apps/Applications.
-
I just checked the script for my app in /home/QtPalmtop/bin and it only has one line:
python /mnt/card/dev/myapp.py
(/mnt/card/dev is where i do my work and store my program).
I think I ran into this same problem and got it to work this way, which gets around the permissions problem.
Jeff
-
OK. In case anyone is interested, here's the explanation for my problem. My program uses Pyro, so I have several import statements related to Pyro. I installed Pyro in /home/zaurus/lib/python and set the environment variable PYTHONPATH to /home/zaurus/lib/python. When I run the program from the command prompt, all is good. When I run it from an icon, python cannot find Pyro. Why? I modified my program to print out sys.path. /home/zaurus/lib/python is not in it (although it is when I run the program from the command prompt). The first line of my program is the usual (#! /usr/bin/env python), so it should be picking up the same environment that exists when I run from a command prompt. I modified the line to explicitly set PYTHONPATH (#! /usr/bin/env PYTHONPATH=/home/zuarus/lib/python python), but the directory still is not in my path. I modified the program with sys.path.append('/home/zaurus/lib/python'). Then the program will run from the icon.
Even better: following the suggestion from geojeff, I put a simple shell script in /home/QtPalmtop/bin. It contains the single line
/usr/bin/env PYTHONPATH=/home/zaurus/lib/python python /home/zaurus/bin/myprog.py
It is necessary to explicitly set PYTHONPATH.
Debugging tips: You can append to this line "> /home/zaurus/log 2>&1" to capture output in a file. This is the technique I used to figure out this problem. Also, I'm pretty sure that when you make a change to your file in /home/QtPalmtop/apps/Applications, you need to reboot.
-
Thanks for those tips !
I was having the same problem with Treeline (see thread in the Software forum) running from the console but not from the icon, and this helped solve it.
BTW, had you tried putting the script name directly in the Exec= statement of the app's .desktop file ? That's what the trivial "PyQt example" does, and I find it works just as well for Treeline, which is quite sophisticated and imports lots of stuff...
-
I expected to be able to do what you described. To be precise, I put the name of the script in the Exec= line, and I put the script in /home/QtPalmtop/bin. However, when I tested this configuration from the command prompt, it would freeze, and from the icon it would fail. I did some more testing this morning and figured out that the problem arises when I specify the environment variable. That is, the program will run (from the command line) when the first line is:
#! /usr/bin/env python
but not when it is:
#! /usr/bin/env PYTHONPATH=/home/zaurus/lib/python python
For now, I will stick with the solution that works for me, but I would still be interested in any insights into what is going wrong here.
There is still an advantage to the configuration that I described (geojeff did, actually) in that one can specify redirection using that technique to capture output from your script.