FOSSLight Util
It is a package that supports common utils used by FOSSLight Scanner.
Features
- It simplifies the logger setup.
- It provides a simple function to create a output file.
- It provides a spdx license list with json format.
- It defines common constant variables.
- It provides a thread that prints the spinner.
- Download source code.
Contents
📋 Prerequisite
FOSSLight Util needs a Python 3.10+.
🎉 How to install
It can be installed using pip3.
$ pip3 install fosslight_util
🚀 How to use
Three modules can be called. Please refer to each file for detailed calling method.
1. Setup logger (tests/test_log.py)
from fosslight_util.set_log import init_log
# 1st param : log file path
# 2nd param : create file (True/False)
# 3rd param : stream log level
# 4th param : file log level
# =>log level(CRITICAL:50, ERROR:40, WARNING:30, INFO:20, DEBUG:10, NOTSET:0)
# 5th param : package name of fosslight scanners (fosslight_source / fosslight_dependency / fosslight_reuse)
# 6th param : path to analyze
#
# 1st return value : a logger
# 2nd return value : log items to print
def test():
logger, log_item = init_log("test_result/log_file1.txt", True, 30, 20)
logger.warning("TESTING - Print log")
2. Write result files (tests/test_output_format.py)
from fosslight_util.output_format import write_output_file
# 2nd param : output file format
# => file format(excel: .xlsx, csv: .csv, opossum: .json)
def test():
sheet_contents = {'SRC':[['run_scancode.py', 'fosslight_source',
'3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_source', 'https://github.com/LGE-OSS/fosslight_source', 'Copyright (c) 2021 LG Electronics, Inc.', 'Exclude', 'Comment message'],
['dependency_unified.py', 'fosslight_dependency',
'3.0.6', 'Apache-2.0', 'https://github.com/LGE-OSS/fosslight_dependency', 'https://github.com/LGE-OSS/fosslight_dependency', 'Copyright (c) 2020 LG Electronics, Inc.', '', '']],
'BIN':[['askalono.exe', 'askalono',
'0.4.3', 'Apache-2.0', 'https://github.com/jpeddicord/askalono', '', 'Copyright (c) 2018 Amazon.com, Inc. or its affiliates.', '', '']]}
success, msg = write_output_file('test_result/excel/FOSSLight-Report', '.xlsx', sheet_contents)
3. Get spdx licenses (tests/test_spdx_licenses.py)
from fosslight_util.spdx_licenses import get_spdx_licenses_json
def test():
success, error_msg, licenses = get_spdx_licenses_json()
4. Load common constant (tests/_print_log_with_another_logger.py)
import fosslight_util.constant as constant
logger = logging.getLogger(constant.LOGGER_NAME)
logger.warning("Get a logger after init_log is called once.")
5. Call a spinner (tests/test_timer.py)
from fosslight_util.timer_thread import TimerThread
timer = TimerThread()
timer.setDaemon(True)
timer.start()
6. Download the source code (tests/test_download.py)
If you give a link, the source is downloaded to the target directory through git clone or wget.
How it works
- Try git clone. 1-1. If the link is ssh-url, convert to https-url.
- If git clone fails, download it with wget and extract the compressed file.
- After extracting the compressed file, delete the compressed file.
Parameters
| Parameter | Argument | Description |
|---|---|---|
| h | None | Print help message. |
| s | String | Link to download. |
| t | String | Path to download and extract. |
| d | String | Path to save a log file. |
How to run
$ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
Limit download size (GB) with --size-limit / -l (omit for unlimited):
$ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/ -l 5
If you want to try with private repository, set your github token like below.
$ fosslight_download -s "https://my_github_token@github.com/Foo/private_repo -t target_dir/"
📝 How to report issue
Please report any ideas or bugs to improve by creating an issue in fosslight_util repository. Then there will be quick bug fixes and upgrades. Ideas to improve are always welcome.
👏 Contributing Guide
We always welcome your contributions. Please see the CONTRIBUTING guide for how to contribute.
📄 License
FOSSLight Util is released under Apache-2.0.
Metadata
Release files for fosslight-util 2.2.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fosslight_util-2.2.21.tar.gz | 993.4 kB | Without provenance | Details for fosslight_util-2.2.21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fosslight_util-2.2.21-py3-none-any.whl | Python 3 | none | any | Details for fosslight_util-2.2.21-py3-none-any.whl |
Total release size: 2.0 MB
Release files / fosslight_util-2.2.21.tar.gz
| Download URL | fosslight_util-2.2.21.tar.gz |
|---|---|
| Size | 993.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b66a1b3f0fe2f3e10c72809d7a21663e911676bfa143d03b2f26a71f11bdd127
|
|
BLAKE2b-256 checksum How to use checksums |
58dc7b8e064d4be82e8a1251f258c3bd4c080bafd507cb42b311d8c5f6da94ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / fosslight_util-2.2.21-py3-none-any.whl
| Download URL | fosslight_util-2.2.21-py3-none-any.whl |
|---|---|
| Size | 982.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd39da5cac46e96f0a8501c939ca37f2fc76c155178adae68804b0ece1ab23ad
|
|
BLAKE2b-256 checksum How to use checksums |
450bf7867ffce8050330b17d0f9b3c098b130883ff807c7b345033dfc6fa0ef5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for fosslight-util 2.2.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.