<s> from amonone . web . apps . core . basemodel import BaseModel <EOL> from amonone . web . utils import generate_api_key <EOL> from amonone . utils . dates import unix_utc_now <EOL> from amonone . web . apps . core . models import server_model <EOL> class DataModel ( BaseModel ) : <EOL> def __init__ ( self ) : <EOL> super ( DataModel , self ) . __init__ ( ) <EOL> self . protected_collections = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def get_database_info ( self ) : <EOL> return self . db . command ( '<STR_LIT>' ) <EOL> def get_server_collection_stats ( self ) : <EOL> all_servers = server_model . get_all ( ) <EOL> data = { } <EOL> if all_servers : <EOL> for server in all_servers : <EOL> system_collection = self . mongo . get_server_system_collection ( server ) <EOL> process_collection = self . mongo . get_server_processes_collection ( server ) <EOL> system_info = self . get_collection_stats ( system_collection . name ) <EOL> process_info = self . get_collection_stats ( process_collection . name ) <EOL> data [ server [ '<STR_LIT:name>' ] ] = { "<STR_LIT>" : system_info , <EOL> "<STR_LIT>" : process_info , <EOL> "<STR_LIT>" : server [ '<STR_LIT>' ] <EOL> } <EOL> return data <EOL> def get_collection_stats ( self , collection ) : <EOL> try : <EOL> stats = self . db . command ( '<STR_LIT>' , collection ) <EOL> except : <EOL> stats = None <EOL> return stats <EOL> def cleanup_system_collection ( self , server , date ) : <EOL> collection = self . mongo . get_server_system_collection ( server ) <EOL> params = { } <EOL> if date != None : <EOL> params [ '<STR_LIT:time>' ] = { "<STR_LIT>" : date } <EOL> collection . remove ( params ) <EOL> def cleanup_process_collection ( self , server , date ) : <EOL> collection = self . mongo . get_server_processes_collection ( server ) <EOL> params = { } <EOL> if date != None : <EOL> params [ '<STR_LIT:time>' ] = { "<STR_LIT>" : date } <EOL> collection . remove ( params ) <EOL> def delete_system_collection ( self , server ) : <EOL> system_collection = self . mongo . get_server_system_collection ( server ) <EOL> self . db . drop_collection ( system_collection ) <EOL> def delete_process_collection ( self , server ) : <EOL> process_collection = self . mongo . get_server_processes_collection ( server ) <EOL> self . db . drop_collection ( process_collection ) <EOL> data_model = DataModel ( ) </s>
