Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 403  / 1 Year ago, fri, march 3, 2023, 12:56:15

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.


More From » python

 Answers
3

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.


[#38103] Saturday, March 4, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
heathree

Total Points: 157
Total Questions: 132
Total Answers: 108

Location: Honduras
Member since Mon, Apr 5, 2021
3 Years ago
;