add debug function to checkrepo
This commit is contained in:
parent
28231bd19d
commit
df1a2a0f9f
@ -392,7 +392,7 @@ def do_check_repo(self, subcmd, opts, *args):
|
|||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.checkrepo = CheckRepo(self.get_api_url(), opts.project, readonly = opts.dry)
|
self.checkrepo = CheckRepo(self.get_api_url(), opts.project, readonly = opts.dry, debug=opts.verbose)
|
||||||
|
|
||||||
if opts.skip:
|
if opts.skip:
|
||||||
if not len(args):
|
if not len(args):
|
||||||
|
@ -21,6 +21,7 @@ import subprocess
|
|||||||
from urllib import quote_plus
|
from urllib import quote_plus
|
||||||
import urllib2
|
import urllib2
|
||||||
from xml.etree import cElementTree as ET
|
from xml.etree import cElementTree as ET
|
||||||
|
from pprint import pformat
|
||||||
|
|
||||||
from osc.core import get_binary_file
|
from osc.core import get_binary_file
|
||||||
from osc.core import http_DELETE
|
from osc.core import http_DELETE
|
||||||
@ -118,7 +119,7 @@ class Request(object):
|
|||||||
|
|
||||||
class CheckRepo(object):
|
class CheckRepo(object):
|
||||||
|
|
||||||
def __init__(self, apiurl, opensuse='Factory', readonly = False):
|
def __init__(self, apiurl, opensuse='Factory', readonly = False, debug = False):
|
||||||
"""CheckRepo constructor."""
|
"""CheckRepo constructor."""
|
||||||
self.apiurl = apiurl
|
self.apiurl = apiurl
|
||||||
self.opensuse = opensuse
|
self.opensuse = opensuse
|
||||||
@ -130,6 +131,12 @@ class CheckRepo(object):
|
|||||||
self.groups = {}
|
self.groups = {}
|
||||||
self._staging()
|
self._staging()
|
||||||
self.readonly = readonly
|
self.readonly = readonly
|
||||||
|
self.debug_enable = debug
|
||||||
|
|
||||||
|
def debug(self, *args):
|
||||||
|
if not self.debug_enable:
|
||||||
|
return
|
||||||
|
print ' '.join([ i if isinstance(i, basestring) else pformat(i) for i in args ])
|
||||||
|
|
||||||
def _staging(self):
|
def _staging(self):
|
||||||
"""Preload the groups of related request associated by the same
|
"""Preload the groups of related request associated by the same
|
||||||
@ -367,6 +374,8 @@ class CheckRepo(object):
|
|||||||
else:
|
else:
|
||||||
raise Exception('Please, provide a request_id or a request XML object.')
|
raise Exception('Please, provide a request_id or a request XML object.')
|
||||||
|
|
||||||
|
self.debug("check_specs", request_id)
|
||||||
|
|
||||||
# Check that only one action is allowed in the request.
|
# Check that only one action is allowed in the request.
|
||||||
actions = request.findall('action')
|
actions = request.findall('action')
|
||||||
if len(actions) > 1:
|
if len(actions) > 1:
|
||||||
@ -780,6 +789,7 @@ class CheckRepo(object):
|
|||||||
foundfailed = None
|
foundfailed = None
|
||||||
|
|
||||||
for repository in repos_to_check:
|
for repository in repos_to_check:
|
||||||
|
self.debug("checking repo", ET.tostring(repository))
|
||||||
isgood = True
|
isgood = True
|
||||||
founddisabled = False
|
founddisabled = False
|
||||||
r_foundbuilding = None
|
r_foundbuilding = None
|
||||||
@ -820,6 +830,7 @@ class CheckRepo(object):
|
|||||||
alldisabled = False
|
alldisabled = False
|
||||||
if isgood:
|
if isgood:
|
||||||
_goodrepo = (request.src_project, repository.attrib['name'])
|
_goodrepo = (request.src_project, repository.attrib['name'])
|
||||||
|
self.debug("good repo", _goodrepo)
|
||||||
if _goodrepo not in request.goodrepos:
|
if _goodrepo not in request.goodrepos:
|
||||||
request.goodrepos.append(_goodrepo)
|
request.goodrepos.append(_goodrepo)
|
||||||
result = True
|
result = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user