File tree Expand file tree Collapse file tree 8 files changed +79
-3
lines changed Expand file tree Collapse file tree 8 files changed +79
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ It is a package that supports common utils used by FOSSLight Scanner.
992 . It easily outputs csv file and excel file in OSS Report format.
10103 . It provides a simple function to create a text file.
11114 . It defines common constant variables.
12+ 5 . It provides a thread that prints the spinner.
1213
1314[ or ] : http://collab.lge.com/main/x/xDHlFg
1415
@@ -84,6 +85,16 @@ logger = logging.getLogger(constant.LOGGER_NAME)
8485logger.warning("Get a logger after init_log is called once.")
8586```
8687
88+ ### 5. Call a spinner (tests/test_timer.py)
89+ ```
90+ from fosslight_util.timer_thread import TimerThread
91+
92+
93+ timer = TimerThread()
94+ timer.setDaemon(True)
95+ timer.start()
96+ ```
97+
8798## 👏 How to report issue
8899
89100Please report any ideas or bugs to improve by creating an issue in [ fosslight_util repository] [ cl ] . Then there will be quick bug fixes and upgrades. Ideas to improve are always welcome.
Original file line number Diff line number Diff line change 11XlsxWriter
22pandas
33xlrd
4- openpyxl
4+ openpyxl
5+ progress
6+ PyYAML
Original file line number Diff line number Diff line change 1313if __name__ == "__main__" :
1414 setup (
1515 name = 'fosslight_util' ,
16- version = '1.0.2 ' ,
16+ version = '1.0.3 ' ,
1717 package_dir = {"" : "src" },
1818 packages = find_packages (where = 'src' ),
1919 description = 'FOSSLight Util' ,
Original file line number Diff line number Diff line change 66import logging
77import os
88from pathlib import Path
9+ import pkg_resources
10+ import sys
11+ import platform
912from . import constant as constant
1013
1114
@@ -35,3 +38,20 @@ def init_log(log_file, create_file=True):
3538 logger .propagate = False
3639
3740 return logger
41+
42+
43+ def init_log_item (main_package_name = "" , path_to_analyze = "" ):
44+
45+ _PYTHON_VERSION = sys .version_info [0 ]
46+ _result_log = {
47+ "Tool Info" : main_package_name ,
48+ "Python version" : _PYTHON_VERSION ,
49+ "OS" : platform .system ()+ " " + platform .release (),
50+ }
51+ if main_package_name != "" :
52+ pkg_version = pkg_resources .get_distribution (main_package_name ).version
53+ _result_log ["Tool Info" ] = main_package_name + " v." + pkg_version
54+ if path_to_analyze != "" :
55+ _result_log ["Path to analyze" ] = path_to_analyze
56+
57+ return _result_log
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+ # Copyright (c) 2021 LG Electronics Inc.
4+ # SPDX-License-Identifier: Apache-2.0
5+ import threading
6+ import time
7+ from progress .spinner import Spinner
8+
9+ class TimerThread (threading .Thread ):
10+ def __init__ (self ):
11+ threading .Thread .__init__ (self , name = ' Thread' )
12+
13+ def run (self ):
14+ spinner = Spinner ('' )
15+ while True :
16+ time .sleep (1 )
17+ spinner .next ()
Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33# Copyright (c) 2021 LG Electronics Inc.
44# SPDX-License-Identifier: Apache-2.0
5-
5+ import yaml
66from fosslight_util .set_log import init_log
7+ from fosslight_util .set_log import init_log_item
78from _print_log import print_log
89from _print_log_with_another_logger import print_log_another_logger
910
1011def main ():
1112 logger = init_log ("test_result/log_file1.txt" )
1213 logger .warning ("TESTING LOG - from 1st Module" )
1314
15+ result_log = init_log_item ("fosslight_util" )
16+ _str_final_result_log = yaml .safe_dump (result_log , allow_unicode = True )
17+ logger .warning (_str_final_result_log )
18+
1419 print_log ()
1520 print_log_another_logger ()
1621
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+ # Copyright (c) 2021 LG Electronics Inc.
4+ # SPDX-License-Identifier: Apache-2.0
5+ import os
6+ import time
7+ from fosslight_util .timer_thread import TimerThread
8+
9+
10+ def main ():
11+ timer = TimerThread ()
12+ timer .setDaemon (True )
13+ timer .start ()
14+
15+ time .sleep (3 )
16+
17+
18+ if __name__ == '__main__' :
19+ main ()
Original file line number Diff line number Diff line change @@ -24,3 +24,5 @@ commands =
2424 python tests/test_excel.py
2525 ls test_result/excel
2626 cat test_result/excel/OSS-Report.csv
27+ # Test - timer
28+ python tests/test_timer.py
You can’t perform that action at this time.
0 commit comments