Skip to content

Commit 7f525b1

Browse files
authored
Merge pull request #100 from fossology/2.0.0-release
2.0.0 release
2 parents 86ba9bd + 5b4b4f2 commit 7f525b1

22 files changed

+989
-607
lines changed

.github/workflows/doc-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
doc-deploy:
1010
name: Deploy document pages
1111
runs-on: ubuntu-latest
12-
container: 'python:3.9-slim'
12+
container: 'python:3.10-slim'
1313
steps:
1414
- name: Install host dependencies
1515
run: |

.github/workflows/foss_cli_tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
container:
17-
image: python:3.9-slim
17+
image: python:3.10-slim
1818
volumes:
1919
- /tmp:/tmp
2020

@@ -46,19 +46,20 @@ jobs:
4646
run: |
4747
poetry run coverage run --source=fossology -m pytest tests/test_foss_cli*.py
4848
poetry run coverage report -m
49+
continue-on-error: true
4950

5051
test-last_release:
51-
name: foss_cli tests (Fossology 3.10.0)
52+
name: foss_cli tests (Fossology 4.1.0)
5253
runs-on: ubuntu-latest
5354

5455
container:
55-
image: python:3.9-slim
56+
image: python:3.10-slim
5657
volumes:
5758
- /tmp:/tmp
5859

5960
services:
6061
fossology:
61-
image: fossology/fossology:3.10.0
62+
image: fossology/fossology:4.1.0
6263
ports:
6364
- 8081:80
6465
volumes:

.github/workflows/fossologytests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
container:
17-
image: python:3.9-slim
17+
image: python:3.10-slim
1818
volumes:
1919
- /tmp:/tmp
2020

@@ -47,23 +47,24 @@ jobs:
4747
export API_LATEST=true
4848
poetry run coverage run --source=fossology -m pytest
4949
poetry run coverage report -m
50+
continue-on-error: true
5051
- name: upload codecoverage results only if we are on the repository fossology/fossology-python
5152
if: ${{ github.repository == 'fossology/fossology-python' }}
5253
run: poetry run codecov -t ${{ secrets.CODECOV_TOKEN }}
5354

5455

5556
test-last-release:
56-
name: Integration Tests (Fossology 4.0.0)
57+
name: Integration Tests (Fossology 4.1.0)
5758
runs-on: ubuntu-latest
5859

5960
container:
60-
image: python:3.9-slim
61+
image: python:3.10-slim
6162
volumes:
6263
- /tmp:/tmp
6364

6465
services:
6566
fossology:
66-
image: fossology/fossology:4.0.0
67+
image: fossology/fossology:4.1.0
6768
ports:
6869
- 8081:80
6970
volumes:

.github/workflows/staticchecks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
- 'python:3.7-slim'
1515
- 'python:3.8-slim'
1616
- 'python:3.9-slim'
17+
- 'python:3.10-slim'
1718

1819
container: ${{ matrix.container }}
1920

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ See `the OpenAPI specification <https://raw.githubusercontent.com/fossology/foss
2727
- 1.2.1 (Fossology 3.10.0)
2828
- 1.3.2 (Fossology 3.11.0)
2929
- 1.4.0 (Fossology 4.0.0)
30+
- 1.4.3 (Fossology 4.1.0)
31+
32+
**NOTE**
33+
34+
Version 2.0.0 of `fossology-python` only supports Fossology API version 1.4.3 onwards because of a breaking change in
35+
the version format returned by the API. Other earlier version of the wrapper support a wider range of API versions,
36+
e.g. 1.5.0 supports Fossology API 1.2.1 to 1.4.0.
3037

3138
Documentation
3239
=============

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 = "1.5.0"
25+
release = "2.0.0"
2626

2727

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

docs-source/sample_workflow.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ group named clearing is created
107107

108108
Upload File
109109
===========
110-
We first get an example file from our github repository testenvironment and then
111-
upload it to the server.
110+
We first get an example file from our github repository test environment and then
111+
upload it to the server.
112112

113113

114114
>>> filename = "my_base-files_11.tar.xz"
@@ -124,7 +124,7 @@ upload it to the server.
124124
... description="Test upload via fossology-python lib",
125125
... group=group_name,
126126
... access_level=AccessLevel.PUBLIC,
127-
... )
127+
... )
128128

129129

130130
Start default scan jobs
@@ -199,3 +199,22 @@ report downloaded...
199199
>>> print(f"report was written to file {name}.") # doctest: +ELLIPSIS
200200
report was written to file...
201201

202+
203+
Delete folder
204+
=============
205+
206+
Cleanup existing folder and all included data.
207+
208+
>>> foss.delete_folder(test_folder)
209+
>>> print(f"Folder {test_folder.name} has been deleted")
210+
Folder AwesomeFossFolder has been deleted
211+
212+
213+
Clean up
214+
========
215+
216+
Cleanup created report and token files
217+
218+
>>> os.unlink(name)
219+
>>> os.unlink(path_to_upload_file)
220+
>>> os.unlink(path_to_token_file)

fossology/foss_cli.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def check_get_access_level(level: str):
136136

137137

138138
def needs_later_initialization_of_foss_instance(ctx):
139-
"""Check if lateron a Fossology Instance will be created.
139+
"""Check if later on a Fossology Instance will be created.
140140
141141
:param ctx: click context
142142
:type ctx: click.core.Context
@@ -580,6 +580,7 @@ def upload_file(
580580
file=upload_file,
581581
description=description if description else "upload via foss-cli",
582582
access_level=the_access_level,
583+
wait_time=10,
583584
)
584585

585586
ctx.obj["UPLOAD"] = the_upload
@@ -602,6 +603,56 @@ def upload_file(
602603
)
603604

604605

606+
@cli.command("delete_folder")
607+
@click.argument("folder_name")
608+
@click.pass_context
609+
def delete_folder(
610+
ctx: click.core.Context,
611+
folder_name: str,
612+
):
613+
"""The foss_cli delete_folder command."""
614+
615+
logger.debug(f"Try to delete folder {folder_name}")
616+
foss = ctx.obj["FOSS"]
617+
618+
folder = None
619+
for f in foss.list_folders():
620+
if f.name == folder_name:
621+
folder = f
622+
logger.debug(f"Found folder to delete: {folder}")
623+
break
624+
625+
if not folder:
626+
logger.fatal(f"Unable to find folder {folder_name}.")
627+
ctx.exit(1)
628+
629+
foss.delete_folder(folder)
630+
logger.debug(f"Delete command was send to {foss.host} for folder {folder}")
631+
632+
633+
@cli.command("delete_upload")
634+
@click.argument("upload_name")
635+
@click.pass_context
636+
def delete_upload(
637+
ctx: click.core.Context,
638+
upload_name: str,
639+
):
640+
"""The foss_cli folder_id command."""
641+
642+
logger.debug(f"Try to delete upload {upload_name}")
643+
foss = ctx.obj["FOSS"]
644+
645+
upload = None
646+
for u in foss.list_uploads(all_pages=True)[0]:
647+
if u.uploadname == upload_name:
648+
upload = u
649+
logger.debug(f"Found upload to delete: {upload}")
650+
break
651+
652+
foss.delete_upload(upload)
653+
logger.debug(f"Delete command was send to {foss.host} for upload {upload}")
654+
655+
605656
@cli.command("start_workflow")
606657
@click.argument(
607658
"file_name",
@@ -695,6 +746,7 @@ def start_workflow( # noqa: C901
695746
file=file_name,
696747
description=file_description,
697748
access_level=the_access_level,
749+
wait_time=10,
698750
)
699751
logger.debug(f"Finished upload for {file_name}")
700752

fossology/jobs.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
class Jobs:
1616
"""Class dedicated to all "jobs" related endpoints"""
1717

18-
def list_jobs(self, upload=None, page_size=100, page=1, all_pages=False):
18+
def list_jobs(
19+
self, upload=None, page_size=100, page=1, all_pages=False
20+
) -> tuple[list, int]:
1921
"""Get all available jobs
2022
2123
API Endpoint: GET /jobs
@@ -66,8 +68,8 @@ def list_jobs(self, upload=None, page_size=100, page=1, all_pages=False):
6668
logger.info(f"Retrieved all {x_total_pages} pages of jobs")
6769
return jobs_list, x_total_pages
6870

69-
def detail_job(self, job_id, wait=False, timeout=30):
70-
"""Get detailled information about a job
71+
def detail_job(self, job_id, wait=False, timeout=30) -> Job:
72+
"""Get detailed information about a job
7173
7274
API Endpoint: GET /jobs/{id}
7375
@@ -102,7 +104,9 @@ def detail_job(self, job_id, wait=False, timeout=30):
102104
description = f"Error while getting details for job {job_id}"
103105
raise FossologyApiError(description, response)
104106

105-
def schedule_jobs(self, folder, upload, spec, group=None, wait=False, timeout=30):
107+
def schedule_jobs(
108+
self, folder, upload, spec, group=None, wait=False, timeout=30
109+
) -> Job:
106110
"""Schedule jobs for a specific upload
107111
108112
API Endpoint: POST /jobs

fossology/obj.py

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ class ClearingStatus(Enum):
8080
REJECTED = "Rejected"
8181

8282

83+
class JobStatus(Enum):
84+
"""Job statuses:
85+
86+
COMPLETED
87+
FAILED
88+
QUEUED
89+
PROCESSING
90+
91+
"""
92+
93+
COMPLETED = "Completed"
94+
FAILED = "Failed"
95+
QUEUED = "Queued"
96+
PROCESSING = "Processing"
97+
98+
8399
class LicenseType(Enum):
84100
"""License types:
85101
@@ -793,6 +809,37 @@ def from_json(cls, json_dict):
793809
return cls(**json_dict)
794810

795811

812+
class FossologyServer(object):
813+
814+
"""FOSSology server info.
815+
816+
:param version: version of the FOSSology server (e.g. 4.0.0)
817+
:param branchName: branch deployed on the FOSSology server
818+
:param commitHash: hash of commit deployed on the FOSSology server
819+
:param commitDate: date of commit deployed on the FOSSology server in ISO8601 format
820+
:param buildDate: date on which packages were built in ISO8601 format
821+
:type version: string
822+
:type branchName: string
823+
:type commitHash: string
824+
:type commitDate: string
825+
:type buildDate: string
826+
"""
827+
828+
def __init__(self, version, branchName, commitHash, commitDate, buildDate):
829+
self.version = version
830+
self.branchName = branchName
831+
self.commitHash = commitHash
832+
self.commitDate = commitDate
833+
self.buildDate = buildDate
834+
835+
def __str__(self):
836+
return f"Fossology server version {self.version} (branch {self.branchName} - {self.commitHash})"
837+
838+
@classmethod
839+
def from_json(cls, json_dict):
840+
return cls(**json_dict)
841+
842+
796843
class ApiInfo(object):
797844

798845
"""FOSSology API info.
@@ -805,28 +852,39 @@ class ApiInfo(object):
805852
:param security: security methods allowed
806853
:param contact: email contact from the API documentation
807854
:param license: licensing of the API
855+
:param fossology: information about FOSSology server
808856
:type name: string
809857
:type description: string
810858
:type version: string
811859
:type security: list
812860
:type contact: string
813861
:type license: ApiLicense object
862+
:type fossology: FossologyServer object
814863
:type kwargs: key word argument
815864
"""
816865

817866
def __init__(
818-
self, name, description, version, security, contact, license, **kwargs
867+
self,
868+
name,
869+
description,
870+
version,
871+
security,
872+
contact,
873+
license,
874+
fossology,
875+
**kwargs,
819876
):
820877
self.name = name
821878
self.description = description
822879
self.version = version
823880
self.security = security
824881
self.contact = contact
825882
self.license = ApiLicense.from_json(license)
883+
self.fossology = FossologyServer.from_json(fossology)
826884
self.additional_info = kwargs
827885

828886
def __str__(self):
829-
return f"FOSSology API {self.name} is deployed with version {self.version}"
887+
return f"{self.name} is deployed with version {self.version}"
830888

831889
@classmethod
832890
def from_json(cls, json_dict):

0 commit comments

Comments
 (0)