mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Pulled out questions.py, added a few more niceties.
This commit is contained in:
parent
d9263c835d
commit
e93f0e62d0
@ -29,29 +29,6 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
def expect(prompt, possibilities, recursed=False):
|
|
||||||
if recursed:
|
|
||||||
print 'Sorry, that response was not an option.'
|
|
||||||
if possibilities:
|
|
||||||
prompt = '%s [%s]' % (prompt, '/'.join(possibilities))
|
|
||||||
prompt = prompt.strip() + ' '
|
|
||||||
s = raw_input(prompt)
|
|
||||||
if possibilities:
|
|
||||||
if s in possibilities:
|
|
||||||
return s.strip()
|
|
||||||
else:
|
|
||||||
return expect(prompt, possibilities, recursed=True)
|
|
||||||
else:
|
|
||||||
return s.strip()
|
|
||||||
|
|
||||||
def anything(prompt):
|
|
||||||
return expect(prompt, [])
|
|
||||||
|
|
||||||
def yn(prompt):
|
|
||||||
return expect(prompt, ['y', 'n'])
|
|
||||||
|
|
||||||
def ny(prompt):
|
|
||||||
return expect(prompt, ['n', 'y'])
|
|
||||||
|
|
||||||
# So we gotta:
|
# So we gotta:
|
||||||
# Check to see if the user has sqlite installed.
|
# Check to see if the user has sqlite installed.
|
||||||
@ -62,6 +39,7 @@ def ny(prompt):
|
|||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, 'src')
|
sys.path.insert(0, 'src')
|
||||||
from fix import *
|
from fix import *
|
||||||
|
from questions import *
|
||||||
import os
|
import os
|
||||||
import imp
|
import imp
|
||||||
import conf
|
import conf
|
||||||
@ -87,7 +65,9 @@ if __name__ == '__main__':
|
|||||||
while not server:
|
while not server:
|
||||||
server = anything('What server would you like to connect to?')
|
server = anything('What server would you like to connect to?')
|
||||||
try:
|
try:
|
||||||
socket.gethostbyname(server)
|
print 'Lookup up %s...' % server
|
||||||
|
ip = socket.gethostbyname(server)
|
||||||
|
print 'Found %s (%s).' % (server, ip)
|
||||||
except:
|
except:
|
||||||
print 'Sorry, but I couldn\'t find that server.'
|
print 'Sorry, but I couldn\'t find that server.'
|
||||||
server = ''
|
server = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user