summaryrefslogtreecommitdiff
blob: 847806f8d92e1453354035b4ecd019f8a9c08ce6 (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, filename) # TODO: consider adding in date at some point
		with open(path, 'wb') as f:
			f.write(data)