コード例 #1
0
def init_mission(args):
    from checkio_client.actions.repo import link_folder_to_repo, clone_repo_to_folder
    domain_data = conf.default_domain_data
    mission = args.mission[0]
    folder = Folder(mission)

    if folder.exists():
        print('Folder exists already')
        return

    if args.template:
        template = args.template
    else:
        domain_data = conf.default_domain_data
        template = domain_data['repo_template']

    clone_repo_to_folder(template, folder.mission_folder())

    if args.repository:
        print('Send to git...')
        link_folder_to_repo(folder.mission_folder(), args.repository)

    recompile_mission(mission)
    if not args.without_container:
        rebuild_mission(mission)
    init_home_file(mission)

    print('Done')
コード例 #2
0
ファイル: getters.py プロジェクト: zemi4/Python-tasks
def recompile_mission(slug):
    folder = Folder(slug)
    compiled_path = folder.compiled_folder_path()
    logging.info("Relink folder to %s", compiled_path)
    if os.path.exists(compiled_path):
        shutil.rmtree(compiled_path)

    mission_source = MissionFilesCompiler(compiled_path)
    mission_source.compile(source_path=folder.mission_folder(), use_link=True)
コード例 #3
0
ファイル: getters.py プロジェクト: zemi4/Python-tasks
def mission_git_getter(url, slug):
    # TODO: checkout into mission solder
    # compile it
    # build docker
    # prepare cli interface
    folder = Folder(slug)
    destination_path = folder.mission_folder()

    logging.info('Getting a new mission through the git...')
    logging.info('from %s to %s', url, destination_path)

    if os.path.exists(destination_path):
        answer = input('Folder {} exists already.'
                           ' Do you want to overwite it? [y]/n :'.format(destination_path))
        if answer is '' or answer.lower().startswith('y'):

            if os.path.islink(destination_path):
                os.remove(destination_path)
            else:
                shutil.rmtree(destination_path)
        else:
            return


    if os.path.exists(url):
        logging.info('Linking folder %s -> %s', url, destination_path)
        os.symlink(os.path.abspath(url), destination_path)
        return

    re_ret = re.search(RE_REPO_BRANCH, url)
    if re_ret:
        checkout_url, branch = re_ret.groups()
    else:
        checkout_url = url
        branch = 'master'

    logging.debug('URL info: checkioout url:%s branch:%s', url, branch)

    try:
        git.Repo.clone_from(checkout_url, destination_path, branch=branch)
    except git.GitCommandError as e:
        raise Exception(u"{}, {}".format(e or '', e.stderr))
    folder.mission_config_write({
        'type': 'git',
        'url': url
    })
    logging.info('Prepare mission {} from {}'.format(slug, url))