Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ready for 0.5.0 #69

Merged
merged 4 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
CHANGES
=======

0.4.0
-----

* ready for 0.4.0
* add badge for travis ci
* fix bugs across different python versions
* remove error line
* fix bugs on python3.3
* fix travis ci
* add travis ci
* fix pep8 errors
* update rtcclient introduction
* remove parent workitem
* fix bug when adding child(ren) and add method to remove child(ren)
* add DELETE method in class Base
* update REAME
* add children workitems
* add parent workitem
* add children workitems
* add parent workitem
* get changesets
* add testcases for get children/parent workitems
* get parent/children workitems
* add tests for get includedinbuilds
* add includedinbuild fixture
* Get IncludedInBuilds
* query workitems using query id
* update ChangeLog for 0.3.0

0.3.0
-----

Expand Down
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ Team Areas, Workitems) into easily managed Python objects:
>>> from rtcclient.utils import setup_basic_logging
>>> from rtcclient.client import RTCClient
# you can remove this if you don't need logging
# default logging for console output
# default debug logging for console output
>>> setup_basic_logging()
# url ends with jazz
>>> url = "https://your_domain:9443/jazz"
>>> username = "your_username"
>>> password = "your_password"
>>> myclient = RTCClient(url, username, password)
# if your url ends with ccm, set ends_with_jazz to False
# refer to issue #68 for detailed explanation
>>> myclient = RTCClient(url, username, password, ends_with_jazz=True)
# it will be faster if returned properties is specified
# see in below query example
>>> wk = myclient.getWorkitem(123456) # get a workitem whose id is 123456
Expand Down
43 changes: 35 additions & 8 deletions rtcclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class RTCClient(RTCBase):
:param searchpath: the folder to store your templates.
If `None`, the default search path
(/your/site-packages/rtcclient/templates) will be loaded.
:param ends_with_jazz: (optional) Set to `True` (default) if
the url ends with 'jazz', otherwise to `False` if with 'ccm'
(Refer to issue #68 for details)
:type ends_with_jazz: bool

Tips: You can also customize your preferred properties to be returned
by specified `returned_properties` when the called methods have
Expand All @@ -40,7 +44,8 @@ class RTCClient(RTCBase):

log = logging.getLogger("client.RTCClient")

def __init__(self, url, username, password, searchpath=None):
def __init__(self, url, username, password, searchpath=None,
ends_with_jazz=True):
"""Initialization

See params above
Expand All @@ -49,6 +54,11 @@ def __init__(self, url, username, password, searchpath=None):
self.username = username
self.password = password
RTCBase.__init__(self, url)

if not isinstance(ends_with_jazz, bool):
raise exception.BadValue("ends_with_jazz is not boolean")

self.jazz = ends_with_jazz
self.headers = self._get_headers()
if searchpath is None:
self.searchpath = _search_path
Expand All @@ -64,10 +74,16 @@ def get_rtc_obj(self):
return self

def _get_headers(self):
if self.jazz is True:
_allow_redirects = True
else:
_allow_redirects = False

_headers = {"Content-Type": self.CONTENT_XML}
resp = self.get(self.url + "/authenticated/identity",
verify=False,
headers=_headers)
headers=_headers,
allow_redirects=_allow_redirects)

_headers["Content-Type"] = self.CONTENT_URL_ENCODED
_headers["Cookie"] = resp.headers.get("set-cookie")
Expand All @@ -77,19 +93,30 @@ def _get_headers(self):
resp = self.post(self.url + "/authenticated/j_security_check",
data=credentials,
verify=False,
headers=_headers)
headers=_headers,
allow_redirects=_allow_redirects)

# authfailed
authfailed = resp.headers.get("x-com-ibm-team-repository-web-auth-msg")
if authfailed == "authfailed":
raise exception.RTCException("Authentication Failed: "
"Invalid username or password")

# fix issue #68
if not _allow_redirects:
_headers["Cookie"] = resp.headers.get("set-cookie")

resp = self.get(self.url + "/authenticated/identity",
verify=False,
headers=_headers)
headers=_headers,
allow_redirects=_allow_redirects)

# fix issue #68
if not _allow_redirects:
_headers["Cookie"] += "; " + resp.headers.get("set-cookie")
else:
_headers["Cookie"] = resp.headers.get("set-cookie")

_headers["Cookie"] = resp.headers.get("set-cookie")
_headers["Accept"] = self.CONTENT_XML
return _headers

Expand Down Expand Up @@ -845,11 +872,11 @@ def getWorkitem(self, workitem_id, returned_properties=None):

try:
if isinstance(workitem_id, bool):
raise ValueError()
raise ValueError("Invalid Workitem id")
if isinstance(workitem_id, six.string_types):
workitem_id = int(workitem_id)
if not isinstance(workitem_id, int):
raise ValueError()
raise ValueError("Invalid Workitem id")

workitem_url = "/".join([self.url,
"oslc/workitems/%s" % workitem_id])
Expand Down Expand Up @@ -878,7 +905,7 @@ def getWorkitem(self, workitem_id, returned_properties=None):
raise exception.BadValue(excp_msg)
except Exception as excp:
self.log.error(excp)
raise exception.NotFound("Not found <Workitem %s>", workitem_id)
raise exception.NotFound("Not found <Workitem %s>" % workitem_id)

def getWorkitems(self, projectarea_id=None, projectarea_name=None,
returned_properties=None, archived=False):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = rtcclient
author = Di Xu
version = 0.4.0
version = 0.5.0
author_email = [email protected]
summary = RTCClient for Rational Team Concert
description-file = README.rst
Expand Down