def package_take(namespace, package, full=True): ''' Make someone Point of contact of an orphaned package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package( SESSION, namespace, package) package = pkgdblib.search_package( SESSION, namespace, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Orphaned' ] if not collections: flask.flash('No branches orphaned found', 'error') return flask.redirect(flask.url_for( '.package_info', namespace=package.namespace, package=package.name) ) form = pkgdb2.forms.BranchForm(collections=collections) if form.validate_on_submit(): for branch in form.branches.data: try: pkgdblib.unorphan_package( session=SESSION, namespace=package.namespace, pkg_name=package.name, pkg_branch=branch, pkg_user=flask.g.fas_user.username, user=flask.g.fas_user ) SESSION.commit() flask.flash('You have taken the package %s on branch %s' % ( package.name, branch)) except pkgdblib.PkgdbBugzillaException, err: # pragma: no cover APP.logger.exception(err) flask.flash(str(err), 'error') SESSION.rollback() except pkgdblib.PkgdbException, err: # pragma: no cover flask.flash(str(err), 'error') SESSION.rollback()
def package_take(namespace, package, full=True): ''' Make someone Point of contact of an orphaned package. ''' if not bool(full) or str(full) in ['0', 'False']: full = False try: package_acl = pkgdblib.get_acl_package(SESSION, namespace, package) package = pkgdblib.search_package(SESSION, namespace, package, limit=1)[0] except (NoResultFound, IndexError): SESSION.rollback() flask.flash('No package of this name found.', 'errors') return flask.render_template('msg.html') collections = [ acl.collection.branchname for acl in package_acl if acl.collection.status in ['Active', 'Under Development'] and acl.status == 'Orphaned' ] if not collections: flask.flash('No branches orphaned found', 'error') return flask.redirect( flask.url_for('.package_info', namespace=package.namespace, package=package.name)) form = pkgdb2.forms.BranchForm(collections=collections) if form.validate_on_submit(): for branch in form.branches.data: try: pkgdblib.unorphan_package(session=SESSION, namespace=package.namespace, pkg_name=package.name, pkg_branch=branch, pkg_user=flask.g.fas_user.username, user=flask.g.fas_user) SESSION.commit() flask.flash('You have taken the package %s on branch %s' % (package.name, branch)) except pkgdblib.PkgdbBugzillaException, err: # pragma: no cover APP.logger.exception(err) flask.flash(str(err), 'error') SESSION.rollback() except pkgdblib.PkgdbException, err: # pragma: no cover flask.flash(str(err), 'error') SESSION.rollback()
def package_take(package, collection): ''' Make someone Point of contact of an orphaned package. ''' try: pkgdblib.unorphan_package(session=SESSION, pkg_name=package, pkg_branch=collection, pkg_user=flask.g.fas_user.username, user=flask.g.fas_user) SESSION.commit() flask.flash('You have taken the package %s on branch %s' % (package, collection)) except pkgdblib.PkgdbException, err: SESSION.rollback() flask.flash(str(err), 'error')
def api_package_unorphan(): ''' Unorphan packages ----------------- Unorphan one or more packages. :: /api/package/unorphan/ Accepts POST queries only. :arg pkgnames: Comma separated list of string of the packages name. :arg branches: Comma separated list of string of the branches name in which these packages will be unorphaned. :arg poc: String of the name of the user taking ownership of this package. If you are not an admin, this name must be None. Sample response: :: { "output": "ok", "messages": ["Package $PACKAGE has been unorphaned for $BRANCH " "by $USER"] } { "output": "notok", "error": ["You must be a packager to take a package."] } ''' httpcode = 200 output = {} pkgnames = flask.request.form.getlist('pkgnames', None) branches = flask.request.form.getlist('branches', None) poc = flask.request.form.get('poc', None) if pkgnames and branches and poc: messages = [] errors = set() for pkg_name, pkg_branch in itertools.product(pkgnames, branches): try: message = pkgdblib.unorphan_package(session=SESSION, pkg_name=pkg_name, pkg_branch=pkg_branch, pkg_user=poc, user=flask.g.fas_user) messages.append(message) SESSION.commit() except pkgdblib.PkgdbBugzillaException, err: # pragma: no cover APP.logger.exception(err) SESSION.rollback() errors.add(str(err)) except pkgdblib.PkgdbException, err: SESSION.rollback() errors.add(str(err))
def package_take(package, collection): ''' Make someone Point of contact of an orphaned package. ''' try: pkgdblib.unorphan_package( session=SESSION, pkg_name=package, pkg_branch=collection, pkg_user=flask.g.fas_user.username, user=flask.g.fas_user ) SESSION.commit() flask.flash('You have taken the package %s on branch %s' % ( package, collection)) except pkgdblib.PkgdbException, err: SESSION.rollback() flask.flash(str(err), 'error')
def api_package_unorphan(): """ Unorphan packages ----------------- Unorphan one or more packages. :: /api/package/unorphan/ Accepts POST queries only. :arg pkgnames: Comma separated list of string of the packages name. :arg branches: Comma separated list of string of the branches name in which these packages will be unorphaned. :arg poc: String of the name of the user taking ownership of this package. If you are not an admin, this name must be None. Sample response: :: { "output": "ok", "messages": ["Package $PACKAGE has been unorphaned for $BRANCH " "by $USER"] } { "output": "notok", "error": ["You must be a packager to take a package."] } """ httpcode = 200 output = {} pkgnames = flask.request.form.getlist("pkgnames", None) branches = flask.request.form.getlist("branches", None) poc = flask.request.form.get("poc", None) if pkgnames and branches and poc: messages = [] errors = set() for pkg_name, pkg_branch in itertools.product(pkgnames, branches): try: message = pkgdblib.unorphan_package( session=SESSION, pkg_name=pkg_name, pkg_branch=pkg_branch, pkg_user=poc, user=flask.g.fas_user ) messages.append(message) SESSION.commit() except pkgdblib.PkgdbBugzillaException, err: # pragma: no cover APP.logger.exception(err) SESSION.rollback() errors.add(str(err)) except pkgdblib.PkgdbException, err: SESSION.rollback() errors.add(str(err))
def api_package_unorphan(): ''' Unorphan packages ----------------- Unorphan one or more packages. :: /api/package/unorphan/ Accept POST queries only. :arg pkg_name: Comma separated list of string of the packages name. :arg clt_name: Comma separated list of string of the branches name in which these packages will be unorphaned. :arg pkg_poc: String of the name of the user taking ownership of this package. If you are not an admin, this name must be None. Sample response: :: { "output": "ok", "messages": ["Package $PACKAGE has been unorphaned for $BRANCH " "by $USER"] } { "output": "notok", "error": ["You must be a packager to take a package."] } ''' httpcode = 200 output = {} form = forms.PackageOwnerForm( csrf_enabled=False, ) if form.validate_on_submit(): pkg_names = form.pkg_name.data.split(',') pkg_branchs = form.clt_name.data.split(',') pkg_poc = form.pkg_poc.data try: messages = [] for pkg_name, pkg_branch in itertools.product( pkg_names, pkg_branchs): message = pkgdblib.unorphan_package( session=SESSION, pkg_name=pkg_name, pkg_branch=pkg_branch, pkg_user=pkg_poc, user=flask.g.fas_user ) messages.append(message) SESSION.commit() output['output'] = 'ok' output['messages'] = messages except pkgdblib.PkgdbException, err: SESSION.rollback() output['output'] = 'notok' output['error'] = str(err) httpcode = 500
def api_package_unorphan(): ''' Unorphan packages ----------------- Unorphan one or more packages. :: /api/package/unorphan/ Accept POST queries only. :arg pkg_name: Comma separated list of string of the packages name. :arg clt_name: Comma separated list of string of the branches name in which these packages will be unorphaned. :arg pkg_poc: String of the name of the user taking ownership of this package. If you are not an admin, this name must be None. Sample response: :: { "output": "ok", "messages": ["Package $PACKAGE has been unorphaned for $BRANCH " "by $USER"] } { "output": "notok", "error": ["You must be a packager to take a package."] } ''' httpcode = 200 output = {} form = forms.PackageOwnerForm(csrf_enabled=False, ) if form.validate_on_submit(): pkg_names = form.pkg_name.data.split(',') pkg_branchs = form.clt_name.data.split(',') pkg_poc = form.pkg_poc.data try: messages = [] for pkg_name, pkg_branch in itertools.product( pkg_names, pkg_branchs): message = pkgdblib.unorphan_package(session=SESSION, pkg_name=pkg_name, pkg_branch=pkg_branch, pkg_user=pkg_poc, user=flask.g.fas_user) messages.append(message) SESSION.commit() output['output'] = 'ok' output['messages'] = messages except pkgdblib.PkgdbException, err: SESSION.rollback() output['output'] = 'notok' output['error'] = str(err) httpcode = 500