I keep getting the following error
g:\python_test>py3 lib\libtest.py p = g:\python_test\SqlLogon.txt Traceback (most recent call last): File "lib\libtest.py", line 43, in
i.printit('c:\mylog.log')
File "lib\libtest.py", line 32, in printit
s = wos()
NameError: name 'wos' is not defined
If i remove the call to os and let s = 'WINDOWS' everything works fine. Why can I not call that function?? following is the code giving the issue!
import sys
import platform
import os
import subprocess
class utl:
def __init__(self,path):
self.path = path
print ('p = ' + self.path)
def usr(self):
lc = open(self.path,'r')
up = lc.readlines()
u = up[0]
u = u.strip('\n')
p = up[1]
p = p.strip('\n')
return u,p
def wos(self):
p = platform.system()
print ('type = ' + str(type(p)))
return p.upper()
def printit(self,filetoprt):
s = wos() # undefined wos
#s = "WINDOWS"
print ('os1 = ' + s + ' ' + filetoprt)
if s == ('WINDOWS'):
os.startfile(filetoprt,'print')
#x = LogonSql.usr('g:\python_test\lib\jcd.txt')
i= utl('g:\python_test\SqlLogon.txt')
p = i.usr()
#t = i.wos()
i.printit('c:\mylog.log')