diff --git a/ChangeLog b/ChangeLog index a7bae5b..89a1dc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 ----- diff --git a/README.rst b/README.rst index 154456c..5c87f51 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/rtcclient/client.py b/rtcclient/client.py index 2b70c4b..5012f28 100644 --- a/rtcclient/client.py +++ b/rtcclient/client.py @@ -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 @@ -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 @@ -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 @@ -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") @@ -77,7 +93,8 @@ 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") @@ -85,11 +102,21 @@ def _get_headers(self): 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 @@ -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]) @@ -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_id) + raise exception.NotFound("Not found " % workitem_id) def getWorkitems(self, projectarea_id=None, projectarea_name=None, returned_properties=None, archived=False): diff --git a/setup.cfg b/setup.cfg index 60dc37a..db28af6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = rtcclient author = Di Xu -version = 0.4.0 +version = 0.5.0 author_email = stephenhsu90@gmail.com summary = RTCClient for Rational Team Concert description-file = README.rst