I've attempted to write a small script that when ran successfully should return a menu of JBoss server instances. Below is the script.
import os
import sys
# Create Parent Menu
def parent_menu():
num = 1
menuItems = {}
files = os.listdir('/dsto/sw/dev/webapps/jbossEAP5.1/applications/jbossas/server')
os.system("clear")
print "Server Instances"
print "****************"
for file in files:
print "%d. %-3s" % (num, file)
menuItems[num] = file
num = num + 1
try:
print ""
selection = raw_input("Choose Server Instance: ")
print ""
print "You selected %s" % menuItems[int(selection)]
choice = menuItems[int(selection)]
return choice
except KeyError, ValueError:
print "%s is not a menu option!" % selection
exit
if __name__=="main":
parent_menu()
print "Main Executed"
else:
print "Main not executed"
The issue I am having is that when run flow falls to the 'else:' statement in the main mod and dies. My testing indicates that it doesn't like if __name__=="main":
If I take this script and place it on a Unix AIX machine it runs fine without issue.
Has anyone ever come across an instance where the main module doesn't process as expected that's similar to what I am seeing?
I should point out that if I remove the main module and run everything top to bottom it works fine but we may want to import this and use the methods here from another script.