def loadFingerprint(self, type, dirpath, filename):
finger_dict = {}
mod_name = filename.split('.')[0]
mod_dispname = '/'.join(re.split('/modules/' + type, dirpath)[-1].split('/') + [mod_name])
mod_loadname = mod_dispname.replace('/', '_')
mod_loadpath = os.path.join(dirpath, filename)
mod_file = open(mod_loadpath)
try:
# import the module into memory
imp.load_source(mod_loadname, mod_loadpath, mod_file)
# find the module and make an instace of it
_module = __import__(mod_loadname)
_class = getattr(_module, mod_name)
_instance = _class(self.config, self.display, self.modulelock)
finger_dict = {'fingerprint': _instance.getFingerprint(), mod_name: 'name'}
except Exception as e:
# notify the user of errors
print e
return None
return finger_dict
评论列表
文章目录