Example #1
0
def get_config_file(name):
    sitepath = get_config('site_db.ini')['db_path']
    if not os.path.exists(sitepath):
        os.makedirs(sitepath)
        # no need to search for the site file
        return None
    sitefile = os.path.join(sitepath, name)
    if not os.path.exists(sitefile):
        return None

    file = ConfigParser()
    file.read(sitefile)
    return file
Example #2
0
    def list_site_users(self, **tokens):
        sitepath = get_config('site_db.ini')['db_path']
        if not os.path.exists(sitepath):
            os.makedirs(sitepath)
            # no need to search for the site files
            return []
        sitefiles = os.listdir(sitepath)
        sites = []
        for sitefile in sitefiles:
            if sitefile[0] == '.':
                continue
            file = ConfigParser()
            file.read(os.path.join(sitepath, sitefile))
            users = file.sections()
            if len(users):
                for user in users:
                    sites.append(SiteInfo(user, sitefile))
            else:
                sites.append(SiteInfo(None, sitefile))

        return sites