Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using quickly ide and I am having trouble with filepath. Where to put additional files required by application? When I put additional files in /data/ folder after application is installed what will be new path? Is it stored in /opt/extras.ubuntu.com/projectName/share or in /usr/share/ ? According to app showdown rules it must be in opt.

Application will need root permission to write in its files? How to access file paths inside python code?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

I was wondering the best way to do this in the past, and looking at the example on http://developer.ubuntu.com for the media player (link seems to be dead these days), they use the helpers module that is there by default when using quickly.

from <appname>_lib import helpers

def get_path(self):
    file_path = helpers.get_media_file("filename.ext")
    file_path = file_path.replace("file:///", "")
    return file_path

If you take a look at the actual helpers code, this just looks in the media folder, from within the data folder.

This returns the file path prefixed with "file:///" which is not always accepted, hence the removal above.

share|improve this answer
add comment

When you want to write file paths, you have to write them in a relative way. So in Glade you have to write

../media/icon.png

With the two dots (.) you go back into the /data folder. Then you say to go into /media and open icon.png. You have to do so because the Glade .ui files are stored in /projectname/data/ui/ - from here you have to go back by 1 and then into the /media folder.

When writing the .desktop.in file (the desktop/application entry) for example for including the icon, you have to write it like this:

./data/media/icon.png

Take care to write only one point.

Oh, what I forgot: The application does not need root access to write into files and quickly does all important packaging (the thing with /opt/) automatically. You do not have to take care of /opt/.

I hope I could help you with your questions.

PS: Note that the Ubuntu App Developer Showdown is over!

share|improve this answer
    
Just to add one more thing. When the command quickly share is used then files are stored in /usr/share/. When you use quickly submitubuntu then files are stored in /opt/extras.ubuntu.com/projectName/share –  user26030 Jul 14 '12 at 20:19
add comment

I think the function get_data_path() in [appname]_lib/[appname]config.py is set up to do exactly this. So in Python, import that function at the beginning of your file:

from [appname]_lib.[appname]config.py import get_data_path

Then when you want to use a file in your data directory you can get its path like this:

data_path = get_data_path()
filepath = os.path.join(data_path, 'mydatafile.css')
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.