Skip to content

Commit

Permalink
[LOG-10930] Python upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Dri0m authored Jun 8, 2021
2 parents bbd04b6 + 2fb13a1 commit 4c8b6fe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 125 deletions.
12 changes: 6 additions & 6 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class JIRA(object):
AGILE_BASE_URL = GreenHopperResource.AGILE_BASE_URL

def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=None, kerberos=False,
validate=False, get_server_info=True, async=False, logging=True, max_retries=3, proxies=None):
validate=False, get_server_info=True, use_async=False, logging=True, max_retries=3, proxies=None):
"""
Construct a JIRA client instance.
Expand Down Expand Up @@ -234,7 +234,7 @@ def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=N
as anononymous it will fail to instanciate.
:param get_server_info: If true it will fetch server version info first to determine if some API calls
are available.
:param async: To enable async requests for those actions where we implemented it, like issue update() or delete().
:param use_async: To enable async requests for those actions where we implemented it, like issue update() or delete().
Obviously this means that you cannot rely on the return code when this is enabled.
"""
# force a copy of the tuple to be used in __del__() because
Expand All @@ -252,8 +252,8 @@ def __init__(self, server=None, options=None, basic_auth=None, oauth=None, jwt=N

if server:
options['server'] = server
if async:
options['async'] = async
if use_async:
options['async'] = use_async

self.logging = logging

Expand Down Expand Up @@ -3171,8 +3171,8 @@ def move_to_backlog(self, issue_keys):

class GreenHopper(JIRA):

def __init__(self, options=None, basic_auth=None, oauth=None, async=None):
def __init__(self, options=None, basic_auth=None, oauth=None, use_async=None):
warnings.warn(
"GreenHopper() class is deprecated, just use JIRA() instead.", DeprecationWarning)
JIRA.__init__(
self, options=options, basic_auth=basic_auth, oauth=oauth, async=async)
self, options=options, basic_auth=basic_auth, oauth=oauth, use_async=use_async)
14 changes: 7 additions & 7 deletions jira/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ def _get_url(self, path):
options.update({'path': path})
return self._base_url.format(**options)

def update(self, fields=None, async=None, jira=None, notify=True, **kwargs):
def update(self, fields=None, use_async=None, jira=None, notify=True, **kwargs):
"""
Update this resource on the server. Keyword arguments are marshalled into a dict before being sent. If this
resource doesn't support ``PUT``, a :py:exc:`.JIRAError` will be raised; subclasses that specialize this method
will only raise errors in case of user error.
:param async: if true the request will be added to the queue so it can be executed later using async_run()
"""
if async is None:
async = self._options['async']
if use_async is None:
use_async = self._options['async']

data = {}
if fields is not None:
Expand Down Expand Up @@ -250,7 +250,7 @@ def update(self, fields=None, async=None, jira=None, notify=True, **kwargs):
# data['fields']['assignee'] = {'name': self._options['autofix']}
# EXPERIMENTAL --->
# import grequests
if async:
if use_async:
if not hasattr(self._session, '_async_jobs'):
self._session._async_jobs = set()
self._session._async_jobs.add(threaded_requests.put(
Expand Down Expand Up @@ -404,7 +404,7 @@ def __init__(self, options, session, raw=None):
if raw:
self._parse_raw(raw)

def update(self, fields=None, update=None, async=None, jira=None, notify=True, **fieldargs):
def update(self, fields=None, update=None, use_async=None, jira=None, notify=True, **fieldargs):
"""
Update this issue on the server.
Expand Down Expand Up @@ -453,7 +453,7 @@ def update(self, fields=None, update=None, async=None, jira=None, notify=True, *
else:
fields_dict[field] = value

super(Issue, self).update(async=async, jira=jira, notify=notify, fields=data)
super(Issue, self).update(use_async=use_async, jira=jira, notify=notify, fields=data)

def add_field_value(self, field, value):
"""
Expand Down Expand Up @@ -492,7 +492,7 @@ def __init__(self, options, session, raw=None):
if raw:
self._parse_raw(raw)

def update(self, fields=None, async=None, jira=None, body='', visibility=None):
def update(self, fields=None, use_async=None, jira=None, body='', visibility=None):
# TODO: fix the Resource.update() override mess
data = {}
if body:
Expand Down
123 changes: 11 additions & 112 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/usr/bin/env python
# import codecs


import os
import sys
import warnings

from pip.req import parse_requirements
# try: # for pip >= 10
# from pip._internal.req import parse_requirements
# except ImportError: # for pip <= 9.0.3
# from pip.req import parse_requirements

from setuptools import find_packages, setup

NAME = "jira"
Expand All @@ -13,7 +19,6 @@
if base_path not in sys.path:
sys.path.insert(0, base_path)


# this should help getting annoying warnings from inside distutils
warnings.simplefilter('ignore', UserWarning)

Expand Down Expand Up @@ -50,117 +55,11 @@ def read(fname):

def get_requirements(*path):
req_path = os.path.join(*path)
reqs = parse_requirements(req_path, session=False)
return [str(ir.req) for ir in reqs]

# class PyTest(TestCommand):
# user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
#
# def initialize_options(self):
# TestCommand.initialize_options(self)
# self.pytest_args = []
#
# logging.basicConfig(format='%(levelname)-10s %(message)s')
# logging.getLogger("jira").setLevel(logging.INFO)
#
# # if we have pytest-cache module we enable the test failures first mode
# try:
# import pytest_cache # noqa
# self.pytest_args.append("--ff")
# except ImportError:
# pass
#
# if sys.stdout.isatty():
# # when run manually we enable fail fast
# self.pytest_args.append("--maxfail=1")
# try:
# import coveralls # noqa
# self.pytest_args.append("--cov=%s" % NAME)
# self.pytest_args.extend(["--cov-report", "term"])
# self.pytest_args.extend(["--cov-report", "xml"])
#
# except ImportError:
# pass
#
# def finalize_options(self):
# TestCommand.finalize_options(self)
# self.test_args = []
# self.test_suite = True
#
# def run_tests(self):
# # before running tests we need to run autopep8
# try:
# saved_argv = sys.argv
# sys.argv = "-r --in-place jira/ tests/ examples/".split(" ")
# runpy.run_module('autopep8')
# sys.argv = saved_argv # restore sys.argv
# except subprocess.CalledProcessError:
# logging.warning('autopep8 is not installed so '
# 'it will not be run')
# # import here, cause outside the eggs aren't loaded
# import pytest
# errno = pytest.main(self.pytest_args)
# sys.exit(errno)


# class Release(Command):
# user_options = []
#
# def initialize_options(self):
# # Command.initialize_options(self)
# pass
#
# def finalize_options(self):
# # Command.finalize_options(self)
# pass
#
# def run(self):
# import json
# try:
# from urllib.request import urlopen
# except ImportError:
# from urllib2 import urlopen
# response = urlopen(
# "https://pypi.python.org/pypi/%s/json" % NAME)
# data = json.load(codecs.getreader("utf-8")(response))
# released_version = data['info']['version']
# if released_version == __version__:
# raise RuntimeError(
# "This version was already released, remove it from PyPi if you want "
# "to release it again or increase the version number. https://pypi.python.org/pypi/%s/" % NAME)
# elif released_version > __version__:
# raise RuntimeError("Cannot release a version (%s) smaller than the PyPI current release (%s)." % (
# __version__, released_version))
#
#
# class PreRelease(Command):
# user_options = []
#
# def initialize_options(self):
# # Command.initialize_options(self)
# pass
#
# def finalize_options(self):
# # Command.finalize_options(self)
# pass
#
# def run(self):
# import json
# try:
# from urllib.request import urlopen
# except ImportError:
# from urllib2 import urlopen
# response = urlopen(
# "https://pypi.python.org/pypi/%s/json" % NAME)
# data = json.load(codecs.getreader("utf-8")(response))
# released_version = data['info']['version']
# if released_version >= __version__:
# raise RuntimeError(
# "Current version of the package is equal or lower than the "
# "already published ones (PyPi). Increse version to be able to pass prerelease stage.")
with open(req_path) as f:
return f.read().strip().split('\n')

if __name__ == '__main__':

if __name__ == '__main__':
setup(
name=NAME,
# cmdclass={'release': Release, 'prerelease': PreRelease},
Expand All @@ -176,7 +75,7 @@ def get_requirements(*path):
'shell': ['ipython>=0.13']},
entry_points={
'console_scripts':
['jirashell = jira.jirashell:main']},
['jirashell = jira.jirashell:main']},

long_description=open("README.rst").read(),
provides=[NAME],
Expand Down

0 comments on commit 4c8b6fe

Please sign in to comment.