Skip to content

Commit d2bbe8b

Browse files
committed
Add a class for printing spinner
1 parent e01fdc4 commit d2bbe8b

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ It is a package that supports common utils used by FOSSLight Scanner.
99
2. It easily outputs csv file and excel file in OSS Report format.
1010
3. It provides a simple function to create a text file.
1111
4. 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)
8485
logger.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

89100
Please 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.

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
XlsxWriter
22
pandas
33
xlrd
4-
openpyxl
4+
openpyxl
5+
progress

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if __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',

src/fosslight_util/timer_thread.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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()

tests/test_timer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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()

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)