Comparison

core/modulemanager.lua @ 1987:94ecd3e7be87

modulemanager: Fixed traceback on loading modules on unknown hosts.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 17 Oct 2009 23:50:09 +0500
parent 1986:d4ba9d94eb74
child 1988:a6e7fe0fc3dd
comparison
equal deleted inserted replaced
1986:d4ba9d94eb74 1987:94ecd3e7be87
102 return nil, "insufficient-parameters"; 102 return nil, "insufficient-parameters";
103 end 103 end
104 104
105 if not modulemap[host] then 105 if not modulemap[host] then
106 modulemap[host] = {}; 106 modulemap[host] = {};
107 hosts[host].modules = modulemap[host];
108 end 107 end
109 108
110 if modulemap[host][module_name] then 109 if modulemap[host][module_name] then
111 log("warn", "%s is already loaded for %s, so not loading again", module_name, host); 110 log("warn", "%s is already loaded for %s, so not loading again", module_name, host);
112 return nil, "module-already-loaded"; 111 return nil, "module-already-loaded";
126 125
127 local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); 126 local pluginenv = setmetatable({ module = api_instance }, { __index = _G });
128 127
129 setfenv(mod, pluginenv); 128 setfenv(mod, pluginenv);
130 if not hosts[host] then hosts[host] = { type = "component", host = host, connected = false, s2sout = {} }; end 129 if not hosts[host] then hosts[host] = { type = "component", host = host, connected = false, s2sout = {} }; end
130 hosts[host].modules = modulemap[host];
131 131
132 local success, ret = pcall(mod); 132 local success, ret = pcall(mod);
133 if not success then 133 if not success then
134 log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil"); 134 log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil");
135 return nil, ret; 135 return nil, ret;