Added a --no-network option.

This commit is contained in:
Jeremy Fincher 2004-09-08 22:43:29 +00:00
parent f496c804a2
commit 87f42e0bee
1 changed files with 14 additions and 7 deletions

View File

@ -154,6 +154,10 @@ def main():
'run as root. You don\'t want this. Don\'t do it.' 'run as root. You don\'t want this. Don\'t do it.'
' Even if you think you want it, you don\'t. ' ' Even if you think you want it, you don\'t. '
'You\'re probably dumb if you do this.') 'You\'re probably dumb if you do this.')
parser.add_option('', '--no-network', action='store_false',
dest='network',
help='Determines whether the wizard will be allowed to '
'run without a network connection.')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if os.name == 'posix': if os.name == 'posix':
if (os.getuid() == 0 or os.geteuid() == 0) and not options.allowRoot: if (os.getuid() == 0 or os.geteuid() == 0) and not options.allowRoot:
@ -278,13 +282,16 @@ def main():
while not ip: while not ip:
serverString = something('What server would you like to connect to?', serverString = something('What server would you like to connect to?',
default=defaultServer) default=defaultServer)
try: if options.network:
output("""Looking up %s...""" % serverString) try:
ip = socket.gethostbyname(serverString) output("""Looking up %s...""" % serverString)
except: ip = socket.gethostbyname(serverString)
output("""Sorry, I couldn't find that server. Perhaps you except:
misspelled it? Also, be sure not to put the port in the server's output("""Sorry, I couldn't find that server. Perhaps you
name -- we'll ask you about that later.""") misspelled it? Also, be sure not to put the port in the
server's name -- we'll ask you about that later.""")
else:
ip = 'no network available'
output("""Found %s (%s).""" % (serverString, ip)) output("""Found %s (%s).""" % (serverString, ip))
output("""IRC Servers almost always accept connections on port output("""IRC Servers almost always accept connections on port