Back to index

radiance  4R0+20100331
copyright.py
Go to the documentation of this file.
00001 
00002 import os
00003 import sys
00004 import string
00005 
00006 
00007 def _get_ltextl():
00008        f = open(os.path.join('src','common','copyright.h'), 'r')
00009        ltl = f.readlines()
00010        f.close()
00011        ltl2 = []
00012        for line in ltl:
00013               line = line.strip()
00014               if line == '*/': line = ''
00015               elif line.find('$Id:') > -1: line = ''
00016               elif line and line[0] == '*':
00017                      line = line[2:]
00018               elif line and line[1] == '*':
00019                      line = line[3:]
00020               ltl2.append(line)
00021        return ltl2 + ['']
00022 
00023 def _show_ltextl(ltextl, lines=23):
00024        llen = len(ltextl)
00025        for i in range(0, llen, lines):
00026               sys.stderr.write('\n'.join(ltextl[i:i+lines]))
00027               if i+lines < llen:
00028                      raw_input('\n[press <return> to continue] ')
00029 
00030 def show_license():
00031        try:
00032               ltextl = _get_ltextl()
00033               _show_ltextl(ltextl)
00034               sys.stderr.write(
00035               'Do you understand and accept the terms of this agreement [n]?\n\n')
00036               answer = ''
00037               s =  'Please enter "yes" or "no", or use ^C to exit: '
00038               while answer not in ['y', 'ye', 'yes', 'n', 'no']:
00039                      if answer: sys.stderr.write('invalid input "%s"\n' % answer)
00040                      answer = string.lower(raw_input(s))
00041 
00042               if answer[0] == 'y':
00043                      return
00044               else:
00045                      sys.stderr.write('\n*** Installation cancelled ***\n')
00046                      sys.exit(1)
00047        except KeyboardInterrupt:
00048               sys.stderr.write('\n*** Installation cancelled ***\n')
00049               sys.exit(1)
00050