[packagedb-cli] Rename pkgdb into pkgdb-cli
by Pierre-YvesChibon
commit 6c0e72a55e78e02abfb625d36e96d1bedf13fd4e
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 29 12:46:35 2011 +0200
Rename pkgdb into pkgdb-cli
pkgdb.py => pkgdb-cli.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb-cli.py
similarity index 99%
rename from pkgdb.py
rename to pkgdb-cli.py
index 2bebb61..59fba71 100755
--- a/pkgdb.py
+++ b/pkgdb-cli.py
@@ -849,7 +849,7 @@ def setup_parser():
usage = "\nCommands: {0}".format(', '.join(cmdlist))
parser = argparse.ArgumentParser(
usage="%(prog)s [global options] COMMAND [options]" + usage,
- prog="pkgdb")
+ prog="pkgdb-cli")
# General connection options
parser.add_argument('command')
parser.add_argument('argument', nargs=argparse.REMAINDER)
12 years, 10 months
[packagedb-cli] Update README file
by Pierre-YvesChibon
commit 899167971d87f50af9e999821c39e3d1cf0012d8
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 29 10:42:58 2011 +0200
Update README file
README | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/README b/README
index 67ab1d7..03ed064 100644
--- a/README
+++ b/README
@@ -29,7 +29,7 @@ Installation
Install Prerequisites
~~~~~~~~~~~~~~~~~~~~~
::
- yum install koji python-fedora
+ yum install python-fedora
Get and Run the Source
~~~~~~~~~~~~~~~~~~~~~~~~
12 years, 10 months
[packagedb-cli] No need to catch this error which hides information
by Pierre-YvesChibon
commit e3dfd80ab894e6a1d87b4cd69068ef03ca8062c5
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 22 10:48:24 2011 +0200
No need to catch this error which hides information
pkgdb.py | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 3f80787..2bebb61 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -612,14 +612,8 @@ def handle_acl(packagename, action, branch='devel', cancel=False,
log.debug("Process all acl for user: {0}".format(
pkgdbclient.username))
for action in actionlist:
- try:
- msg = _handle_acl_request(packagename, action,
+ msg = _handle_acl_request(packagename, action,
branch, cancel)
- except ServerError, err:
- log.info(
- "Could not process acl '{0}' for branch '{1}'".format(
- action, branch))
- log.debug(err)
# else we process only the given one
else:
12 years, 10 months
[packagedb-cli] Make use of set_remove_acl_request
by Pierre-YvesChibon
commit 11ac3c07319fff6afd0f9cb4ce7e128a1dfdc1ba
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Wed Jun 22 10:45:43 2011 +0200
Make use of set_remove_acl_request
This method will only set ACL request if the request has not already been granted.
On the other side, it will Obsolete any requests (wether it was granted or not).
pkgdb.py | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index e4b003c..3f80787 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -308,21 +308,25 @@ def _handle_acl_request(packagename, action, branch, cancel=False):
log.debug(
"Process acl '{0}' for user {1} and package {2} on branch {3}".format(
action, pkgdbclient.username, packagename, branch))
+ statusname = "Awaiting Review"
params = {'pkgid' : packageid,
- 'person_name' : pkgdbclient.username,
- 'new_acl' : action,
- 'statusname' : "Awaiting Review"}
+ 'person_name' : pkgdbclient.username,
+ 'acl_name' : action,
+ 'set_acl' : True}
if cancel:
- params['statusname'] = "Obsolete"
+ params['set_acl'] = False
+ statusname = "Obsolete"
pkgdbinfo = pkgdbclient.send_request(
- '/acls/dispatcher/set_acl_status/',
+ '/acls/dispatcher/set_remove_acl_request/',
auth=True, req_params=params)
log.debug(pkgdbinfo)
wentok = False
- if 'status' in pkgdbinfo.keys() \
+ if "message" in pkgdbinfo.keys():
+ msg = "{0}: {1}".format(action, pkgdbinfo["message"])
+ elif 'status' in pkgdbinfo.keys() \
and str(pkgdbinfo['status']) == "True":
msg = "ACL {2}{0}{4} for user {1} was set to {2}'{3}'{4} on package {5} branch {6}".format(
- action, pkgdbclient.username, bold, params['statusname'], reset,
+ action, pkgdbclient.username, bold, statusname, reset,
packagename, branch)
wentok = True
else:
@@ -626,7 +630,7 @@ def handle_acl(packagename, action, branch='devel', cancel=False,
log.info("Could not process acl '{0}' for branch '{1}'".format(
action, branch))
log.debug(err)
-
+ return msg
def answer_acl_request(packagename, action, user, answer, branch=None,
username=None, password=None):
12 years, 10 months
[packagedb-cli] Improve ACL request management
by Pierre-YvesChibon
commit 774323f36b76ae55ef9709cfcead34ebe96f56c7
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Tue Jun 21 21:36:50 2011 +0200
Improve ACL request management
pkgdb.py | 73 +++++++++++++++++++++++++++++--------------------------------
1 files changed, 35 insertions(+), 38 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 5b694ed..e4b003c 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -291,32 +291,44 @@ def _answer_acl(action, user, packagename, answer, branch):
" so?".format(answer)
-def _toggle_one_acl(packagename, action, branch, cancel=False):
+def _handle_acl_request(packagename, action, branch, cancel=False):
"""
- Request for an action on a specific branch for a specific package.
+ Set or remove (cancel) an ACL request for an action on a specific
+ branch for a specific package.
:arg packagename is the name of the package for which you would like
to request an ACL.
:arg action is action which is requested for this package, actions
allowed are: [watchbugzilla, watchcommit, commit, approveacls]
- :arg branch name of the branch for which to toggle the ACL.
+ :arg branch name of the branch for which to process the ACL.
:karg cancel change the toggling of the ACL from requesting to a new
ACL to obsoleting an already requested ACL.
"""
packageid = _get_package_id(packagename, branch)
log.debug(
- "Toggle acl '{0}' for user {1} and package {2} on branch {3}".format(
+ "Process acl '{0}' for user {1} and package {2} on branch {3}".format(
action, pkgdbclient.username, packagename, branch))
- params = {'container_id': '{0}:{1}'.format(packageid, action)}
+ params = {'pkgid' : packageid,
+ 'person_name' : pkgdbclient.username,
+ 'new_acl' : action,
+ 'statusname' : "Awaiting Review"}
+ if cancel:
+ params['statusname'] = "Obsolete"
pkgdbinfo = pkgdbclient.send_request(
- '/acls/dispatcher/toggle_acl_request',
+ '/acls/dispatcher/set_acl_status/',
auth=True, req_params=params)
log.debug(pkgdbinfo)
- if 'aclStatus' in pkgdbinfo.keys():
- msg = pkgdbinfo['aclStatus']
+ wentok = False
+ if 'status' in pkgdbinfo.keys() \
+ and str(pkgdbinfo['status']) == "True":
+ msg = "ACL {2}{0}{4} for user {1} was set to {2}'{3}'{4} on package {5} branch {6}".format(
+ action, pkgdbclient.username, bold, params['statusname'], reset,
+ packagename, branch)
+ wentok = True
else:
- msg = pkgdbinfo['message']
- return msg
+ msg = "Something went wrong and we could not set the ACL as you wished"
+ print msg
+ return wentok
def get_packages(motif=None, name_only=False):
@@ -559,7 +571,7 @@ def get_last_build(packagename, tag):
_get_last_build(packagename, tag)
-def toggle_acl(packagename, action, branch='devel', cancel=False,
+def handle_acl(packagename, action, branch='devel', cancel=False,
username=None, password=None):
"""
Request for a user and a branch the action for a given package.
@@ -568,7 +580,7 @@ def toggle_acl(packagename, action, branch='devel', cancel=False,
to request an ACL.
:arg action is action which is requested for this package, actions
allowed are: [watchbugzilla, watchcommit, commit, approveacls]
- :karg branch name of the branch for which to toggle the ACL. By
+ :karg branch name of the branch for which to set/remove the ACL. By
default this branch is 'devel' but can also be 'f-14'...
:karg cancel change the toggling of the ACL from requesting to a new
ACL to obsoleting an already requested ACL.
@@ -591,44 +603,29 @@ def toggle_acl(packagename, action, branch='devel', cancel=False,
action, ",".join(actionlist)))
msg = ""
- # if action == 'all' then we toggle all the ACLs
+ # if action == 'all' then we set/remove all the ACLs
if action == 'all':
- log.debug("Toggle all acl for user: {0}".format(
+ log.debug("Process all acl for user: {0}".format(
pkgdbclient.username))
for action in actionlist:
try:
- msg = _toggle_one_acl(packagename, action, branch,
- cancel)
+ msg = _handle_acl_request(packagename, action,
+ branch, cancel)
except ServerError, err:
log.info(
- "Could not toggle acl '{0}' for branch '{1}'".format(
+ "Could not process acl '{0}' for branch '{1}'".format(
action, branch))
log.debug(err)
- if msg != "":
- print "{0}{1}{2} for {3} on package {4} branch {5}"\
- "".format(
- bold,
- msg,
- reset,
- pkgdbclient.username,
- packagename,
- branch)
- # else we toggle only the given one
+
+ # else we process only the given one
else:
try:
- msg = _toggle_one_acl(packagename, action, branch, cancel)
+ msg = _handle_acl_request(packagename, action, branch,
+ cancel)
except ServerError, err:
- log.info("Could not toggle acl '{0}' for branch '{1}'".format(
+ log.info("Could not process acl '{0}' for branch '{1}'".format(
action, branch))
log.debug(err)
- if msg != "":
- print "{0}{1}{2} for {3} on package {4} branch {5}".format(
- bold,
- msg,
- reset,
- pkgdbclient.username,
- packagename,
- branch)
def answer_acl_request(packagename, action, user, answer, branch=None,
@@ -934,7 +931,7 @@ def main():
log.info("branch : {0}".format(args.branch))
log.info("acl : {0}".format(args.action))
log.info("cancel : {0}".format(args.cancel))
- toggle_acl(args.package, action=args.action,
+ handle_acl(args.package, action=args.action,
branch=args.branch, cancel=args.cancel,
username=arg.username, password=arg.password)
12 years, 10 months
[packagedb-cli] Start fixing the request process
by Pierre-YvesChibon
commit a7f9daa42b635898880480364d687b8ccc6f3918
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Mon Jun 20 14:17:57 2011 +0200
Start fixing the request process
pkgdb.py | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 9d1c2a4..5b694ed 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -291,7 +291,7 @@ def _answer_acl(action, user, packagename, answer, branch):
" so?".format(answer)
-def _toggle_one_acl(packagename, action, branch):
+def _toggle_one_acl(packagename, action, branch, cancel=False):
"""
Request for an action on a specific branch for a specific package.
@@ -300,6 +300,8 @@ def _toggle_one_acl(packagename, action, branch):
:arg action is action which is requested for this package, actions
allowed are: [watchbugzilla, watchcommit, commit, approveacls]
:arg branch name of the branch for which to toggle the ACL.
+ :karg cancel change the toggling of the ACL from requesting to a new
+ ACL to obsoleting an already requested ACL.
"""
packageid = _get_package_id(packagename, branch)
log.debug(
@@ -557,7 +559,7 @@ def get_last_build(packagename, tag):
_get_last_build(packagename, tag)
-def toggle_acl(packagename, action, branch='devel',
+def toggle_acl(packagename, action, branch='devel', cancel=False,
username=None, password=None):
"""
Request for a user and a branch the action for a given package.
@@ -568,6 +570,8 @@ def toggle_acl(packagename, action, branch='devel',
allowed are: [watchbugzilla, watchcommit, commit, approveacls]
:karg branch name of the branch for which to toggle the ACL. By
default this branch is 'devel' but can also be 'f-14'...
+ :karg cancel change the toggling of the ACL from requesting to a new
+ ACL to obsoleting an already requested ACL.
:karg username the FAS username for the user requesting the ACL.
:karg password the FAS password for the user requesting the ACL.
"""
@@ -593,7 +597,8 @@ def toggle_acl(packagename, action, branch='devel',
pkgdbclient.username))
for action in actionlist:
try:
- msg = _toggle_one_acl(packagename, action, branch)
+ msg = _toggle_one_acl(packagename, action, branch,
+ cancel)
except ServerError, err:
log.info(
"Could not toggle acl '{0}' for branch '{1}'".format(
@@ -611,7 +616,7 @@ def toggle_acl(packagename, action, branch='devel',
# else we toggle only the given one
else:
try:
- msg = _toggle_one_acl(packagename, action, branch)
+ msg = _toggle_one_acl(packagename, action, branch, cancel)
except ServerError, err:
log.info("Could not toggle acl '{0}' for branch '{1}'".format(
action, branch))
@@ -811,6 +816,8 @@ def setup_action_parser(action, last_args=None):
help="Orphan all your packages")
elif action == "request":
+ parser.add_argument('--cancel', action="store_true", default=False,
+ help="Obsolete an ACL request")
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
help="Request (or obsolete a request) for specific ACL on this package " \
@@ -926,8 +933,9 @@ def main():
log.info("package : {0}".format(args.package))
log.info("branch : {0}".format(args.branch))
log.info("acl : {0}".format(args.action))
+ log.info("cancel : {0}".format(args.cancel))
toggle_acl(args.package, action=args.action,
- branch=args.branch,
+ branch=args.branch, cancel=args.cancel,
username=arg.username, password=arg.password)
elif action == "update":
12 years, 10 months
[packagedb-cli] Code cleanning
by Pierre-YvesChibon
commit 5ba7e7aa75c88972d8d8f42911f46e68dd3adb23
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Mon Jun 20 14:17:06 2011 +0200
Code cleanning
Run pylint & pep8
pkgdb.py | 59 +++++++++++++++++++++++++++++------------------------------
1 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index b5de2d2..9d1c2a4 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -46,7 +46,7 @@ elif '--verbose' in sys.argv:
if '--nocolor' in sys.argv:
red = ""
- bold = ""
+ bold = ""
reset = ""
cmdlist = ['acl', 'list', 'request', 'update', 'orphan']
@@ -83,8 +83,7 @@ def _get_client_authentified(username=None, password=None):
pkgdbclient.password = password
-def _get_group_info(group, statusmap, tmpstring="", prevstring="",
- pending=False):
+def _get_group_info(group, statusmap, tmpstring="", pending=False):
"""
For a given group (or user) check the ACL to print the ACL of the
group or person.
@@ -104,7 +103,6 @@ def _get_group_info(group, statusmap, tmpstring="", prevstring="",
:karg tmpstring temporary string used to keep information and set
the layout. At the end it contains the whole row which is the object
returned
- :karg prevstring previous string.
:karg pending by default all statuscode are returned, if pending is
true then only statuscode corresponding to "awaiting review" are
returned
@@ -119,10 +117,8 @@ def _get_group_info(group, statusmap, tmpstring="", prevstring="",
aclout = statusmap[str(
group['aclOrder'][acl]['statuscode'])]
tmpstring = tmpstring + aclout + " " * (16 - len(aclout))
- prevstring = group['aclOrder'][acl]['acl']
else:
tmpstring = tmpstring + " " * 16
- prevstring = ""
if not has_acl:
# return None if there are no ACLs (it used to have ACLs in
# past)
@@ -349,7 +345,7 @@ def get_packages(motif=None, name_only=False):
req_params={'tg_paginate_limit': 0})
print pkgdbinfo['title']
for pkg in pkgdbinfo['packages']:
- out = " " + pkg['name']+ " " * (33 - \
+ out = " " + pkg['name'] + " " * (33 - \
len(pkg['name'])) + \
pkg['summary']
if name_only:
@@ -394,7 +390,7 @@ def get_orphaned_packages(motif=None, eol=False, name_only=False):
print pkgdbinfo.keys()
print pkgdbinfo['title']
for pkg in pkgdbinfo['pkgs']:
- out = " " + pkg['name']+ " " * (33 - \
+ out = " " + pkg['name'] + " " * (33 - \
len(pkg['name'])) + \
pkg['summary']
if name_only:
@@ -435,7 +431,7 @@ def get_packager_info(packager, output=True, name_only=False):
log.info(name_only)
pkgs.append(pkg['name'])
if output:
- out = " " + pkg['name']+ " " * (33 - \
+ out = " " + pkg['name'] + " " * (33 - \
len(pkg['name'])) + \
pkg['summary']
if name_only:
@@ -514,10 +510,8 @@ def get_package_info(packagename, branch=None, pending=False,
print "{0}Group:".format(" " * 8)
for group in collection['groups']:
tmp = " " * 10 + group['groupname']
- prevstring = group['groupname']
info = _get_group_info(group, pkgdbinfo['statusMap'],
- tmp, prevstring,
- pending=pending)
+ tmp, pending=pending)
if info is not None and info != "":
print info
@@ -525,10 +519,8 @@ def get_package_info(packagename, branch=None, pending=False,
print "{0}Comaintainer(s):".format(" " * 8)
for people in collection['people']:
tmp = " " * 10 + people['username']
- prevstring = tmp
info = _get_group_info(people, pkgdbinfo['statusMap'],
- tmp, prevstring,
- pending=pending)
+ tmp, pending=pending)
if info is not None and info != "":
print info
@@ -565,8 +557,8 @@ def get_last_build(packagename, tag):
_get_last_build(packagename, tag)
-def toggle_acl(packagename, action, branch='devel', username=None,
- password=None):
+def toggle_acl(packagename, action, branch='devel',
+ username=None, password=None):
"""
Request for a user and a branch the action for a given package.
@@ -590,22 +582,26 @@ def toggle_acl(packagename, action, branch='devel', username=None,
_get_client_authentified(username=username, password=password)
for branch in branches:
if action not in actionlist and action != 'all':
- raise ActionError("Action '{0}' is not in the list: {1},all".format(
+ raise ActionError(
+ "Action '{0}' is not in the list: {1},all".format(
action, ",".join(actionlist)))
msg = ""
# if action == 'all' then we toggle all the ACLs
if action == 'all':
- log.debug("Toggle all acl for user: {0}".format(pkgdbclient.username))
+ log.debug("Toggle all acl for user: {0}".format(
+ pkgdbclient.username))
for action in actionlist:
try:
msg = _toggle_one_acl(packagename, action, branch)
- except ServerError, er:
- log.info("Could not toggle acl '{0}' for branch '{1}'".format(
+ except ServerError, err:
+ log.info(
+ "Could not toggle acl '{0}' for branch '{1}'".format(
action, branch))
- log.debug(er)
+ log.debug(err)
if msg != "":
- print "{0}{1}{2} for {3} on package {4} branch {5}".format(
+ print "{0}{1}{2} for {3} on package {4} branch {5}"\
+ "".format(
bold,
msg,
reset,
@@ -616,10 +612,10 @@ def toggle_acl(packagename, action, branch='devel', username=None,
else:
try:
msg = _toggle_one_acl(packagename, action, branch)
- except ServerError, er:
+ except ServerError, err:
log.info("Could not toggle acl '{0}' for branch '{1}'".format(
action, branch))
- log.debug(er)
+ log.debug(err)
if msg != "":
print "{0}{1}{2} for {3} on package {4} branch {5}".format(
bold,
@@ -818,7 +814,8 @@ def setup_action_parser(action, last_args=None):
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
help="Request (or obsolete a request) for specific ACL on this package " \
- "(actions are '{0}', 'all')".format("', '".join(actionlist)))
+ "(actions are '{0}', 'all')".format(
+ "', '".join(actionlist)))
parser.add_argument('branch', default='devel', nargs="?",
help="Branch of the package for which the ACL is " \
"requested (default: 'devel', can be: 'all')")
@@ -827,7 +824,8 @@ def setup_action_parser(action, last_args=None):
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
help="Request a specific ACL for this package " \
- "(actions are: '{0}', 'all')".format("', '".join(actionlist)))
+ "(actions are: '{0}', 'all')".format(
+ "', '".join(actionlist)))
parser.add_argument('user',
help="FAS username of the person who requested ACL " \
"on this package")
@@ -887,7 +885,7 @@ def main():
log.info("package : {0}".format(args.package))
log.info("branch : {0}".format(args.branch))
#log.info("approve : {0}".format(args.approve))
- get_package_info(args.package, branch=args.branch,
+ get_package_info(args.package, branch=args.branch,
pending=args.pending, extra=args.noextra)
elif action == "list":
@@ -928,8 +926,9 @@ def main():
log.info("package : {0}".format(args.package))
log.info("branch : {0}".format(args.branch))
log.info("acl : {0}".format(args.action))
- toggle_acl(args.package, args.action, args.branch,
- arg.username, arg.password)
+ toggle_acl(args.package, action=args.action,
+ branch=args.branch,
+ username=arg.username, password=arg.password)
elif action == "update":
log.info("user : {0}".format(arg.username))
12 years, 10 months
[packagedb-cli] Enables the request of all ACLs on all branches.
by Pierre-YvesChibon
commit 65cc8cf632d73a0427fde4ff2a63cf91832e79cc
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Mon Jun 20 09:18:00 2011 +0200
Enables the request of all ACLs on all branches.
We now have functional:
- pkgdb-cli request <package> all all
- pkgdb-cli request <package> all <branch>
- pkgdb-cli request <package> <action> all
Documentation has also been updated to reflect that the "request" action can also be used to make obsolete a request.
pkgdb.py | 102 +++++++++++++++++++++++++++++++++++++-------------------------
1 files changed, 61 insertions(+), 41 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index c34c1ff..b5de2d2 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -295,6 +295,32 @@ def _answer_acl(action, user, packagename, answer, branch):
" so?".format(answer)
+def _toggle_one_acl(packagename, action, branch):
+ """
+ Request for an action on a specific branch for a specific package.
+
+ :arg packagename is the name of the package for which you would like
+ to request an ACL.
+ :arg action is action which is requested for this package, actions
+ allowed are: [watchbugzilla, watchcommit, commit, approveacls]
+ :arg branch name of the branch for which to toggle the ACL.
+ """
+ packageid = _get_package_id(packagename, branch)
+ log.debug(
+ "Toggle acl '{0}' for user {1} and package {2} on branch {3}".format(
+ action, pkgdbclient.username, packagename, branch))
+ params = {'container_id': '{0}:{1}'.format(packageid, action)}
+ pkgdbinfo = pkgdbclient.send_request(
+ '/acls/dispatcher/toggle_acl_request',
+ auth=True, req_params=params)
+ log.debug(pkgdbinfo)
+ if 'aclStatus' in pkgdbinfo.keys():
+ msg = pkgdbinfo['aclStatus']
+ else:
+ msg = pkgdbinfo['message']
+ return msg
+
+
def get_packages(motif=None, name_only=False):
"""
Retrieve the list of all packages in packagedb.
@@ -556,58 +582,52 @@ def toggle_acl(packagename, action, branch='devel', username=None,
if branch is None:
branch = 'devel'
- if action not in actionlist and action != 'all':
- raise ActionError("Action '{0}' is not in the list: {1},all".format(
- action, ",".join(actionlist)))
- _get_client_authentified(username=username, password=password)
- packageid = _get_package_id(packagename, branch)
+ if branch == 'all':
+ branches = _get_active_branches()
+ else:
+ branches = [branch]
- # if action == 'all' then we toggle all the ACLs
- if action == 'all':
- log.debug("Toggle all acl for user: {0}".format(pkgdbclient.username))
- for action in actionlist:
- log.debug(
- "Toggle acl {0} for user {1} and package {2} on branch {3}".format(
- action, pkgdbclient.username, packagename, branch))
- params = {'container_id': '{0}:{1}'.format(packageid, action)}
- pkgdbinfo = pkgdbclient.send_request(
- '/acls/dispatcher/toggle_acl_request',
- auth=True, req_params=params)
- log.debug(pkgdbinfo)
- if 'aclStatus' in pkgdbinfo.keys():
- msg = pkgdbinfo['aclStatus']
- else:
- msg = pkgdbinfo['message']
- log.info(
- "{0}{1}{2} for {3} on package {4} branch {5}".format(
+ _get_client_authentified(username=username, password=password)
+ for branch in branches:
+ if action not in actionlist and action != 'all':
+ raise ActionError("Action '{0}' is not in the list: {1},all".format(
+ action, ",".join(actionlist)))
+
+ msg = ""
+ # if action == 'all' then we toggle all the ACLs
+ if action == 'all':
+ log.debug("Toggle all acl for user: {0}".format(pkgdbclient.username))
+ for action in actionlist:
+ try:
+ msg = _toggle_one_acl(packagename, action, branch)
+ except ServerError, er:
+ log.info("Could not toggle acl '{0}' for branch '{1}'".format(
+ action, branch))
+ log.debug(er)
+ if msg != "":
+ print "{0}{1}{2} for {3} on package {4} branch {5}".format(
bold,
msg,
reset,
pkgdbclient.username,
packagename,
- branch))
- # else we toggle only the given one
- else:
- log.debug(
- "Toggle acl {0} for user {1} and package {2} on branch {3}".format(
- action, pkgdbclient.username, packagename, branch))
- params = {'container_id': '{0}:{1}'.format(packageid, action)}
- pkgdbinfo = pkgdbclient.send_request(
- '/acls/dispatcher/toggle_acl_request',
- auth=True, req_params=params)
- log.debug(pkgdbinfo)
- if 'aclStatus' in pkgdbinfo.keys():
- msg = pkgdbinfo['aclStatus']
+ branch)
+ # else we toggle only the given one
else:
- msg = pkgdbinfo['message']
- log.info(
- "{0}{1}{2} for {3} on package {4} branch {5}".format(
+ try:
+ msg = _toggle_one_acl(packagename, action, branch)
+ except ServerError, er:
+ log.info("Could not toggle acl '{0}' for branch '{1}'".format(
+ action, branch))
+ log.debug(er)
+ if msg != "":
+ print "{0}{1}{2} for {3} on package {4} branch {5}".format(
bold,
msg,
reset,
pkgdbclient.username,
packagename,
- branch))
+ branch)
def answer_acl_request(packagename, action, user, answer, branch=None,
@@ -797,7 +817,7 @@ def setup_action_parser(action, last_args=None):
elif action == "request":
parser.add_argument('package', help="Name of the package")
parser.add_argument("action",
- help="Request a specific ACL for this package " \
+ help="Request (or obsolete a request) for specific ACL on this package " \
"(actions are '{0}', 'all')".format("', '".join(actionlist)))
parser.add_argument('branch', default='devel', nargs="?",
help="Branch of the package for which the ACL is " \
12 years, 10 months
[packagedb-cli] Bug fix in layout
by Pierre-YvesChibon
commit eea52b48c00a8b9fefc722f45ddfce953eb90092
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Mon Jun 20 08:58:21 2011 +0200
Bug fix in layout
- Was causing: "Error: tuple index out of range"
- refers to #6
pkgdb.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 3d3df68..c34c1ff 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -579,7 +579,7 @@ def toggle_acl(packagename, action, branch='devel', username=None,
else:
msg = pkgdbinfo['message']
log.info(
- "{0}{1}{3} for {4} on package {5} branch {6}".format(
+ "{0}{1}{2} for {3} on package {4} branch {5}".format(
bold,
msg,
reset,
@@ -601,7 +601,7 @@ def toggle_acl(packagename, action, branch='devel', username=None,
else:
msg = pkgdbinfo['message']
log.info(
- "{0}{1}{2}{3} for {4} on package {5} branch {6}".format(
+ "{0}{1}{2} for {3} on package {4} branch {5}".format(
bold,
msg,
reset,
12 years, 10 months
[packagedb-cli] Fix indentation issue in --nocolor
by Pierre-YvesChibon
commit e0fcee04db6843d71f18260e6b8251c5c20be29e
Author: Pierre-Yves Chibon py(a)chibon.fr <pingou(a)pingoured.fr>
Date: Thu Jun 16 15:19:38 2011 +0200
Fix indentation issue in --nocolor
red, bold and reset should not have any length as by default they are not seen.
Fixes #4
pkgdb.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/pkgdb.py b/pkgdb.py
index 8635918..3d3df68 100755
--- a/pkgdb.py
+++ b/pkgdb.py
@@ -45,9 +45,9 @@ elif '--verbose' in sys.argv:
log.setLevel(logging.INFO)
if '--nocolor' in sys.argv:
- red = " "
- bold = " "
- reset = " "
+ red = ""
+ bold = ""
+ reset = ""
cmdlist = ['acl', 'list', 'request', 'update', 'orphan']
actionlist = ['watchbugzilla', 'watchcommits', 'commit', 'approveacls']
12 years, 10 months