Skip to content

Commit 0fac3e5

Browse files
author
Ethan Lee
committed
Fix the notice screen
Signed-off-by: Ethan Lee <[email protected]>
1 parent da28cfd commit 0fac3e5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/fosslight_binary/cli.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import argparse
66
import sys
77
import os
8+
import shutil
89
from fosslight_util.help import print_package_version
910
from fosslight_binary._help import print_help_msg
1011
from fosslight_binary.binary_analysis import find_binaries
@@ -13,6 +14,22 @@
1314
_PKG_NAME = "fosslight_binary"
1415

1516

17+
def get_terminal_size():
18+
size = shutil.get_terminal_size()
19+
return size.lines
20+
21+
def paginate_file(file_path):
22+
lines_per_page = get_terminal_size() - 1
23+
with open(file_path, 'r') as file:
24+
lines = file.readlines()
25+
26+
for i in range(0, len(lines), lines_per_page):
27+
os.system('clear' if os.name == 'posix' else 'cls')
28+
print(''.join(lines[i:i+lines_per_page]))
29+
if i + lines_per_page < len(lines):
30+
input("Press Enter to see the next page...")
31+
32+
1633
def main():
1734
global windows
1835
path_to_find_bin = ""
@@ -85,8 +102,10 @@ def main():
85102
data_path = os.path.join(base_path, 'LICENSES')
86103
print(f"*** {_PKG_NAME} open source license notice ***")
87104
for ff in os.listdir(data_path):
88-
f = open(os.path.join(data_path, ff), 'r', encoding='utf8')
89-
print(f.read())
105+
source_file = os.path.join(data_path, ff)
106+
destination_file = os.path.join(base_path, ff)
107+
paginate_file(source_file)
108+
shutil.copyfile(source_file, destination_file)
90109
sys.exit(0)
91110

92111
timer = TimerThread()

0 commit comments

Comments
 (0)