示例#1
0
    def get(self, modelName, *args, **kwargs):
        package, aimModel = self.getModelByName(modelName)
        if aimModel is None:
            self._reason = '您所请求的模型不存在或者并未被注册'
            self._status_code = 404
            self.write_error(404)
            return None
        # show this models
        # get all valid field
        allValidField = self.getValidFieldByModel(aimModel)
        allFieldName = [getattr(aimModel, foo)
                        for (foo, instance) in allValidField]
        # set up query
        total_record_cnt = aimModel.select().count()
        query = (aimModel
                 .select(*allFieldName)
                 )
        # for foo in query:
        #    for attrName in [f o for (fo,instance) in allValidField]:
        #        print attrName,getattr(foo,attrName)

        modelsFinder = modelFinder()
        # a tuple containing three element : app,className,class
        modelsList = modelsFinder.getInstalledModel()

        args = locals()
        args.pop('self')
        self.render('templates/contrib/admin/tableData.html', **args)
示例#2
0
 def render(self, *args, **kwargs):
     from tjango.contrib.admin.utils import modelFinder
     modelsFinder = modelFinder()
     # a tuple containing three element : app,className,class
     modelsList = modelsFinder.getInstalledModel()
     args = locals()
     args.pop('self')
     return self.render_string('templates/contrib/admin/leftSideBar.html',
                               **args)
示例#3
0
    def getModelByName(self, modelName):
        '''
        get models by models's name
        :param modelName: models class
        :return:models class or None object
        '''
        modelFinderInstance = modelFinder()
        packageModels = modelFinderInstance.getInstalledModel()
        # traverse all list then find it

        for package, list in packageModels:
            for name, model in list:
                if name == modelName:
                    return package, model
        return None
示例#4
0
    def get(self, *args, **kwargs):
        import psutil
        import platform
        # cpu info
        logicalCPU = psutil.cpu_count(logical=True)
        physicsCPU = psutil.cpu_count(logical=False)

        # platform uname
        (system, node, release, version, machine, processor) = platform.uname()

        # cpu usage
        usedCPURate = psutil.cpu_percent(interval=1, percpu=False)

        # memory info
        mem = psutil.virtual_memory()

        # start time
        startTime = psutil.boot_time()

        # network statistics
        network = psutil.net_io_counters(pernic=False)

        from tjango.conf import setting
        Setting = setting()
        Setting._setup()

        logFileExist = getattr(Setting._wrapped, 'LOGFILE', False)

        modelsFinder = modelFinder()
        # a tuple containing three element : app,className,class
        modelsList = modelsFinder.getInstalledModel()

        # fill render parameter
        args = locals()
        args.pop('self')
        self.render('templates/contrib/admin/manage.html', **args)