Hi all...First python script and I'm getting an error I can't seem to get around using a config file. The first part of the script takes user input and puts that into a mysql database with no problem..Then I get to the filesystem work and things go a bit pear shaped..I can get it to work without using the config file options but I'd like to keep it consistent and pull from that file:
vshare = str(raw_input('Share the user needs access to: '))
vrights = str(raw_input('Should this user be Read Only? (y/n): '))
f = open("%s/%s" % (config['vsftp']['user_dir'], (vusername), 'wr'))
#f = open("/etc/vsftpd_user_conf/%s" % (vusername) , 'wr' )
f.write("local_root=%s/%s" % (config['vsftp']['local_root_dir'], vshare))
if vrights.lower() in ['y', 'ye', 'yes']:
buffer = []
for line in f.readlines():
if 'write_enable=' in line:
buffer.append('write_enable=NO')
else:
buffer.append(line)
f.writelines(buffer)
f.close()
The error I'm getting is:
TypeError: not all arguments converted during string formatting
If I uncomment the commented line it works and makes it a bit further and errors out as well..But I'll deal with that once I get this hiccup sorted..Thanks for any input.