Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/build/lib.linux-x86_64-2.7/stats_consolidation/consolidation.py
blob: a1fd79afd0a0e7f0437d747fe92a92de07b8df89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import print_function
import os
import argparse

import rrd_files
import db
from rrd_files import *
from db import *

class Consolidation:
	
	def __init__(self, path, db):
		self.base_path = path
		self.date_start = db.get_date_last_record()
		self.db = db	
	def process_rrds (self):
		id_hash_list = os.listdir(unicode(self.base_path))
		try:
			if id_hash_list:
				for id_hash in id_hash_list:
					user_hash_list = os.listdir( unicode( os.path.join(self.base_path, id_hash) ) )
					if user_hash_list:
						for user_hash in user_hash_list:
							rrd_list = os.listdir( unicode(os.path.join(self.base_path, id_hash, user_hash)) )
							if rrd_list:
								for rrd in rrd_list: 
									rrd_path = unicode (os.path.join(self.base_path, id_hash, user_hash) )
									rrd_obj = RRD (path=rrd_path, name=rrd, date_start=self.date_start, date_end=None)
									self.db.store_activity_uptime(rrd_obj)
							else:
								print ("RRD file not found: {}".format(os.path.join(self.base_path, id_hash, user_hash)))
					else:
						print ("None hash user found on: {}".format(os.path.join(self.base_path, id_hash)))	
			else:
				print ("None hash ids  found on: {}" + format(self.base_path))
		except Exception as e:
			print ("Error: {}".format(str(e)))