forked from pool/bugzilla
Accepting request 915179 from home:StevenK:branches:devel:tools:scm
- Add modernize-bugzilla-submit.patch: - Port bugzilla-submit to Python 3. OBS-URL: https://build.opensuse.org/request/show/915179 OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/bugzilla?expand=0&rev=24
This commit is contained in:
parent
b48c9bbed7
commit
51295d2c6e
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 31 06:31:13 UTC 2021 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Add modernize-bugzilla-submit.patch:
|
||||
- Port bugzilla-submit to Python 3.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Dec 13 11:12:55 UTC 2020 - ecsos <ecsos@opensuse.org>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package bugzilla
|
||||
#
|
||||
# Copyright (c) 2020 SUSE LLC
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -29,6 +29,7 @@ Source3: MPL-2.0.html
|
||||
Source4: %{name}.conf
|
||||
Source5: %{name}-rpmlintrc
|
||||
Patch1: fix_whine_error.patch
|
||||
Patch2: modernize-bugzilla-submit.patch
|
||||
BuildRequires: apache-rpm-macros
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: pkgconfig(systemd)
|
||||
@ -123,9 +124,8 @@ This subpackage contains the Apache configuration files
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1
|
||||
%autopatch -p1
|
||||
# rpmlint
|
||||
sed -i -e 's|\/usr\/bin\/env python|\/usr\/bin\/python|g' contrib/bugzilla-submit/bugzilla-submit
|
||||
sed -i -e 's|\/usr\/bin\/env perl|\/usr\/bin\/perl|g' contrib/perl-fmt
|
||||
#
|
||||
tar -xzf %{SOURCE2} --directory "template"
|
||||
|
88
modernize-bugzilla-submit.patch
Normal file
88
modernize-bugzilla-submit.patch
Normal file
@ -0,0 +1,88 @@
|
||||
Index: bugzilla-5.0.6/contrib/bugzilla-submit/bugzilla-submit
|
||||
===================================================================
|
||||
--- bugzilla-5.0.6.orig/contrib/bugzilla-submit/bugzilla-submit
|
||||
+++ bugzilla-5.0.6/contrib/bugzilla-submit/bugzilla-submit
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env python
|
||||
+#!/usr/bin/python3
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
@@ -26,16 +26,12 @@ def error(m):
|
||||
sys.stderr.flush()
|
||||
sys.exit(1)
|
||||
|
||||
-version = string.split(string.split(sys.version)[0], ".")[:2]
|
||||
-if map(int, version) < [2, 3]:
|
||||
- error("you must upgrade to Python 2.3 or higher to use this script.")
|
||||
+import urllib.request, urllib.parse, urllib.error, re, os, netrc, email.Parser, optparse
|
||||
|
||||
-import urllib, re, os, netrc, email.Parser, optparse
|
||||
-
|
||||
-class ErrorURLopener(urllib.URLopener):
|
||||
+class ErrorURLopener(urllib.request.URLopener):
|
||||
"""URLopener that handles HTTP 404s"""
|
||||
def http_error_404(self, url, fp, errcode, errmsg, headers, *extra):
|
||||
- raise ValueError, errmsg # 'File Not Found'
|
||||
+ raise ValueError(errmsg) # 'File Not Found'
|
||||
|
||||
# Set up some aliases -- partly to hide the less friendly fieldnames
|
||||
# behind the names actually used for them in the stock web page presentation,
|
||||
@@ -59,7 +55,7 @@ def header_to_field(hdr):
|
||||
return hdr
|
||||
|
||||
def field_to_header(hdr):
|
||||
- hdr = "-".join(map(lambda x: x.capitalize(), hdr.split("_")))
|
||||
+ hdr = "-".join([x.capitalize() for x in hdr.split("_")])
|
||||
for (alias, name) in field_aliases:
|
||||
if hdr == name:
|
||||
hdr = alias
|
||||
@@ -114,9 +110,9 @@ def get_credentials(bugzilla):
|
||||
authenticate_on = '"' + bugzilla + '"'
|
||||
try:
|
||||
credentials = netrc.netrc()
|
||||
- except netrc.NetrcParseError, e:
|
||||
+ except netrc.NetrcParseError as e:
|
||||
error("ill-formed .netrc: %s:%s %s" % (e.filename, e.lineno, e.msg))
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
error("missing .netrc file %s" % str(e).split()[-1])
|
||||
ret = credentials.authenticators(authenticate_on)
|
||||
if not ret:
|
||||
@@ -177,12 +173,11 @@ def validate_fields(data):
|
||||
legal_fields = required_fields + (
|
||||
"assigned_to", "cc", "keywords", "dependson", "blocked",
|
||||
)
|
||||
- my_fields = data.keys()
|
||||
- for field in my_fields:
|
||||
+ for field in data:
|
||||
if field not in legal_fields:
|
||||
error("invalid field: %s" % field_to_header(field))
|
||||
for field in required_fields:
|
||||
- if field not in my_fields:
|
||||
+ if field not in data:
|
||||
error("required field missing: %s" % field_to_header(field))
|
||||
|
||||
if not data['short_desc']:
|
||||
@@ -197,7 +192,7 @@ def validate_fields(data):
|
||||
|
||||
def submit_bug_POST(bugzilla, data):
|
||||
# Move the request over the wire
|
||||
- postdata = urllib.urlencode(data)
|
||||
+ postdata = urllib.parse.urlencode(data)
|
||||
try:
|
||||
url = ErrorURLopener().open("%s/post_bug.cgi" % bugzilla, postdata)
|
||||
except ValueError:
|
||||
@@ -270,10 +265,10 @@ def check_result_POST(ret, data):
|
||||
"is Bugzilla instance's top-level directory?" % bugzilla)
|
||||
m = re.search("Bug ([0-9]+) Submitted", ret)
|
||||
if not m:
|
||||
- print ret
|
||||
+ print(ret)
|
||||
error("Internal error: bug id not found; please report a bug")
|
||||
id = m.group(1)
|
||||
- print "Bug %s posted." % id
|
||||
+ print("Bug %s posted." % id)
|
||||
|
||||
#
|
||||
#
|
Loading…
Reference in New Issue
Block a user