2
'''Creates a .pythonrc.py file and puts the path for BuildSystem in it'''
9
'''Check that hostname returns something BitKeeper is happy with, and returns any lines to be added to the RC file
10
- Set BK_HOST if necessary'''
13
hostname = socket.gethostname()
14
if len(hostname) > 8 and hostname[0:9] == 'localhost':
15
return ['os.putenv("BK_HOST", "bkneedsname.org")']
16
elif hostname[-1] == '.':
17
return ['os.putenv("BK_HOST", "'+hostname+'org")']
18
elif hostname.find('.') == -1:
19
return ['os.putenv("BK_HOST", "'+hostname+'.org")']
22
def setupASESection(lines, path):
23
'''Fill in the ASE section of the RC file'''
29
aseMarker = '###### ASE Section'
31
for line in [l.strip() for l in lines]:
44
ase.extend(['# Code added by sidl/BuildSystem/install/setuprc.py', 'import sys', 'sys.path.insert(0,"'+path+'")'])
45
ase.extend(setupHostname())
51
filename = os.path.join(os.getenv('HOME'),'.pythonrc.py')
52
if os.path.isfile(filename):
59
f = open(filename,'w')
60
f.write('\n'.join(setupASESection(lines, path)))
62
sys.path.insert(0, path)
65
if __name__ == '__main__':
68
sys.exit('Usage: setupRC.py <BuildSystem path>')