forked from python-bugzilla/python-bugzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.py
40 lines (33 loc) · 1.45 KB
/
create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
# create.py: Create a new bug report
import time
import bugzilla
# public test instance of bugzilla.redhat.com.
#
# Don't worry, changing things here is fine, and won't send any email to
# users or anything. It's what bugzilla.stage.redhat.com is for!
URL = "bugzilla.stage.redhat.com"
bzapi = bugzilla.Bugzilla(URL)
if not bzapi.logged_in:
print("This example requires cached login credentials for %s" % URL)
bzapi.interactive_login()
# Similar to build_query, build_createbug is a helper function that handles
# some bugzilla version incompatibility issues. All it does is return a
# properly formatted dict(), and provide friendly parameter names.
# The argument names map to those accepted by Bugzilla Bug.create:
# https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug
#
# The arguments specified here are mandatory, but there are many other
# optional ones like op_sys, platform, etc. See the docs
createinfo = bzapi.build_createbug(
product="Fedora",
version="rawhide",
component="python-bugzilla",
summary="new example python-bugzilla bug %s" % time.time(),
description="This is comment #0 of an example bug created by "
"the python-bugzilla.git examples/create.py script.")
newbug = bzapi.createbug(createinfo)
print("Created new bug id=%s url=%s" % (newbug.id, newbug.weburl))