标签:nta 代码 item 定义 dir theme mono get request
PLUGIN_ITEMS = { "nic": "src.plugins.nic.Nic", "disk": "src.plugins.disk.Disk", } API = "http://127.0.0.1:8000/api/server.html"
import sys import os import importlib import requests BASEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASEDIR) from conf import settings server_info = {} for k,v in settings.PLUGIN_ITEMS.items(): # 找到v字符串:src.plugins.nic.Nic,src.plugins.disk.Disk module_path,cls_name = v.rsplit(‘.‘,maxsplit=1) # rsplit,倒叙的split,maxsplit=1,第一个‘.‘ module = importlib.import_module(module_path) cls = getattr(module,cls_name) obj = cls() ret = obj.process() server_info[k] = ret requests.post( url=settings.API, data=server_info )
标签:nta 代码 item 定义 dir theme mono get request
原文地址:http://www.cnblogs.com/lucaq/p/7597618.html