def upload_plugin(self, filename, path): main_deferred = Deferred() shutil.copyfile(path, os.path.join(get_config_dir(), "plugins", filename)) component.get("Web.PluginManager").scan_for_plugins() if client.is_localhost(): client.core.rescan_plugins() return True plugin_data = base64.encodestring(open(path, "rb").read()) def on_upload_complete(*args): client.core.rescan_plugins() component.get("Web.PluginManager").scan_for_plugins() main_deferred.callback(True) def on_upload_error(*args): main_deferred.callback(False) d = client.core.upload_plugin(filename, plugin_data) d.addCallback(on_upload_complete) d.addErrback(on_upload_error) return main_deferred