mac에서 불편하던 중 대략 만들어 봤따.
...
@ by ChangYeol,Kim
@ http://umakingtistory.com
'''
pt1 = '/uma/'
pt2 = '.txt'
hostList = ['1.Development', '2.Staging', '4.Production']
def chooseHostList():
hosts = readFile('/etc/hosts')
i = 0
while(i < len(hostList)):
src_buf = readFile(pt1 + hostList[i] + pt2)
if hosts == src_buf:
print '[*', (i+1), '] ', hostList[i]
else:
print '[ ', (i+1), '] ', hostList[i]
i = i + 1
def loopMain():
while True:
print('=====================================')
chooseHostList()
print('-------------------------------------')
inp = input('==>')
if inp > 0 and inp <= len(hostList):
buf = readFile(pt1 + hostList[inp-1] + pt2)
writeFileToHosts(buf)
else:
print()
def readFile(filename):
sf = open(filename)
buf = sf.read()
sf.close()
return buf
def writeFileToHosts(buf):
tf = open('/etc/hosts', 'w')
tf.write(buf)
tf.close()
loopMain()
'내꺼' 카테고리의 다른 글
| css 디버깅 툴 (0) | 2012.07.09 |
|---|---|
| Captcha 같이 영문(대+소)+숫자 를 섞어서 출력하려고 하다가 보니 몇가지를 만들었네. (0) | 2009.11.24 |
| host 정보를 바꿔봐~ (2) | 2009.06.25 |
| 귀찮을때 쓰는 hosts 바꿔치기 batch... (0) | 2009.06.16 |
| hosts (0) | 2009.05.22 |