Skip to content

Commit f83ced7

Browse files
committed
tested using Python 3.11.4
1 parent e900814 commit f83ced7

23 files changed

+2100
-2087
lines changed

README.md

+42-38
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
What's New?
1414
===========
1515

16+
0.21.0 16-Aug-2023
17+
* tested with Python 3.11.4 - worked OOTB. Now developing using 3.11.4 - won't be back-tested with older Pythons but should work back to 3.9 at least.
18+
1619
0.20.0 4-May-2023
1720
* Deprecated RM load_folders() - use find_folder() instead.
1821
* Added RM create_folder() - this doesn't require doing a forced reload of all folders, because it inserts the new folder into the internal info about folders
@@ -41,66 +44,59 @@ There are links to these examples below.
4144
Installation
4245
============
4346

44-
Requirements:
45-
46-
This version has been tested with:
47-
* Python 3.9.1 x64 on Windows 10 x64**.
48-
* Python 3.9.6 x64 on CentOS (Redhat) 8.4
49-
50-
The only version constraint of the requirements is on Windows that requests==2.24.0 and urllib3==1.25.11 - On Windows there seems to be a problem with requests>=2.25.0 (latest is 2.26.0) when using Fiddler proxy on port 8888.
51-
52-
The move to Python 3.9 was relatively recent - this code may work with 3.8.x and possibly earlier versions. Trying to install with Python 3.10 using `pip` failed when getting `lxml` - there may be other problems as didn't get past this.
53-
54-
The content on github is at https://github.com/IBM/ELM-Python-Client
55-
56-
NOTE: the python package installed is call `elmclient`
47+
Either method of install described below installs the elmclient package and puts example commands (such as `oslcquery` into your path so a) they can be run simply by typing the command, e.g. `oslcquery` and b) as you edit the source code these commands automatically use the latest code.
5748

58-
If you need to install Python, on Windows you can download the Python 3.9.* installer exe from python.org and then use this command to silently install so python is on your path (modifying to reflect the installer exe you have downloaded):
49+
Requirements: Python 3.11/3.10/3.9 - NOTE I'm developing using Python 3.11.4 and compatibility with older versions is NOT checked.
5950

60-
* python-3.9.6-amd64.exe /quiet InstallAllUsers=1 TargetDir=c:\Python39 PrependPath=1 Include_test=0
51+
Overview
52+
--------
6153

62-
Then exit and start a new command shell and python will be on your path.
54+
Step 1: Install Python so it can be run from a command prompt
55+
Either Step 2a: Quickest and easiest to get started: install elmclient from pypi
56+
Or Step 2b: If you want to change elmclient code
6357

64-
FIRST option for `elmclient` is to install from the github.com zip:
58+
Step 1
59+
------
6560

66-
Download the github zip:
61+
Install Python so you can run Python from the commandline - might be python3 if you're on *nix. On Windows the command is `python` - you can find install guides all over the internet.
6762

68-
* wget https://github.com/IBM/ELM-Python-Client/archive/refs/heads/master.zip
63+
Step 2a - Quickest and easiest to just use elmclient
64+
----------------------------------------------------
6965

70-
Unzip to its own folder and open a command prompt in that folder.
66+
This method is also easiest to update with new versions of elmclient.
7167

72-
Either, install using:
68+
at a command prompt:
69+
* for Windows type `pip install elmclient`
70+
* For *nix use `pip3 install elmclient`
7371

74-
```
75-
python setup.py install
76-
```
72+
To update:
73+
* for Windows type `pip install -U elmclient`
74+
* For *nix use `pip3 install -U elmclient`
7775

78-
This adds the example commands (e.g. `oslcquery`) to the Python Scripts folder - if this folder is in the path you can use the command from anywhere.
76+
Using this method you could copy the examples from where they're lurking in your Python installation's library to a different folder, rename if using one of the commands such as oslcquery to a different name, and edit them in this folder separate from the elmclient install.
7977

78+
Test that all was successful by running `oslcquery -h` you should get a version number then a swathe of text with all the options.
8079

81-
Or, if you want to run from source because you want to modify the code then download the github zip then you can extract it to a directory of your choice and install as an editable package by opening a command prompt in the directory and using the command:
8280

83-
```
84-
pip install -e .
85-
```
81+
Step 2b - If you want to edit the code in elmclient
82+
---------------------------------------------------
8683

87-
This installs the elmclient and puts example commands into your scripts so a) they can be run simply by typing the command, e.g. `oslcquery` and b) as you edit the source code these commands automatically use the latest code.
84+
This method assumes you have developer knowledge how to modify and merge code.
8885

86+
By far the preferred method is to first fork the github repository. You'll then get a folder on your PC which has a sub-folder `elmclient'.
8987

90-
SECOND option its to install from pypi using pip:
88+
Open a command prompt in that folder and run the command (Windows) `pip install -e .` or (*nix) `pip3 install -e .`
9189

92-
The package is available from pypi it will be installed using `pip` (NOTE there's isn't a -e for editable install option when using `pip` to install from `pypi`):
90+
Test that all was successful by running `oslcquery -h` you should get a version number then a swathe of text with all the options.
9391

94-
```
95-
pip install elmclient
96-
```
9792

98-
This will install the provided example commands such as `oslcquery`, `batchquery`, `reqif_io`, etc. to the python scripts folder; for ease of use, when installing Python make sure this is in your path.
9993

10094

10195
Coding using the elmclient
10296
==========================
10397

98+
You code will import elmclient, then use it.
99+
104100
The basis of using the elmclient is to first create a "server", then add the needed application(s) to it - typically just one application such as rm, or perhaps more applications such as rm and gc.
105101

106102
Then you can use the API functions to find projects, components, configurations, etc.
@@ -113,7 +109,15 @@ The other examples add fairly complex details around the use of elmclient to pro
113109
Authentication (in httpops.py)
114110
==============================
115111

116-
The auth code works with form authentication using Liberty in local user registry, LDAP and OIDC (Jazz Authorisation Server) modes. Other modes haven't been tested. You'll have to provide a username and password. The examples `oslcquery` and `reqif_io` layer methods on top of this to allow saving obfuscated credentials to a file so you don't have to provide these on the commandline every time. See the code for these examples.
112+
The auth code works with:
113+
* form authentication using Liberty in local user registry
114+
* LDAP (using JTS setup for LDAP) and OIDC (Jazz Authorisation Server, which might be configured for LDAP)
115+
116+
Other authentication methods haven't been tested.
117+
118+
You'll have to provide a username and password; that username will determine the permissions to read/write data on your server, just as they would through a browser UI.
119+
120+
The examples `oslcquery` and `reqif_io` layer authentication enhancements on top of this to allow saving obfuscated credentials to a file so you don't have to provide these on the commandline every time. See the code for these examples.
117121

118122

119123
Handling different context roots
@@ -136,7 +140,7 @@ These examples drove the evolution of `elmclient`:
136140
* General Reportable REST export to XML/CSV - read more [here](elmclient/examples/REPREST.md) - currently only implemented for DOORS Next but with potential to expand to EWM and ETM - commandline options
137141
* Simple Simple DOORS Next Module Structure API - read more [here](elmclient/examples/DN_SIMPLE_MODULESTRUCTURE.md) - Access a module structure and print out the indentend artifiact titles with section number - hardcoded
138142
* Simple DOORS Next Reportable REST - read more [here](elmclient/examples/DN_REPREST.md) - this is a very simple example of using `elmclient` to access the DOORS Next Reportable REST API - hardcoded
139-
143+
* .. and more, check the examples folder...
140144

141145
ELM APIs
142146
========

elmclient/_gcm.py

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ def find_local_component(self, name_or_uri):
8686
return compdetail['component']
8787
return None
8888

89+
def list_components( self ):
90+
# list all the component names
91+
self.load_components_and_configurations()
92+
components = []
93+
for compuri, compdetail in self._components.items():
94+
if compdetail.get('name'):
95+
components.append( compdetail.get('name') )
96+
return components
97+
8998
def load_components_and_configurations(self,force=False):
9099
if self._components is not None and self._configurations is not None and not force:
91100
return

elmclient/examples/represt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ def represt_main():
335335
# def getcontentrow( node, thisrowdict, allcolumns, level, path, remove_ns=True ):
336336
row = utils.getcontentrow( res )
337337
for k in row.keys():
338-
if args.collapsetags:
339-
k1 = k.rsplit("/",1)[1]
338+
if args.collapsetags and '/' in k:
339+
k1 = k.rsplit("/",1)
340340
if k in headingsmapping and headingsmapping[k] != k1:
341341
headingsmapping[k1] = k
342342
else:

elmclient/tests/results/gcm401.html

+32-32
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ <h2>Shapes<h2>
483483
<TR> <TD></TD>
484484
<TD>Member</TD>
485485
<TD></TD>
486-
<TD>https://jazz.ibm.com:9443/gc/type/shape/datatype/enumerated#A1</TD>
486+
<TD>https://jazz.ibm.com:9443/gc/type/shape/datatype/enumerated#A2</TD>
487487
<TD></TD>
488488
</TR>
489489
<TR> <TD></TD>
@@ -560,14 +560,14 @@ <h2>Shapes<h2>
560560
</TR>
561561
<TR> <TD></TD>
562562
<TD>Contributor</TD>
563-
<TD></TD>
564-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A10</TD>
563+
<TD>contributor</TD>
564+
<TD>dcterms:contributor</TD>
565565
<TD></TD>
566566
</TR>
567567
<TR> <TD></TD>
568568
<TD>Creator</TD>
569-
<TD></TD>
570-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A8</TD>
569+
<TD>creator</TD>
570+
<TD>dcterms:creator</TD>
571571
<TD></TD>
572572
</TR>
573573
<TR> <TD></TD>
@@ -596,8 +596,8 @@ <h2>Shapes<h2>
596596
</TR>
597597
<TR> <TD></TD>
598598
<TD>'Project area'</TD>
599-
<TD></TD>
600-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A4</TD>
599+
<TD>projectArea</TD>
600+
<TD>process:projectArea</TD>
601601
<TD></TD>
602602
</TR>
603603
<TR> <TD></TD>
@@ -639,13 +639,13 @@ <h2>Shapes<h2>
639639
<TR> <TD></TD>
640640
<TD>Contributor</TD>
641641
<TD></TD>
642-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A9</TD>
642+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A6</TD>
643643
<TD></TD>
644644
</TR>
645645
<TR> <TD></TD>
646646
<TD>Creator</TD>
647647
<TD></TD>
648-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A5</TD>
648+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A0</TD>
649649
<TD></TD>
650650
</TR>
651651
<TR> <TD></TD>
@@ -675,7 +675,7 @@ <h2>Shapes<h2>
675675
<TR> <TD></TD>
676676
<TD>'Project area'</TD>
677677
<TD></TD>
678-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A4</TD>
678+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components/_OqW90FEfEe2nTqOb0RrItA#A1</TD>
679679
<TD></TD>
680680
</TR>
681681
<TR> <TD></TD>
@@ -716,14 +716,14 @@ <h2>Shapes<h2>
716716
</TR>
717717
<TR> <TD></TD>
718718
<TD>Contributor</TD>
719-
<TD>contributor</TD>
720-
<TD>dcterms:contributor</TD>
719+
<TD></TD>
720+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A0</TD>
721721
<TD></TD>
722722
</TR>
723723
<TR> <TD></TD>
724724
<TD>Creator</TD>
725-
<TD>creator</TD>
726-
<TD>dcterms:creator</TD>
725+
<TD></TD>
726+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A1</TD>
727727
<TD></TD>
728728
</TR>
729729
<TR> <TD></TD>
@@ -752,8 +752,8 @@ <h2>Shapes<h2>
752752
</TR>
753753
<TR> <TD></TD>
754754
<TD>'Project area'</TD>
755-
<TD>projectArea</TD>
756-
<TD>process:projectArea</TD>
755+
<TD></TD>
756+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/components#A2</TD>
757757
<TD></TD>
758758
</TR>
759759
<TR> <TD></TD>
@@ -819,31 +819,31 @@ <h2>Shapes<h2>
819819
<TR> <TD></TD>
820820
<TD>Committer</TD>
821821
<TD></TD>
822-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A5</TD>
822+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A0</TD>
823823
<TD></TD>
824824
</TR>
825825
<TR> <TD></TD>
826826
<TD>Component</TD>
827827
<TD></TD>
828-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A18</TD>
828+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A5</TD>
829829
<TD></TD>
830830
</TR>
831831
<TR> <TD></TD>
832832
<TD>Contribution</TD>
833833
<TD></TD>
834-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A16</TD>
834+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A17</TD>
835835
<TD></TD>
836836
</TR>
837837
<TR> <TD></TD>
838838
<TD>Contributor</TD>
839839
<TD></TD>
840-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A11</TD>
840+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A13</TD>
841841
<TD></TD>
842842
</TR>
843843
<TR> <TD></TD>
844844
<TD>Creator</TD>
845845
<TD></TD>
846-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A21</TD>
846+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A7</TD>
847847
<TD></TD>
848848
</TR>
849849
<TR> <TD></TD>
@@ -855,7 +855,7 @@ <h2>Shapes<h2>
855855
<TR> <TD></TD>
856856
<TD>'Derived from'</TD>
857857
<TD></TD>
858-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A0</TD>
858+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A1</TD>
859859
<TD></TD>
860860
</TR>
861861
<TR> <TD></TD>
@@ -879,13 +879,13 @@ <h2>Shapes<h2>
879879
<TR> <TD></TD>
880880
<TD>'Previous baseline'</TD>
881881
<TD></TD>
882-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A7</TD>
882+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A21</TD>
883883
<TD></TD>
884884
</TR>
885885
<TR> <TD></TD>
886886
<TD>'Project area'</TD>
887887
<TD></TD>
888-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A19</TD>
888+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations/_OqW90FEfEe2nTqOb0RrItA#A8</TD>
889889
<TD></TD>
890890
</TR>
891891
<TR> <TD></TD>
@@ -957,31 +957,31 @@ <h2>Shapes<h2>
957957
<TR> <TD></TD>
958958
<TD>Committer</TD>
959959
<TD></TD>
960-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A6</TD>
960+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A20</TD>
961961
<TD></TD>
962962
</TR>
963963
<TR> <TD></TD>
964964
<TD>Component</TD>
965965
<TD></TD>
966-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A16</TD>
966+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A0</TD>
967967
<TD></TD>
968968
</TR>
969969
<TR> <TD></TD>
970970
<TD>Contribution</TD>
971971
<TD></TD>
972-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A3</TD>
972+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A10</TD>
973973
<TD></TD>
974974
</TR>
975975
<TR> <TD></TD>
976976
<TD>Contributor</TD>
977977
<TD></TD>
978-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A13</TD>
978+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A17</TD>
979979
<TD></TD>
980980
</TR>
981981
<TR> <TD></TD>
982982
<TD>Creator</TD>
983983
<TD></TD>
984-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A9</TD>
984+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A2</TD>
985985
<TD></TD>
986986
</TR>
987987
<TR> <TD></TD>
@@ -993,7 +993,7 @@ <h2>Shapes<h2>
993993
<TR> <TD></TD>
994994
<TD>'Derived from'</TD>
995995
<TD></TD>
996-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A17</TD>
996+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A9</TD>
997997
<TD></TD>
998998
</TR>
999999
<TR> <TD></TD>
@@ -1017,13 +1017,13 @@ <h2>Shapes<h2>
10171017
<TR> <TD></TD>
10181018
<TD>'Previous baseline'</TD>
10191019
<TD></TD>
1020-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A7</TD>
1020+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A21</TD>
10211021
<TD></TD>
10221022
</TR>
10231023
<TR> <TD></TD>
10241024
<TD>'Project area'</TD>
10251025
<TD></TD>
1026-
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A19</TD>
1026+
<TD>https://jazz.ibm.com:9443/gc/oslc-query/shape/configurations#A3</TD>
10271027
<TD></TD>
10281028
</TR>
10291029
<TR> <TD></TD>

0 commit comments

Comments
 (0)