def repository_new(self): """Add a repository .. :quickref: Module; Add repository Requires the `manage_modules` permission. If successful, will return the repository in ``repository``. Otherwise, errors will be available in ``errors``. :form name: name of the repository (should be a valid package name). :form address: HTTPs or SSH address of the repository. :form private: boolean specifying if the repository is private. See Administration Guide for more details on private repositories. """ deploy_key = get_deploy_key() repository = Repository() if request.method == 'POST': for field in ['name', 'address']: repository[field] = request.form.get(field) if repository[field] is None or repository[field] == "": flash("{} is required.".format(field), 'danger') return validation_error() existing_repository = Repository.get( **{field: repository[field]}) if existing_repository: flash( "There is already a repository with this {}.".format( field), 'danger') return validation_error() value = request.form.get('private') repository['private'] = (value is not None) and (value not in [ '0', 'False' ]) if repository['private'] and deploy_key is None: flash( "Private repositories are disabled because of a problem with your installation (you do not have a deploy key in 'conf/id_rsa.pub')", 'danger') return validation_error() repository['status'] = 'cloning' repository.save() repository.clone() return redirect({'repository': clean_repositories(repository)}, url_for('ModulesView:index')) return render({ 'repository': repository, 'deploy_key': deploy_key }, 'modules/repository_new.html')
def add_community_repository(): from fame.core.repository import Repository repo = Repository.get(name="community") if repo: print "[+] Community repository already installed." else: print "[+] Installing community repository ..." repo = Repository({ 'name': 'community', 'address': 'https://github.com/certsocietegenerale/fame_modules.git', 'private': False, 'status': 'cloning' }) repo.save() repo.do_clone()