Skip to main content

FOSSLight Util

Project description

FOSSLight Util

FOSSLight Util is released under the Apache-2.0. Current python package version. REUSE status

It is a package that supports common utils used by FOSSLight Scanner.

Features

  1. It simplifies the logger setup.
  2. It provides a simple function to create a output file.
  3. It provides a spdx license list with json format.
  4. It defines common constant variables.
  5. It provides a thread that prints the spinner.
  6. Download source code.

Contents

📋 Prerequisite

FOSSLight Util needs a Python 3.6+.

🎉 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

  1. Try git clone. 1-1. If the link is ssh-url, convert to https-url.
  2. If git clone fails, download it with wget and extract the compressed file.
  3. 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/

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.

📄 License

FOSSLight Util is released under Apache-2.0.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fosslight_util-2.0.2.tar.gz (927.3 kB view details)

Uploaded Source

Built Distribution

fosslight_util-2.0.2-py3-none-any.whl (939.8 kB view details)

Uploaded Python 3

File details

Details for the file fosslight_util-2.0.2.tar.gz.

File metadata

  • Download URL: fosslight_util-2.0.2.tar.gz
  • Upload date:
  • Size: 927.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for fosslight_util-2.0.2.tar.gz
Algorithm Hash digest
SHA256 9f94c0812f8f7fe56f5c657fd201d02e081a6ce08cd579a30d7fe0e8c14a5aed
MD5 ce1bb8d49b106e46d911ff4f5565bbc5
BLAKE2b-256 3b3d9c4b39aeed94c26a75359fb9d04e36026c3cd61d58ab0a0706baaf283e1b

See more details on using hashes here.

File details

Details for the file fosslight_util-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fosslight_util-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d626442f77c060997ff7563b05cb729d4a988fdce913e750249010a2f93eae8
MD5 f068134071ccc59f8ea776a795a2411a
BLAKE2b-256 7556166895b49f7491c5eeb37e6a8ec7b9e5d78098fa728f266596b4fdd2e8e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page