コード例 #1
0
ファイル: controllers.py プロジェクト: nictuku/cacic3
 def _update_computer(self, set_machine, insert_only=False):
     """Updates the computer info in the database.
     Creates a new computer entry if needed.
     """
     # limpa valores desnecessários
     set_machine['dt_hr_ult_acesso'] = datetime.datetime.now()
     try:
         Computer.insert().execute(set_machine)
     except:
         pass
     if not insert_only:
         Computer.update(Computer.c.te_node_address==set_machine['te_node_address'],
             Computer.c.id_so==set_machine['id_so']
             ).execute(set_machine)
     return True
コード例 #2
0
ファイル: controllers.py プロジェクト: nictuku/cacic3
 def showreport(self, **kw):
     fields = kw['hardware']
     items = Computer.select ()
     # force conversion to str, since there is a check with isinstance,
     # and we don't want to have field names be something other than
     # ASCII anyway
     fields = [(field.title(), str(field.strip())) for field in fields]
     grid = DataGrid (fields = fields)
     return dict(grid = grid, items = items)
コード例 #3
0
ファイル: controllers.py プロジェクト: nictuku/cacic3
    def display(self, category, **kw):
        report_tables = []

        # get selected networks
        networks = kw.get('Networks', None)
        os_ids = kw.get('Operating Systems', None)

        # if none was selected, get all; there's probably a better way of handling
        # this, by conditionally adding where clauses to the reports selects
        if not networks:
            action = self._get_action_from_category(category)
            networks = [x[0] for x in self._get_network_items(action)]

        if not os_ids:
            os_ids = [x[0] for x in self._get_os_items()]

        # this may be needed
        # fields = self._get_mandatory_fields () + list(kw['Report Items'])
        fields = self._get_mandatory_fields () + kw['Report Items']

        if category == 'hardware':
            items = Computer.select (apply(Computer.c.netaddr.in_, networks))
            items = [item for item in items if str(item.os_id) in os_ids]
            count = 1
            for item in items:
                item.index = count
                item.os_name = item.opsys.name
                count += 1
            del count
            # force conversion to str, since there is a check with isinstance,
            # and we don't want to have field names be something other than
            # ASCII anyway
            fields = [(field.title(), str(field.strip())) for field in fields]
            grid = DataGrid (fields = fields)
            report_tables.append ((grid, items))

        if kw.has_key ('Statistics Items'):
            report_tables += self._get_statistics_tables (kw['Statistics Items'],
                                                          networks, os_ids)

        return dict(report_tables = report_tables)