File: save_report.py

package info (click to toggle)
knockpy 4.1.0-4
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 256 kB
  • sloc: python: 560; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 528 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import time
import json

def touch(filename):
	fname = filename
	file = open(fname, 'w')
	file.close()

def export(domain, report, _type):
	timestamp = time.time()
	filename = domain.replace('.', '_')+'_'+str(timestamp)+'.'+_type
	if _type == 'csv':
		csv_report = ''
		for item in report:
			csv_report += item + '\n'
		report = csv_report
	try:
		with open(filename, 'a') as f:
			f.write(report)
		f.close()
		return '\n'+_type.upper()+' report saved in: '+filename
	except: 
		return '\nCannot write report file: '+filename