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.

Where should I add source files for my program? I created a folder /data/src and put the files there. In my Python code I tried to point with os.getcwd() to it. This works for quickly run but if I install my application it gives me an IOEroor for home/username/myapp/data/src. How I can ajust the username?

Thanks

share|improve this question
    
what sort of "source files"? do you mean python code? –  fluteflute Jul 8 '12 at 20:10
    
No, just a text file which includes data. This data I need in the python code to create a dict and calculate something. –  snowflake Jul 8 '12 at 20:12
    
try $home instead –  Tachyons Oct 5 '12 at 15:02
add comment

2 Answers

up vote 1 down vote accepted

Even if you were able to get the os.getcwd() approach to work, it would probably break when you run the program installed. If you look in the program_name_lib directory, you'll see that quickly provides some convenience functions for you. The easiest way to do what you want is to put the text file in data/media and use the get_media_file() helper. Like so:

from program_name_lib.helpers import get_media_file
text_file = get_media_file("my_file.txt")
share|improve this answer
add comment

Without knowing details, it appears that it expects the directory data/src to be in you home directory, under your program name, and not in the root. Did you really put it in /data/src? Normally, I think it would go somewhere in your home directory, which you own and have full permissions. You can, of course, change this and put it where you want, but it's usually best not to put things in the root directory.

share|improve this answer
    
But the media files are also in the data folder. How quickly finds them? Or are they copied after installation to the home directory? Sorry, up to now I programmed only for windows. –  snowflake Jul 8 '12 at 20:18
1  
Sorry... I probably should just delete my post, as this is getting into too many details of your program and quickly that I don't know about. –  Marty Fried Jul 8 '12 at 21:23
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.