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 planning to package FBuntu into PPA for easier distribution.

The nature of this app is that the user has to make specific edits to the auth.py file to make it work and hence I am stuck from proceeding any further.

A default first couple of lines of auth.py looks like this:

import facebook

class facebookAuthentication:
    def __init__(self):
        url = "https://..."
        self.parse_url(url)

The user after branching FBuntu from the bazaar, has to manually edit the url with the one you get after authenticating with Facebook. I have no idea on how to make an app be edited after a deb package has been generated.

Any guidance on how to proceed with packaging this would be welcome.

share|improve this question
2  
+1 ... for those not familiar with fbuntu (me!) can you give examples of what you need to edit in auth.py? It sounds like auth.py should be reading from config files not hard-coding stuff. –  fossfreedom May 26 '12 at 8:46
    
@fossfreedom well yes, I want it to read things from a config file instead of being hard coded because it is a very user specific url. –  jokerdino May 26 '12 at 8:53
2  
Just a note, I'm working on a full-on packaging tutorial to address this –  hbdgaf May 26 '12 at 10:01
    
As the guy who wrote FBuntu, I'm well aware it isn't very user friendly, and would love to make it distributable via a PPA. I think I ought to take on some advice from the answers to this question! –  8128 May 28 '12 at 14:46
    
@fluteflute uh, didn't expect you to read this question. I thought I would finish the work and then contact you.. –  jokerdino May 28 '12 at 14:58

2 Answers 2

up vote 3 down vote accepted

I'm not sure what this question has to do with packaging. Users shouldn't have to be editing the python files directly, and of course would need to be root to do so to installed one. What you really want is a proper conf file installed to the users home directory. Something like:

import os
import ConfigParser

try:
    import xdg.BaseDirectory
except ImportError:
    home = os.environ.get('HOME')
    xdg_config_home = os.path.join(home, '.config/')
else:
    xdg_config_home = xdg.BaseDirectory.xdg_config_home

confDir =  os.path.join(xdg_config_home, 'myApp')
confFile =  os.path.join(confDir, 'conf.ini')

config = ConfigParser.ConfigParser()

if os.path.isfile(confFile):
    config.read(confFile)
    print "The URL is " + config.get('Section', 'url')
else:
    print "URL not set. Please edit " + confFile
    if not os.path.exists(confDir):
        os.makedirs(confDir)
    config.add_section('Section')
    config.set('Section', 'url', ' ')
    with open(confFile, 'wb') as confFile:
        config.write(confFile)

Of course, if this is a GUI app this is still a bit much for the user. You might want to implement a preferences window.

share|improve this answer
    
I almost forgot about this question. Thanks for your guidance. :) –  jokerdino Jun 15 '12 at 12:07

Because of your "very specific url" comment I gather using gwibber is not an option.

I maintain a couple year old python application originally put together with Quickly. Even if you don't want to use Quickly to put together your app, Quickly uses a modified setup.py file to modify a very small Python module. As the app. is built setup.py is called from the make sequence (usual) and a modification to setup.py changes one small but important detail regarding whether the program has been installed or whether it is being tested. I suppose you could use the same approach to change a different kind of detail.

Still, leaving an application generalized and having it read a config (preference) file would be the standard way to customize a program's operation, if at all possible. So if you can use andrewsomething's suggetion I think that would be better.

share|improve this answer

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.