summaryrefslogtreecommitdiff
blob: fda6c3545c12d69302b029ec578186c6e7937c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Implements storage of collected log files in the local filesystem.
"""

import os, errno

class FilesystemStorage:
	def __init__(self, root):
		self.root = root
		try:
			os.mkdir(root)
		except OSError:
			pass # TODO: proper handling

	def save_file(self, source, filename, data):
		try:
			os.mkdir(os.path.join(self.root, source))
		except OSError:
			pass # TODO: proper handling

		path = os.path.join(self.root, source, os.path.basename(filename)) # TODO: consider adding in date at some point
		with open(path, 'wb') as f:
			f.write(data)