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

def HarvestMan::config::HarvestManStateObject::__fix (   self  )  [private]

Fix errors in config variables 

Definition at line 782 of file config.py.

00782                    :
        """ Fix errors in config variables """

        # If there is more than one url, we
        # combine all the project related
        # variables into a dictionary for easy
        # lookup.
        num=len(self.urls)
        if num==0:
            sys.exit("Fatal Error: No URLs given, Aborting.")
            
        if not len(self.projtimeouts): self.projtimeouts.append(self.projtimeout)
        if not len(self.verbosities): self.verbosities.append(self.verbosity)
        
        if num>1:
            # Check the other list variables
            # If their length is less than url length
            # make up for it.
            for x in range(num-len(self.projects)):
                self.projects.append(self.projects[x])
            for x in range(num-len(self.basedirs)):
                self.basedirs.append(self.basedirs[x])                    
            for x in range(num-len(self.verbosities)):
                self.verbosities.append(self.verbosities[x])
            for x in range(num-len(self.projtimeouts)):
                self.projtimeouts.append(self.projtimeouts[x])
                

        # Fix url error
        for x in range(len(self.urls)):
            url = self.urls[x]

            # If null url, return
            if not url: continue

            # Check for protocol strings
            # http://
            pindex = -1
            pindex = url.find('http://')
            if pindex == -1:
                # ftp://
                pindex = url.find('ftp://')
                if pindex == -1:
                    # https://
                    pindex = url.find('https://')
                    if pindex == -1:
                        # www.
                        pindex = url.find('www.')
                        if pindex == -1:
                            pindex = url.find('file://')
                            if pindex == -1:
                                # prepend http:// to it
                                url = 'http://' + url


            self.urls[x] = url

            # If project is not set, set it to domain
            # name of the url.
            project = None
            try:
                project = self.projects[x]
            except:
                pass

            if not project:
                import urlparser
                h = urlparser.HarvestManUrlParser(url)
                project = h.get_domain()
                self.projects.append(project)

            basedir = None
            try:
                basedir = self.basedirs[x]
            except:
                pass

            if not basedir:
                self.basedirs.append('.')


Generated by  Doxygen 1.6.0   Back to index