- f=open(file,'w')
- now=time.strftime("Last update: %Y.%m.%d at %H:%M:%S %Z", time.localtime())
- f.write(now+'\n')
- if message: f.write('Message:'+message+'\n')
- pp=pprint.PrettyPrinter(stream=f,indent=2)
- pp.pprint(data)
- f.close()
- verbose("logger:.log_data_in_file Owerwrote %s"%file)
+ with open(file, 'w') as f:
+ now=time.strftime("Last update: %Y.%m.%d at %H:%M:%S %Z", time.localtime())
+ f.write(now+'\n')
+ if message: f.write('Message:'+message+'\n')
+ pp=pprint.PrettyPrinter(stream=f, indent=2)
+ pp.pprint(data)
+ f.close()
+ verbose("logger:.log_data_in_file Owerwrote %s"%file)