Skip to content

Commit 16719d1

Browse files
authored
Merge pull request #113 from fossology/chore/release-3.x
Chore/release 3.x
2 parents c998d61 + 1e639aa commit 16719d1

34 files changed

+62
-115
lines changed

.github/workflows/foss_cli_tests.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,3 @@ jobs:
4747
poetry run coverage run --source=fossology -m pytest tests/test_foss_cli*.py
4848
poetry run coverage report -m
4949
continue-on-error: true
50-
51-
test-last_release:
52-
name: foss_cli tests (Fossology 4.1.0)
53-
runs-on: ubuntu-latest
54-
55-
container:
56-
image: python:3.11-slim
57-
volumes:
58-
- /tmp:/tmp
59-
60-
services:
61-
fossology:
62-
image: fossology/fossology:4.1.0
63-
ports:
64-
- 8081:80
65-
volumes:
66-
- /tmp:/tmp
67-
68-
steps:
69-
- uses: actions/checkout@v1
70-
- name: Install host dependencies
71-
run: |
72-
apt-get -qq update
73-
apt-get install -qq gcc git nmap xz-utils
74-
rm -rf /var/lib/apt/lists/*
75-
- name: Install Python dependencies
76-
run: |
77-
pip install poetry
78-
poetry install --with=dev
79-
- name: Install files in shared volume
80-
run: |
81-
tar xJf tests/files/base-files_11.tar.xz -C /tmp
82-
- name: Check services
83-
run: nmap fossology -p 80
84-
- name: Run tests
85-
run: |
86-
poetry run coverage run --source=fossology -m pytest tests/test_foss_cli*.py
87-
poetry run coverage report -m
88-

README.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,11 @@ A simple wrapper for the Fossology REST API.
2626

2727
See `the OpenAPI specification <https://raw.githubusercontent.com/fossology/fossology/master/src/www/ui/api/documentation/openapi.yaml>`_ used to implement this library.
2828

29-
Compatible API versions:
29+
Current release is compatible with **Fossology version 4.2.1** - API version 1.4.3.
3030

31-
- 1.2.1 (Fossology 3.10.0)
32-
- 1.3.2 (Fossology 3.11.0)
33-
- 1.4.0 (Fossology 4.0.0)
34-
- 1.4.3 (Fossology 4.1.0)
35-
- 1.5.1 (Fossology 4.2.0) - partially covered, see #52 for the list of missing supported API feature
31+
`See release notes <https://github.com/fossology/fossology-python/releases>`_ for all details.
3632

37-
**NOTE**
38-
39-
Version 2.0.0 of `fossology-python` only supports Fossology API version 1.4.3 onwards because of a breaking change in
40-
the version format returned by the API. Other earlier version of the wrapper support a wider range of API versions,
41-
e.g. 1.5.0 supports Fossology API 1.2.1 to 1.4.0.
33+
The list of unsupported API features is documented in `issue #52 <https://github.com/fossology/fossology-python/issues/52>`_.
4234

4335
Documentation
4436
=============

docs-source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
copyright = "2021, Siemens AG"
2323

2424
# The full version, including major/minor/patch tags
25-
release = "2.1.0"
25+
release = "3.0.0"
2626

2727

2828
# -- General configuration ---------------------------------------------------

docs-source/sample_workflow.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ Login to the Fossology Server
6565
Create the Fossology Instance.
6666

6767

68-
>>> # The username is only needed for Fossology API version < 1.2.3
69-
>>> foss = Fossology(FOSSOLOGY_SERVER, token, name=os.environ["FOSSOLOGY_USER"])
68+
>>> foss = Fossology(FOSSOLOGY_SERVER, token)
7069
>>> print(f"Logged in as user {foss.user.name}")
7170
Logged in as user fossy
7271

fossology/__init__.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Copyright 2019-2021 Siemens AG
1+
# Copyright 2019 Siemens AG
22
# SPDX-License-Identifier: MIT
33

44
import logging
5-
import re
65
from datetime import date, timedelta
76

87
import requests
@@ -68,7 +67,7 @@ def fossology_token(
6867
response = requests.post(url + "/api/v1/tokens", data=data)
6968
if response.status_code == 201:
7069
token = response.json()["Authorization"]
71-
return re.sub("Bearer ", "", token)
70+
return token.replace("Bearer ", "")
7271
elif response.status_code == 404:
7372
description = "Authentication error"
7473
raise AuthenticationError(description, response)
@@ -88,14 +87,12 @@ class Fossology(Folders, Groups, LicenseEndpoint, Uploads, Jobs, Report, Users,
8887
:Example:
8988
9089
>>> from fossology import Fossology
91-
>>> foss = Fossology(FOSS_URL, FOSS_TOKEN, username) # doctest: +SKIP
90+
>>> foss = Fossology(FOSS_URL, FOSS_TOKEN) # doctest: +SKIP
9291
9392
:param url: URL of the Fossology instance
9493
:param token: The API token generated using the Fossology UI
95-
:param name: The name of the token owner (deprecated since API version 1.2.3)
9694
:type url: str
9795
:type token: str
98-
:type name: str (deprecated since API version 1.2.3)
9996
:raises FossologyApiError: if a REST call failed
10097
:raises AuthenticationError: if the user couldn't be authenticated
10198
"""
@@ -109,19 +106,18 @@ def __init__(self, url, token, name=None):
109106
self.api = f"{self.host}/api/v1"
110107
self.session = requests.Session()
111108
self.session.headers.update({"Authorization": f"Bearer {self.token}"})
112-
self.version = self.get_version()
113109
self.info = self.get_info()
114110
self.health = self.get_health()
115-
self.user = self.get_self(name)
111+
self.user = self.get_self()
116112
self.name = self.user.name
117113
self.rootFolder = self.detail_folder(self.user.rootFolderId)
118114
self.folders = self.list_folders()
119115

120116
logger.info(
121-
f"Authenticated as {self.user.name} against {self.host} using API version {self.version}"
117+
f"Authenticated as {self.user.name} against {self.host} using API version {self.info.version}"
122118
)
123119

124-
def get_self(self, name=None):
120+
def get_self(self):
125121
"""Perform the first API request and populate user variables
126122
127123
API Endpoint: GET /users/self
@@ -147,22 +143,6 @@ def get_self(self, name=None):
147143
def close(self):
148144
self.session.close()
149145

150-
def get_version(self):
151-
"""Get API version from the server
152-
153-
API endpoint: GET /version (deprecated since API version 1.3.3)
154-
155-
:return: the API version string
156-
:rtype: string
157-
:raises FossologyApiError: if the REST call failed
158-
"""
159-
response = self.session.get(f"{self.api}/version")
160-
if response.status_code == 200:
161-
return response.json()["version"]
162-
else:
163-
description = "Error while getting API version"
164-
raise FossologyApiError(description, response)
165-
166146
def get_info(self) -> ApiInfo:
167147
"""Get info from the server
168148

fossology/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright 2019 Siemens AG
2+
# SPDX-License-Identifier: MIT
3+
14
__doc__ = """
25
Allows to run the foss_cli with: python -m fossology
36
"""

fossology/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2021 Siemens AG
1+
# Copyright 2019 Siemens AG
22
# SPDX-License-Identifier: MIT
33

44
from json.decoder import JSONDecodeError

fossology/folders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mypy: disable-error-code="attr-defined"
2-
# Copyright 2019-2021 Siemens AG
2+
# Copyright 2019 Siemens AG
33
# SPDX-License-Identifier: MIT
44

55
import logging
@@ -99,7 +99,7 @@ def create_folder(
9999
logger.info(
100100
f"Folder '{name}' already exists under the folder {parent.name} ({parent.id})"
101101
)
102-
# Foldernames with similar letter but different cases
102+
# Folder names with similar letter but different cases
103103
# are not allowed in Fossology, compare with lower case
104104
existing_folder = [
105105
folder

fossology/foss_cli.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright 2019 Siemens AG
2+
# SPDX-License-Identifier: MIT
3+
14
__doc__ = """
25
The foss_cli cmdline interface uses the provided REST-API to communicate
36
with the Fossology Server.
@@ -20,11 +23,7 @@
2023
import click
2124

2225
from fossology import Fossology, fossology_token
23-
from fossology.exceptions import (
24-
AuthenticationError,
25-
FossologyApiError,
26-
FossologyUnsupported,
27-
)
26+
from fossology.exceptions import FossologyApiError, FossologyUnsupported
2827
from fossology.obj import AccessLevel, Folder, ReportFormat, Summary, TokenScope
2928

3029
logger = logging.getLogger(__name__)
@@ -46,7 +45,6 @@
4645
"copyright_email_author": True,
4746
"ecc": True,
4847
"keyword": True,
49-
"monk": True,
5048
"mime": True,
5149
"monk": True,
5250
"nomos": True,
@@ -219,14 +217,7 @@ def init_foss(ctx: click.Context):
219217
"No Token provided. Either provide FOSS_TOKEN in environment or use the -t option."
220218
)
221219
raise e
222-
try:
223-
foss = Fossology(ctx.obj["SERVER"], ctx.obj["TOKEN"]) # using new API
224-
except AuthenticationError: # API version < 1.2.3 requires a username
225-
foss = Fossology(
226-
ctx.obj["SERVER"],
227-
ctx.obj["TOKEN"],
228-
name=ctx.obj["USERNAME"],
229-
)
220+
foss = Fossology(ctx.obj["SERVER"], ctx.obj["TOKEN"]) # using new API
230221
ctx.obj["FOSS"] = foss
231222
ctx.obj["USER"] = foss.user.name
232223
logger.debug(f"Logged in as user {foss.user.name}")
@@ -323,7 +314,7 @@ def cli(
323314
logger.debug("Started in debug mode")
324315
if foss_needs_initialization:
325316
logger.debug(
326-
f"Using API: {pprint.pformat(foss.api)} version {pprint.pformat(foss.version)}"
317+
f"Using API: {pprint.pformat(foss.api)} version {pprint.pformat(foss.info.version)}"
327318
)
328319
logger.debug(
329320
f"Running as user {pprint.pformat(foss.user.name)} on {pprint.pformat(foss.host)}"

fossology/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mypy: disable-error-code="attr-defined"
2-
# Copyright 2019-2021 Siemens AG
2+
# Copyright 2019 Siemens AG
33
# SPDX-License-Identifier: MIT
44

55
import logging

0 commit comments

Comments
 (0)