Skip to content

Commit

Permalink
Fix the notice screen
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Lee <seojethan.lee@lge.com>
  • Loading branch information
Ethan Lee committed Nov 11, 2024
1 parent da28cfd commit 0fac3e5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/fosslight_binary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import argparse
import sys
import os
import shutil
from fosslight_util.help import print_package_version
from fosslight_binary._help import print_help_msg
from fosslight_binary.binary_analysis import find_binaries
Expand All @@ -13,6 +14,22 @@
_PKG_NAME = "fosslight_binary"


def get_terminal_size():
size = shutil.get_terminal_size()
return size.lines

def paginate_file(file_path):
lines_per_page = get_terminal_size() - 1
with open(file_path, 'r') as file:
lines = file.readlines()

for i in range(0, len(lines), lines_per_page):
os.system('clear' if os.name == 'posix' else 'cls')
print(''.join(lines[i:i+lines_per_page]))
if i + lines_per_page < len(lines):
input("Press Enter to see the next page...")


def main():
global windows
path_to_find_bin = ""
Expand Down Expand Up @@ -85,8 +102,10 @@ def main():
data_path = os.path.join(base_path, 'LICENSES')
print(f"*** {_PKG_NAME} open source license notice ***")
for ff in os.listdir(data_path):
f = open(os.path.join(data_path, ff), 'r', encoding='utf8')
print(f.read())
source_file = os.path.join(data_path, ff)
destination_file = os.path.join(base_path, ff)
paginate_file(source_file)
shutil.copyfile(source_file, destination_file)
sys.exit(0)

timer = TimerThread()
Expand Down

0 comments on commit 0fac3e5

Please sign in to comment.