Logo Search packages:      
Sourcecode: pythoncard version File versions  Download package

def textRouter::TextRouter::loadInConfig (   self,
  configFile = "textRouter.conf" 
)

Loads in a config file, and sets the Manila site account settings accordingly

Definition at line 2428 of file textRouter.py.

02428                                                           :
        """Loads in a config file, and sets the Manila site account settings accordingly"""
        msg = "Loading: Config file loaded."
        self.status(msg)
        try:
            configuration = util.readAndEvalFile(configFile)
        except IOError, e:
            self.status("Error loading config file: %s" % e)
            return
        
        # load's up the general preferences
        self.loadInPrefsSet(configuration, "generalPrefs", "generalPreferences")

        # load's up the html preferences
        self.loadInPrefsSet(configuration, "htmlPrefs", "htmlPreferences")

        # load's up the email preferences
        self.loadInPrefsSet(configuration, "emailPrefs", "emailPreferences")

        # load's up the manila preferences
        self.loadInPrefsSet(configuration, "manilaPrefs", "manilaPreferences")

        # load's up the blogger preferences
        self.loadInPrefsSet(configuration, "bloggerPrefs", "bloggerPreferences")

        # load's up the blogger preferences
        self.loadInPrefsSet(configuration, "utilitiesPrefs", "utilitiesPreferences")


        # load's up the state settings (last input/output action, last load/save filenames)
        if "stateSettings" in configuration:
            for aKey in configuration["stateSettings"].keys():
                self.stateSettings[aKey] = configuration["stateSettings"][aKey]
            self.loadInStateSettings()


        # load's up the predefined email recipients
        if "emailRecipients" in configuration:
            self.emailRcpts = configuration["emailRecipients"]

        # load's up the filters
        if "filters" in configuration:
            self.filters = configuration["filters"]

        # sets the manila settings via the setter method
        if "manilaAccounts" in configuration:
            for manilaAccountPrefs in configuration["manilaAccounts"]:

                # these are specifically checked for, because they were later additions, and so by doing
                # this we didn't break the config file for people who were already using it.
                weblogFile = ("weblogOPML" in manilaAccountPrefs and \
                              [ manilaAccountPrefs["weblogOPML"] ] or \
                              [ "" ])[0]

                usePostedL = ("usePostedLine" in manilaAccountPrefs and \
                              [ manilaAccountPrefs["usePostedLine"] ] or \
                              [ "No" ])[0]

                postedLine = ("postedLine" in manilaAccountPrefs and \
                              [ manilaAccountPrefs["postedLine"] ] or \
                              [ "posted at %I:%M %p" ])[0]


                if self.generalPrefs["useProxy"] == "Yes":
                    proxy = self.generalPrefs["proxyServer"] + ":" + str(self.generalPrefs["proxyPort"])
                else:
                    proxy = ""

                self.theManilaAccounts.append(ManilaAccount(proxy))
                
                self.theManilaAccounts[-1].setPrefs(manilaAccountPrefs["siteurl"], \
                                                    manilaAccountPrefs["rpcserver"], \
                                                    manilaAccountPrefs["username"], \
                                                    manilaAccountPrefs["password"], \
                                                    weblogFile, \
                                                    usePostedL, \
                                                    postedLine )
                
        # sets the blogger settings via the setter method, and then setups the active blog.
        if "bloggerAccounts" in configuration:
            for bloggerAccountPrefs in configuration["bloggerAccounts"]:
                if "weblogsPing" in bloggerAccountPrefs:
                    weblogsPing = bloggerAccountPrefs["weblogsPing"]
                else:
                    weblogsPing = "Yes"

                #if self.generalPrefs["useProxy"] == 'Yes':
                #    print "using proxy"
                #    self.theBloggerAccounts.append(BloggerAccount("yes"))
                #else:
                #    print "not using proxy"
                if self.generalPrefs["useProxy"] == "Yes":
                    proxy = self.generalPrefs["proxyServer"] + ":" + str(self.generalPrefs["proxyPort"])
                else:
                    proxy = ""

                self.theBloggerAccounts.append(BloggerAccount(proxy))

                self.theBloggerAccounts[-1].setPrefs(bloggerAccountPrefs["rpcserver"], \
                                                     bloggerAccountPrefs["username"], \
                                                     bloggerAccountPrefs["password"], \
                                                     weblogsPing)

                # can't use setActiveBlog because we haven't logged in yet.  arg.
                self.theBloggerAccounts[-1].prefs["activeBlog"] = int(bloggerAccountPrefs["activeBlog"])
        
        ## -- now do the actual auto login for Blogger
        if self.bloggerPrefs["bloggerAutoLogin"] == 'Yes':
            if "theCurrentBloggerAccount" not in self.stateSettings or \
               self.stateSettings["theCurrentBloggerAccount"] == -1:
                msg += "  Can't login to Blogger because you have no accounts defined."
            else:
                self.status(msg + "  Logging in to Blogger...")
                self.theBloggerAccounts[self.theCurrentBloggerAccount].bloggerLogin()
                if self.theBloggerAccounts[self.theCurrentBloggerAccount].anErrorOccured():
                    msg += "  Error logging in to Blogger."
                else:
                    msg += "  Blogger login OK."
            
        self.status(msg)

        ## -- now do the actual auto login for Manila
        if self.manilaPrefs["manilaAutoLogin"] == 'Yes':
            if self.theCurrentManilaAccount != -1:
                self.theManilaAccounts[self.theCurrentManilaAccount].manilaLogin()
                if self.theManilaAccounts[self.theCurrentManilaAccount].anErrorOccured():
                    msg += "  Error logging in to Manila."
                else:
                    msg += "  Manila login OK."

                    self.status(msg)

                    # now get homepage, if we thats also in the prefs
                    if self.manilaPrefs["manilaAutoGetHomepage"] == 'Yes':
                        self.theManilaAccounts[self.theCurrentManilaAccount].manilaGetHP()
                        if self.theManilaAccounts[self.theCurrentManilaAccount].anErrorOccured():
                            msg += "  Error getting homepage."
                        else:
                            self.updateTextBox(self.theManilaAccounts[self.theCurrentManilaAccount].currentHPContent["body"])
                            msg += "  Homepage downloaded successfully."                    
        self.status(msg)

    def loadInPrefsSet(self, configuration, nameSet, nameSetConfig):


Generated by  Doxygen 1.6.0   Back to index