本文整理汇总了Python中bugzilla.Bugz类的典型用法代码示例。如果您正苦于以下问题:Python Bugz类的具体用法?Python Bugz怎么用?Python Bugz使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bugz类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, base, user = None, password = None, forget = False,
columns = 0, encoding = '', skip_auth = False,
quiet = False, httpuser = None, httppassword = None ):
self.quiet = quiet
self.columns = columns or terminal_width()
cp = ConfigParser()
cp.read(os.path.expanduser('~/.pybugz'))
defrepo = cp.get('Settings', 'default')
if not base:
base = cp.get(defrepo, 'url')
if not user:
user = cp.get(defrepo, 'user')
password = cp.get(defrepo, 'password')
Bugz.__init__(self, base, user, password, forget, skip_auth, httpuser, httppassword)
self.log("Using %s " % self.base)
if not encoding:
try:
self.enc = locale.getdefaultlocale()[1]
except:
self.enc = 'utf-8'
if not self.enc:
self.enc = 'utf-8'
else:
self.enc = encoding
示例2: search
def search(self, *args, **kwds):
"""Performs a search on the bugzilla database with the keywords given on the title (or the body if specified).
"""
search_term = ' '.join(args).strip()
show_url = kwds['show_url']
del kwds['show_url']
search_opts = sorted([(opt, val) for opt, val in kwds.items()
if val != None and opt != 'order'])
if not (search_term or search_opts):
raise BugzError('Please give search terms or options.')
if search_term:
log_msg = 'Searching for \'%s\' ' % search_term
else:
log_msg = 'Searching for bugs '
if search_opts:
self.log(log_msg + 'with the following options:')
for opt, val in search_opts:
self.log(' %-20s = %s' % (opt, val))
else:
self.log(log_msg)
result = Bugz.search(self, search_term, **kwds)
if result == None:
raise RuntimeError('Failed to perform search')
if len(result) == 0:
self.log('No bugs found.')
return
self.listbugs(result, show_url)
示例3: attach
def attach(self, bugid, filename, content_type = 'text/plain', description = None):
""" Attach a file to a bug given a filename. """
if not os.path.exists(filename):
raise BugzError('File not found: %s' % filename)
if not description:
description = block_edit('Enter description (optional)')
result = Bugz.attach(self, bugid, filename, description, filename,
content_type)
示例4: namedcmd
def namedcmd(self, command, show_status=False, show_url=False):
"""Run a command stored in Bugzilla by name."""
log_msg = 'Running namedcmd \'%s\''%command
result = Bugz.namedcmd(self, command)
if result is None:
raise RuntimeError('Failed to run command\nWrong namedcmd perhaps?')
if len(result) == 0:
self.log('No result from command')
return
self.listbugs(result, show_url, show_status)
示例5: __init__
def __init__(self, base, user = None, password =None, forget = False,
columns = 0, encoding = '', skip_auth = False,
quiet = False, httpuser = None, httppassword = None ):
self.quiet = quiet
self.columns = columns or terminal_width()
Bugz.__init__(self, base, user, password, forget, skip_auth, httpuser, httppassword)
self.log("Using %s " % self.base)
if not encoding:
try:
self.enc = locale.getdefaultlocale()[1]
except:
self.enc = 'utf-8'
if not self.enc:
self.enc = 'utf-8'
else:
self.enc = encoding
示例6: attach
def attach(self, bugid, filename, content_type = 'text/plain', patch = False, description = None):
""" Attach a file to a bug given a filename. """
if not os.path.exists(filename):
raise BugzError('File not found: %s' % filename)
if not description:
description = block_edit('Enter description (optional)')
result = Bugz.attach(self, bugid, filename, description, filename,
content_type, patch)
if result == True:
self.log("'%s' has been attached to bug %s" % (filename, bugid))
else:
reason = ""
if result and result != False:
reason = "\nreason: %s" % result
raise RuntimeError("Failed to attach '%s' to bug %s%s" % (filename,
bugid, reason))
示例7: attachment
def attachment(self, attachid, view = False):
""" Download or view an attachment given the id."""
self.log('Getting attachment %s' % attachid)
result = Bugz.attachment(self, attachid)
if not result:
raise RuntimeError('Unable to get attachment')
action = {True:'Viewing', False:'Saving'}
self.log('%s attachment: "%s"' % (action[view], result['filename']))
safe_filename = os.path.basename(re.sub(r'\.\.', '',
result['filename']))
if view:
print result['fd'].read()
else:
if os.path.exists(result['filename']):
raise RuntimeError('Filename already exists')
open(safe_filename, 'wb').write(result['fd'].read())
示例8: get
def get(self, bugid, comments = True, attachments = True):
""" Fetch bug details given the bug id """
self.log('Getting bug %s ..' % bugid)
result = Bugz.get(self, bugid)
if result is None:
raise RuntimeError('Bug %s not found' % bugid)
# Print out all the fields below by extract the text
# directly from the tag, and just ignore if we don't
# see the tag.
FIELDS = (
('short_desc', 'Title'),
('assigned_to', 'Assignee'),
('creation_ts', 'Reported'),
('delta_ts', 'Updated'),
('bug_status', 'Status'),
('resolution', 'Resolution'),
('bug_file_loc', 'URL'),
('bug_severity', 'Severity'),
('priority', 'Priority'),
('reporter', 'Reporter'),
)
MORE_FIELDS = (
('product', 'Product'),
('component', 'Component'),
('status_whiteboard', 'Whiteboard'),
('keywords', 'Keywords'),
)
for field, name in FIELDS + MORE_FIELDS:
try:
value = result.find('.//%s' % field).text
if value is None:
continue
except AttributeError:
continue
print '%-12s: %s' % (name, value.encode(self.enc))
# Print out the cc'ed people
cced = result.findall('.//cc')
for cc in cced:
print '%-12s: %s' % ('CC', cc.text)
# print out depends
dependson = ', '.join([d.text for d in result.findall('.//dependson')])
blocked = ', '.join([d.text for d in result.findall('.//blocked')])
if dependson:
print '%-12s: %s' % ('DependsOn', dependson)
if blocked:
print '%-12s: %s' % ('Blocked', blocked)
bug_comments = result.findall('.//long_desc')
bug_attachments = result.findall('.//attachment')
print '%-12s: %d' % ('Comments', len(bug_comments))
print '%-12s: %d' % ('Attachments', len(bug_attachments))
print
if attachments:
for attachment in bug_attachments:
aid = attachment.find('.//attachid').text
desc = attachment.find('.//desc').text
when = attachment.find('.//date').text
print '[Attachment] [%s] [%s]' % (aid, desc.encode(self.enc))
if comments:
i = 0
wrapper = textwrap.TextWrapper(width = self.columns)
for comment in bug_comments:
try:
who = comment.find('.//who').text.encode(self.enc)
except AttributeError:
# Novell doesn't use 'who' on xml
who = ""
when = comment.find('.//bug_when').text.encode(self.enc)
what = comment.find('.//thetext').text
print '\n[Comment #%d] %s : %s' % (i, who, when)
print '-' * (self.columns - 1)
if what is None:
what = ''
# print wrapped version
for line in what.split('\n'):
if len(line) < self.columns:
print line.encode(self.enc)
else:
for shortline in wrapper.wrap(line):
print shortline.encode(self.enc)
i += 1
print
示例9: block_edit
if 'comment_editor' in kwds:
if kwds['comment_editor']:
kwds['comment'] = block_edit('Enter comment:')
del kwds['comment_editor']
if kwds['fixed']:
kwds['status'] = 'RESOLVED'
kwds['resolution'] = 'FIXED'
del kwds['fixed']
if kwds['invalid']:
kwds['status'] = 'RESOLVED'
kwds['resolution'] = 'INVALID'
del kwds['invalid']
result = Bugz.modify(self, bugid, **kwds)
if not result:
raise RuntimeError('Failed to modify bug')
else:
self.log('Modified bug %s with the following fields:' % bugid)
for field, value in result:
self.log(' %-12s: %s' % (field, value))
def attachment(self, attachid, view = False):
""" Download or view an attachment given the id."""
self.log('Getting attachment %s' % attachid)
result = Bugz.attachment(self, attachid)
if not result:
raise RuntimeError('Unable to get attachment')