Newbie -> NameError: getopt

M

Mustafa Cayci

Hello,

I followed several postings in Google and came up with the beginning of the
following code:
During the execution, I am getting

Problem invoking WLST - Traceback (innermost last):
File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line 80, in
?
File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line 22, in
main
NameError: getopt

I thought I was importing the "getopt" as shown below.

Thanks for you help in advance,
Mustafa



#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__':

from wlstModule import *#@UnusedWildImport
import sys
import os
from java.lang import System
import getopt

serverName = ''
portNumber = ''
ucf = ''
ukf = ''
adminURL = ''
protocolName = ''
portNumber = ''

def main(argv):

try:
opts, args = getopt.getopt(sys.argv[1:], "s:p:t:u:k:")
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(2)
....
 
R

R. Tyler Croy

Hello,

I followed several postings in Google and came up with the beginning of
the following code:
During the execution, I am getting

Problem invoking WLST - Traceback (innermost last):
File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line
80, in
?
File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line
22, in
main
NameError: getopt

I thought I was importing the "getopt" as shown below.

Try bringing your imports up out of the "if __name__" block. Where you are
referencing getopt (the main() function), the getopt module hasn't yet
been imported.

You can do something like this:

import getopt

def main():
# ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top