|
5 | 5 | import argparse |
6 | 6 | import sys |
7 | 7 | import os |
| 8 | +import shutil |
8 | 9 | from fosslight_util.help import print_package_version |
9 | 10 | from fosslight_binary._help import print_help_msg |
10 | 11 | from fosslight_binary.binary_analysis import find_binaries |
|
13 | 14 | _PKG_NAME = "fosslight_binary" |
14 | 15 |
|
15 | 16 |
|
| 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 | + |
16 | 33 | def main(): |
17 | 34 | global windows |
18 | 35 | path_to_find_bin = "" |
@@ -85,8 +102,10 @@ def main(): |
85 | 102 | data_path = os.path.join(base_path, 'LICENSES') |
86 | 103 | print(f"*** {_PKG_NAME} open source license notice ***") |
87 | 104 | 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) |
90 | 109 | sys.exit(0) |
91 | 110 |
|
92 | 111 | timer = TimerThread() |
|
0 commit comments