Beispiel #1
0
def createdb():
       foo = Couch('localhost', '5984')
       print "\nCreate database 'mydb':"
       foo.createDb('mydb')
		if thread.is_alive():
			print "terminating process"
			self.process.terminate()
			thread.join()

		# timeout sees -15, normal sees 0x
		log.returnCode = self.process.returncode

		jsonString = json.dumps(log, default=lambda o: o.__dict__)
		print jsonString
		db.saveDoc('traceroute', jsonString)

		
f = open('urllist.txt', 'r')
db = Couch('localhost', '5984')
db.createDb('traceroute')

logFile = open(str(strftime("%Y-%m-%d %H:%M:%S", gmtime())), 'w')

for line in f:
	if line[0] == '#' or line[0] == '\n' or len(line) == 0:
		continue
	url = urlparse(line.partition(" ")[0])
	print "url     :", url.netloc
	print "comments:", line[line.index(' ') + 1:]
	command = Command(['traceroute', '-a', '-q 5', url.netloc], 20)
	command.run()

logFile.close()