Browse Source

use a Storage class

Helge Jung 9 years ago
parent
commit
0fc6095792
3 changed files with 8 additions and 3 deletions
  1. 4 3
      batcave.py
  2. 2 0
      ffstatus/__init__.py
  3. 2 0
      ffstatus/storage.py

+ 4 - 3
batcave.py

@@ -45,11 +45,12 @@ if args.no_detach:
 
 logger.info('Starting up')
 
+storage = Storage()
+
 a = AlfredParser()
 b = BatmanParser()
 d = DashingClient(args.dashing_url, args.dashing_token) if not args.dashing_url is None else None
 g = GraphitePush(args.graphite_host, args.graphite_port) if not args.graphite_host is None else None
-data = { }
 
 if args.no_send:
 	if not g is None: g.dont_send = True
@@ -94,8 +95,8 @@ while True:
 			d.push(newdata)
 
 		logger.debug('Step 3/3: Merging current data ...')
-		data = dict_merge(data, newdata)
-		logger.info('I have data for ' + str(len(data)) + ' nodes.')
+		storage.data = dict_merge(storage.data, newdata)
+		logger.info('I have data for ' + str(len(storage.data)) + ' nodes.')
 	except Exception as err:
 		logger.error(str(err))
 

+ 2 - 0
ffstatus/__init__.py

@@ -4,10 +4,12 @@ from .alfred import AlfredParser
 from .batman import BatmanParser
 from .dashing import DashingClient
 from .graphite import GraphitePush
+from .storage import Storage
 
 __all__ = [
 	'AlfredParser', 'BatmanParser',
 	'DashingClient', 'GraphitePush',
+	'Storage',
 	'dict_merge', 'merge_alfred_batman', 'mac2id' ]
 
 def mac2id(mac):

+ 2 - 0
ffstatus/storage.py

@@ -0,0 +1,2 @@
+class Storage:
+	data = {}