Exemplo n.º 1
0
    def get_imp_list(self, account, checked, page_num):
        '''
            Get Imp list
        '''
        page_num = int(page_num)
        page_size = self.settings.get('page_size')
        imp_list = []

        # remove phone_2, phone_3 and imp_requests from query stuff and db.
        query = self.db.imps.find(
            {
                'account':account,
                'checked':checked
            },
            {
                '_id':0,
                'phone_2':0,
                'phone_3':0,
                'imp_requests':0
            }
        )

        q = query

        q = q.sort([('_id', -1)]).skip(int(page_num) * page_size).limit(page_size)

        try:
            while (yield q.fetch_next):
                imp = imps.Imp(q.next_object())
                imp_list.append(clean_structure(imp))
        except Exception, e:
            logging.exception(e)
            raise gen.Return(e)
Exemplo n.º 2
0
 def new_index(self, struct):
     '''
         New Index
     ''' 
     try:
         index = indexes.Index(struct)
         index.validate()
         index = clean_structure(index)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 3
0
 def replace_nodes(self, account, node_uuid, struct):
     '''
         Replace nodes
     '''
     try:
         nodes = nodes.Nodes(struct)
         nodes.validate()
         nodes = clean_structure(nodes)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 4
0
 def new_node(self, struct):
     '''
         New node
     '''
     try:
         node = nodes.Nodes(struct)
         node.validate()
         node = clean_structure(node)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 5
0
 def replace_imp(self, account, imp_uuid, struct):
     '''
         Replace Imp
     '''
     try:
         imp = imps.imp(struct)
         imp.validate()
         imp = clean_structure(imp)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 6
0
 def modify_imp(self, account, imp_uuid, struct):
     '''
         Modify Imp
     '''
     try:
         imp = imps.Modifyimp(struct)
         imp.validate()
         imp = clean_structure(imp)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 7
0
 def modify_nodes(self, account, node_uuid, struct):
     '''
         Modify nodes
     '''
     try:
         nodes = nodes.ModifyNodes(struct)
         nodes.validate()
         nodes = clean_structure(nodes)
     except Exception, e:
         logging.error(e)
         message = str(e)
         raise e
Exemplo n.º 8
0
 def new_imp(self, struct):
     '''
         New Imp
     '''
     # if check dir fail remove directory uuid
     if not struct.get('has_directory', False):
         struct.pop('directory_uuid', None)
         
     try:
         imp = imps.imp(struct)
         imp.validate()
         imp = clean_structure(imp)
     except Exception, e:
         logging.error(e)
         raise e
Exemplo n.º 9
0
 def get_node(self, account, node_uuid):
     '''
         Get node
     '''
     message = None
     try:
         result = yield self.db.nodes.find_one(
             {
             'account':account,
             'uuid':node_uuid},
             {'_id':0, 'resources.imps.contains':0} # resources.imps or nodes?
         )
         if result:
             node = nodes.Nodes(result)
             node.validate()
             message = clean_structure(node)
     except Exception, e:
         # e is for error
         logging.exception(e)
         raise e
Exemplo n.º 10
0
    def get_imp(self, account, imp_uuid):
        '''
            Get Imp
        '''
        message = None
        logging.info('{0} get imp {1}'.format(account, imp_uuid))
        try:
            result = yield self.db.imps.find_one(
                {'account':account,
                 'uuid': imp_uuid},
                {'_id':0, 'phone_2':0, 'phone_3':0, 'imp_requests':0} # remove this stuff from db.
            )

            logging.info('{0} this is the result'.format(str(result)))
            if result:
                imp = imps.imp(result)
                imp.validate()
                message = clean_structure(imp)
        except Exception, e:
            logging.exception(e)
            raise e