Merge "Make PluginWithSuchNameExists more informative"
This commit is contained in:
commit
31d34f4c82
@ -13,6 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from rally.common.plugin import discover
|
from rally.common.plugin import discover
|
||||||
from rally.common.plugin import info
|
from rally.common.plugin import info
|
||||||
from rally.common.plugin import meta
|
from rally.common.plugin import meta
|
||||||
@ -142,13 +144,17 @@ class Plugin(meta.MetaMixin, info.InfoMixin):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _set_name_and_namespace(cls, name, namespace):
|
def _set_name_and_namespace(cls, name, namespace):
|
||||||
try:
|
try:
|
||||||
Plugin.get(name, namespace=namespace)
|
existing_plugin = Plugin.get(name, namespace=namespace)
|
||||||
except exceptions.PluginNotFound:
|
except exceptions.PluginNotFound:
|
||||||
cls._meta_set("name", name)
|
cls._meta_set("name", name)
|
||||||
cls._meta_set("namespace", namespace)
|
cls._meta_set("namespace", namespace)
|
||||||
else:
|
else:
|
||||||
raise exceptions.PluginWithSuchNameExists(name=name,
|
raise exceptions.PluginWithSuchNameExists(
|
||||||
namespace=namespace)
|
name=name, namespace=namespace,
|
||||||
|
existing_path=(
|
||||||
|
sys.modules[existing_plugin.__module__].__file__),
|
||||||
|
new_path=sys.modules[cls.__module__].__file__
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _set_deprecated(cls, reason, rally_version):
|
def _set_deprecated(cls, reason, rally_version):
|
||||||
|
@ -90,7 +90,9 @@ class PluginNotFound(NotFoundException):
|
|||||||
|
|
||||||
class PluginWithSuchNameExists(RallyException):
|
class PluginWithSuchNameExists(RallyException):
|
||||||
msg_fmt = _("Plugin with such name: %(name)s already exists in "
|
msg_fmt = _("Plugin with such name: %(name)s already exists in "
|
||||||
"%(namespace)s namespace")
|
"%(namespace)s namespace. It's module allocates at "
|
||||||
|
"%(existing_path)s. You are trying to add plugin whose module "
|
||||||
|
"allocates at %(new_path)s.")
|
||||||
|
|
||||||
|
|
||||||
class NoSuchConfigField(NotFoundException):
|
class NoSuchConfigField(NotFoundException):
|
||||||
|
Loading…
Reference in New Issue
Block a user