| 1 |
schorsch |
1.3 |
from __future__ import division, print_function, unicode_literals |
| 2 |
schorsch |
1.1 |
|
| 3 |
schorsch |
1.2 |
import os |
| 4 |
schorsch |
1.1 |
import sys |
| 5 |
schorsch |
1.3 |
import builtins |
| 6 |
|
|
if hasattr(builtins, 'raw_input'): # < Py3 |
| 7 |
|
|
input = builtins.raw_input |
| 8 |
schorsch |
1.1 |
|
| 9 |
|
|
|
| 10 |
schorsch |
1.2 |
def _get_ltextl(): |
| 11 |
|
|
f = open(os.path.join('src','common','copyright.h'), 'r') |
| 12 |
|
|
ltl = f.readlines() |
| 13 |
|
|
f.close() |
| 14 |
|
|
ltl2 = [] |
| 15 |
|
|
for line in ltl: |
| 16 |
|
|
line = line.strip() |
| 17 |
|
|
if line == '*/': line = '' |
| 18 |
|
|
elif line.find('$Id:') > -1: line = '' |
| 19 |
|
|
elif line and line[0] == '*': |
| 20 |
|
|
line = line[2:] |
| 21 |
|
|
elif line and line[1] == '*': |
| 22 |
|
|
line = line[3:] |
| 23 |
|
|
ltl2.append(line) |
| 24 |
|
|
return ltl2 + [''] |
| 25 |
|
|
|
| 26 |
|
|
def _show_ltextl(ltextl, lines=23): |
| 27 |
|
|
llen = len(ltextl) |
| 28 |
|
|
for i in range(0, llen, lines): |
| 29 |
|
|
sys.stderr.write('\n'.join(ltextl[i:i+lines])) |
| 30 |
|
|
if i+lines < llen: |
| 31 |
schorsch |
1.3 |
input('\n[press <return> to continue] ') |
| 32 |
schorsch |
1.1 |
|
| 33 |
|
|
def show_license(): |
| 34 |
schorsch |
1.2 |
try: |
| 35 |
|
|
ltextl = _get_ltextl() |
| 36 |
|
|
_show_ltextl(ltextl) |
| 37 |
|
|
sys.stderr.write( |
| 38 |
|
|
'Do you understand and accept the terms of this agreement [n]?\n\n') |
| 39 |
|
|
answer = '' |
| 40 |
|
|
s = 'Please enter "yes" or "no", or use ^C to exit: ' |
| 41 |
|
|
while answer not in ['y', 'ye', 'yes', 'n', 'no']: |
| 42 |
|
|
if answer: sys.stderr.write('invalid input "%s"\n' % answer) |
| 43 |
schorsch |
1.3 |
answer = input(s).lower() |
| 44 |
schorsch |
1.2 |
|
| 45 |
|
|
if answer[0] == 'y': |
| 46 |
|
|
return |
| 47 |
|
|
else: |
| 48 |
|
|
sys.stderr.write('\n*** Installation cancelled ***\n') |
| 49 |
|
|
sys.exit(1) |
| 50 |
|
|
except KeyboardInterrupt: |
| 51 |
schorsch |
1.1 |
sys.stderr.write('\n*** Installation cancelled ***\n') |
| 52 |
|
|
sys.exit(1) |
| 53 |
|
|
|
| 54 |
schorsch |
1.3 |
# vi: set ts=4 sw=4 : |
| 55 |
|
|
|