Exemple #1
0
def build(source, build_dir, root, initiator):
    logging.info("Sync script started by %s...", initiator)

    # TODO: use this approach to include standards that are not managed on GitHub
    #standards = OSFS(source).listdir(dirs_only=True)
        
    # check if initiator is present in repos.json
    if initiator in standards_id.keys():
        cleanup(source, build_dir, initiator)

        logging.info("Fetching repo %s..." % initiator)
        backend.fetch_repo(root, initiator, standards_id[initiator]['url'], build_dir)
        
        logging.info("Building folders...")
        backend.build_folders(source, build_dir, standards_id[initiator], root)
        
        logging.info("Creating overview page...")
        webpages.create_overview_page(standards, source, build_dir)
    else:
        print "%s is not listed in repos.json... aborting." % initiator
        logging.error("%s is not listed in repos.json... aborting" % initiator)
        exit()
        #TODO: check if repo needs to be removed from repos/

    print "Done!"
from fs.errors import ResourceNotFoundError
import settings as s
from backend import fetch_repo, deploy_register, build_register
from utils import load_repos

root_fs = OSFS(s.root_path)
root_fs.makedir(s.build_path, recursive=True, allow_recreate=True)
build_fs = OSFS(s.build_path)
build_fs.makedir(s.sources_path, allow_recreate=True)
build_fs.makedir(s.register_path, allow_recreate=True)

# create production directory if needed
try:
    production_fs = OSFS(s.production_path)
except ResourceNotFoundError:
    # grab production dir's parent dir
    path = s.production_path.split('/')[-2]
    print path
    production_fs = OSFS(s.production_path[:len(s.production_path) - (len(path) + 1)]).makeopendir(path)
    print production_fs

if not production_fs.exists(s.backups_path):
    production_fs.makedir(s.backups_path)

# fetch repos from GitHub
for repo in load_repos(s.repos_path)[0].values():
    print 'Fetching %s for the first time' % repo['id']
    fetch_repo(root_fs, repo['id'], repo['url'])
    build_register(repo['id'])

deploy_register()
from fs.errors import ResourceNotFoundError
import settings as s
from backend import fetch_repo, create_production, build
from utils import load_repos

root_fs = OSFS(s.root_path)
build_fs = root_fs.makeopendir(s.build_path)
build_fs.makedir(s.sources_path)
build_fs.makedir(s.staging_path)
build_fs.makedir(s.register_path)

# create production directory if needed
try:
    production_fs = OSFS(s.production_path)
except ResourceNotFoundError:
    # grap production dir's parent dir
    path = s.production_path.split('/')[-2]
    print path
    production_fs = OSFS(s.production_path[:len(s.production_path) - (len(path) + 1)]).makeopendir(path)
    print production_fs

if production_fs.exists(s.backups_path) == False:
    production_fs.makedir(s.backups_path)

# fetch repos from GitHub
for repo in load_repos(s.repos_path)[0].values():
    print 'Fetching %s for the first time' % repo['id']
    fetch_repo(root_fs, s.sources_path, repo['id'], repo['url'], s.build_path)
    build(s.sources_path, s.register_path, root_fs, repo['id'])

create_production(s.register_path, s.backups_path, s.script_entry_path, s.production_path)