Coverage for src/robotide/publish/messages.py: 98%

168 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2008-2015 Nokia Networks 

2# Copyright 2016- Robot Framework Foundation 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15 

16import inspect 1ab

17import sys 1ab

18import traceback 1ab

19from .. import utils 1ab

20 

21 

22class RideMessage: 1ab

23 """Base class for all messages sent by RIDE. 

24 

25 :CVariables: 

26 topic 

27 Topic of this message. If not overridden, value is got from the class 

28 name by lowercasing it, separating words with a dot and dropping possible 

29 ``Message`` from the end. For example classes ``MyExample`` and 

30 ``AnotherExampleMessage`` get titles ``my.example`` and 

31 ``another.example``, respectively. 

32 data 

33 Names of attributes this message provides. These must be given as 

34 keyword arguments to `__init__` when an instance is created. 

35 """ 

36 

37 _topic = None 1ab

38 data = [] 1ab

39 

40 def __init__(self, **kwargs): 1ab

41 """Initializes message based on given keyword arguments. 

42 

43 Names of the given keyword arguments must match to names in `data` 

44 class attribute, otherwise the initialization fails. 

45 

46 Must be called explicitly by subclass if overridden. 

47 """ 

48 if sorted(kwargs.keys()) != sorted(self.data): 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eg h i P |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfc wfQ R S T U V W X Y Z xfyfzfAfBfCfDfMgNgOgPgQgRgEf0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfQfcgLgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

49 raise TypeError('Argument mismatch, expected: %s' % self.data) 2PgQgRg

50 self.__dict__.update(kwargs) 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eg h i P |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfc wfQ R S T U V W X Y Z xfyfzfAfBfCfDfMgNgOgEf0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfQfcgLgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

51 

52 @classmethod 1ab

53 def topic(cls): 1ab

54 if not cls._topic: 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eigjgkglgmgngogpgqgrgsgtgugvgwgxgg ygzgh Agi BgCgDgEgFgGgHgP |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfIgc wfQ R S T U V W fgX Y Z xfyfzfAfBfCfDfdgegEfgghg0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfJgQfKgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

55 cls_name = cls.__name__ 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eigjgkglgmgngogpgqgrgsgtgugvgwgxgg ygzgh Agi BgCgDgEgFgGgHgP |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfIgc wfQ R S T U V W fgX Y Z xfyfzfAfBfCfDfdgegEfgghg0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfJgQfKgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

56 if cls_name.endswith('Message'): 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eigjgkglgmgngogpgqgrgsgtgugvgwgxgg ygzgh Agi BgCgDgEgFgGgHgP |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfIgc wfQ R S T U V W fgX Y Z xfyfzfAfBfCfDfdgegEfgghg0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfJgQfKgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

57 cls_name = cls_name[:-len('Message')] 2a P c Q R S T U V W fgX Y Z dgeggghg0 1 2

58 topic_name = utils.printable_name(cls_name, code_style=True).replace(' ', '.') 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eigjgkglgmgngogpgqgrgsgtgugvgwgxgg ygzgh Agi BgCgDgEgFgGgHgP |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfIgc wfQ R S T U V W fgX Y Z xfyfzfAfBfCfDfdgegEfgghg0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfJgQfKgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

59 else: 

60 topic_name = cls._topic 2dgeg

61 return topic_name.lower() 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eigjgkglgmgngogpgqgrgsgtgugvgwgxgg ygzgh Agi BgCgDgEgFgGgHgP |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfIgc wfQ R S T U V W fgX Y Z xfyfzfAfBfCfDfdgegEfgghg0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfJgQfKgRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

62 

63 def publish(self): 1ab

64 """Publishes the message. 

65 

66 All listeners that have subscribed to the topic of this message will be 

67 called with this instance as an argument. 

68 

69 Notifications are sent sequentially. Due to the limitations of current 

70 implementation, if any of the listeners raises an exception, subsequent 

71 listeners will not get the notification. 

72 """ 

73 from robotide.publish.publisher import PUBLISHER 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eg h i P |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfc wfQ R S T U V W X Y Z xfyfzfAfBfCfDfEf0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfQfRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

74 PUBLISHER.publish(self.__class__, self) 2a 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? d @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcK L M N O GcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxde f ydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e]e^e_e`e{eg h i P |e}e~eafbfcfj dfk l efm ffgfn hfifjfkflfmfnfofpfqfrfsftfufvfc wfQ R S T U V W X Y Z xfyfzfAfBfCfDfEf0 1 o p q FfGfHf2 IfJfKfLfMfNfOfPfQfRfSfTfUfVfWfXfYfZf0f1f2f3f4f5f6f7f8f9f!f#f$f%f'f(f)f*f+f,f-f.f/f:fr s t ;f=fu v w x y z A B C D E F G H I J ?f@f[f]f^f_f`f{f|f}f~fagbg

75 

76 

77class RideLog(RideMessage): 1ab

78 """This class represents a general purpose log message. 

79 

80 Subclasses of this be may be used to inform error conditions or to provide 

81 some kind of debugging information. 

82 """ 

83 data = ['message', 'level', 'timestamp', 'notify_user'] 1ab

84 

85 

86class RideLogMessage(RideLog): 1ab

87 """This class represents a general purpose log message. 

88 

89 This message may be used to inform error conditions or to provide 

90 some kind of debugging information. 

91 """ 

92 data = ['message', 'level', 'timestamp', 'notify_user'] 1ab

93 

94 def __init__(self, message, level='INFO', notify_user=False): 1ab

95 """Initializes a RIDE log message. 

96 

97 The log ``level`` has default value ``INFO`` and the ``timestamp`` 

98 is generated automatically. 

99 """ 

100 RideMessage.__init__( 2a Lg

101 self, message=message, level=level, 

102 timestamp=utils.get_timestamp(), notify_user=notify_user) 

103 

104 

105class RideLogException(RideLog): 1ab

106 """This class represents a general purpose log message with a traceback 

107 appended to message text. Also, the original exception is included with 

108 the message. 

109 

110 This message may be used to inform error conditions or to provide 

111 some kind of debugging information. 

112 """ 

113 data = ['message', 'level', 'timestamp', 'exception', 'notify_user'] 1ab

114 

115 def __init__(self, message, exception, level='INFO', notify_user=False): 1ab

116 """Initializes a RIDE log exception. 

117 

118 The log ``level`` has default value ``INFO`` and the ``timestamp`` 

119 is generated automatically. Message is automatically appended with 

120 a traceback. 

121 """ 

122 _, _, exc_traceback = sys.exc_info() 2a d e f g h i j k l m n c o p q cgr s t u v w x y z A B C D E F G H I J

123 if exc_traceback: 123 ↛ 127line 123 didn't jump to line 127 because the condition on line 123 was always true2a d e f g h i j k l m n c o p q cgr s t u v w x y z A B C D E F G H I J

124 tb = traceback.extract_tb(exc_traceback) 2a d e f g h i j k l m n c o p q cgr s t u v w x y z A B C D E F G H I J

125 message += '\n\nTraceback (most recent call last):\n%s\n%s' % \ 2a d e f g h i j k l m n c o p q cgr s t u v w x y z A B C D E F G H I J

126 (str(exception), ''.join(traceback.format_list(tb))) 

127 RideMessage.__init__( 2a d e f g h i j k l m n c o p q cgr s t u v w x y z A B C D E F G H I J

128 self, message=message, level=level, notify_user=notify_user, 

129 timestamp=utils.get_timestamp(), exception=exception) 

130 

131 

132class RideParserLogMessage(RideMessage): 1ab

133 """This class represents a general purpose log message. 

134 

135 This message may be used to inform parser errors and to provide 

136 some kind of debugging information. 

137 """ 

138 data = ['message', 'level', 'timestamp', 'notify_user'] 1ab

139 

140 def __init__(self, message, level='', notify_user=False): 1ab

141 """Initializes a RIDE log message. 

142 

143 The log ``level`` has default value ``WARN`` and the ``timestamp`` 

144 is generated automatically. 

145 """ 

146 RideMessage.__init__( 

147 self, message=message, level=level, 

148 timestamp=utils.get_timestamp(), notify_user=notify_user) 

149 

150 

151class RideInputValidationError(RideMessage): 1ab

152 """Sent whenever user input is invalid.""" 

153 data = ['message'] 1ab

154 

155 

156class RideModificationPrevented(RideMessage): 1ab

157 """Sent whenever modifying command is prevented for some reason""" 

158 data = ['controller'] 1ab

159 

160 

161class RideSettingsChanged(RideMessage): 1ab

162 """Sent when settings are changed 

163 

164 keys is a tuple of key names. For example, if the "Grid Colors" section 

165 was modified the keys would be ("Grid Colors"), or a specific plugin 

166 setting might be ("Plugin", "Preview", "format"). 

167 `old` and `new` contain the old and the new value of the setting. 

168 """ 

169 data = ['keys', 'old', 'new'] 1ab

170 

171 

172class RideExecuteSpecXmlImport(RideMessage): 1ab

173 """Sent whenever spec xml import is requested""" 

174 

175 

176class RideTreeSelection(RideMessage): 1ab

177 """Sent whenever user selects a node from the tree.""" 

178 data = ['node', 'item', 'silent'] 1ab

179 

180 

181class RideOpenVariableDialog(RideMessage): 1ab

182 """Sent when variable dialog is requested to be open""" 

183 data = ['controller'] 1ab

184 

185 

186class RideTestExecutionStarted(RideMessage): 1ab

187 """Sent whenever new test execution is started.""" 

188 data = ['results'] 1ab

189 

190 

191class RideTestSelectedForRunningChanged(RideMessage): 1ab

192 """Sent whenever a test is selected or unselected from the tree.""" 

193 data = ['tests'] 1ab

194 

195 

196class RideTestRunning(RideMessage): 1ab

197 """Sent whenever RIDE is starting to run a test case.""" 

198 data = ['item'] 1ab

199 

200 

201class RideTestPaused(RideMessage): 1ab

202 """Sent whenever RIDE is running a test case and paused.""" 

203 data = ['item'] 1ab

204 

205 

206class RideTestPassed(RideMessage): 1ab

207 """Sent whenever RIDE has executed a test case, and it passed.""" 

208 data = ['item'] 1ab

209 

210 

211class RideTestFailed(RideMessage): 1ab

212 """Sent whenever RIDE has executed a test case, and it failed.""" 

213 data = ['item'] 1ab

214 

215 

216class RideTestSkipped(RideMessage): 1ab

217 """Sent whenever RIDE has executed a test case, and it was skipped.""" 

218 data = ['item'] 1ab

219 

220 

221class RideTestStopped(RideMessage): 1ab

222 """Sent whenever RIDE was executing a test case, and it was stopped or aborted.""" 

223 data = ['item'] 1ab

224 

225 

226class RideNotebookTabChanging(RideMessage): 1ab

227 """Sent when the notebook tab change has started. 

228 

229 Subscribing to this event allows the listener to do something before the 

230 tab has actually changed in the UI. 

231 """ 

232 data = ['oldtab', 'newtab'] 1ab

233 

234 

235class RideNotebookTabChanged(RideMessage): 1ab

236 """Sent after the notebook tab change has completed.""" 

237 pass 1ab

238 

239 

240class RideSaving(RideMessage): 1ab

241 """Sent when user selects Save from File menu or via shortcut. 

242 

243 This is used for example to store current changes from editor to data 

244 model, to guarantee that all changes are really saved.""" 

245 data = ['path', 'datafile'] 1ab

246 

247 

248class RideBeforeSaving(RideMessage): 1ab

249 """Sent before files are going to be saved.""" 

250 pass 1ab

251 

252 

253class RideSaved(RideMessage): 1ab

254 """Sent after the file has been actually saved to disk.""" 

255 data = ['path'] 1ab

256 

257 

258class RideSaveAll(RideMessage): 1ab

259 """Sent when user selects ``Save All`` from ``File`` menu or via shortcut.""" 

260 pass 1ab

261 

262 

263class RideDataDirtyCleared(RideMessage): 1ab

264 """Sent when datafiles dirty marking is cleared 

265 

266 datafile has been saved and datafile in memory equals the serialized one. 

267 """ 

268 data = ['datafile'] 1ab

269 

270 

271class RideNewProject(RideMessage): 1ab

272 """Sent when a new project has been created.""" 

273 data = ['path', 'datafile'] 1ab

274 

275 

276class RideClosing(RideMessage): 1ab

277 """Sent when user selects ``Quit`` from ``File`` menu or via shortcut.""" 

278 pass 1ab

279 

280 

281class RideOpenSuite(RideMessage): 1ab

282 """Sent when a new suite has finished loading.""" 

283 data = ['path', 'datafile'] 1ab

284 

285 

286class RideOpenResource(RideMessage): 1ab

287 """Sent when a new resource has finished loading.""" 

288 data = ['path', 'datafile'] 1ab

289 

290 

291class RideSelectResource(RideMessage): 1ab

292 """Sent when a resource should be selected.""" 

293 data = ['item'] 1ab

294 

295 

296class RideDataChanged(RideMessage): 1ab

297 """Base class for all messages notifying that data in model has changed.""" 

298 pass 1ab

299 

300 

301class RideFileNameChanged(RideDataChanged): 1ab

302 """Sent after test suite or resource file is renamed""" 

303 data = ['datafile', 'old_filename'] 1ab

304 

305 

306class RideDataFileRemoved(RideDataChanged): 1ab

307 data = ['path', 'datafile'] 1ab

308 

309 

310class RideSuiteAdded(RideDataChanged): 1ab

311 data = ['parent', 'suite'] 1ab

312 

313 

314class RideInitFileRemoved(RideDataChanged): 1ab

315 data = ['path', 'datafile'] 1ab

316 

317 

318class RideImportSetting(RideDataChanged): 1ab

319 """Base class for all messages about changes to import settings.""" 

320 data = ['datafile', 'type', 'import_controller'] 1ab

321 

322 def is_resource(self): 1ab

323 return self.type == 'resource' 

324 

325 @property 1ab

326 def name(self): 1ab

327 return self.import_controller.name 1KLMNO

328 

329 

330class _RideExcludes(RideMessage): 1ab

331 data = ['old_controller', 'new_controller'] 1ab

332 

333 

334class RideIncludesChanged(_RideExcludes): 1ab

335 pass 1ab

336 

337 

338class RideExcludesChanged(_RideExcludes): 1ab

339 pass 1ab

340 

341 

342class RideImportSettingAdded(RideImportSetting): 1ab

343 """Sent whenever an import setting is added. 

344 

345 ``datafile`` is the suite or resource file whose imports have changed, 

346 ``type`` is either ``resource``, ``library``, or ``variables``. 

347 """ 

348 pass 1ab

349 

350 

351class RideImportSettingChanged(RideImportSetting): 1ab

352 """Sent whenever a value of import setting is changed. 

353 

354 ``datafile`` is the suite or resource file whose imports have changed, 

355 ``type`` is either ``resource``, ``library``, or ``variables``. 

356 """ 

357 pass 1ab

358 

359 

360class RideImportSettingRemoved(RideImportSetting): 1ab

361 """Sent whenever a value of import setting is removed. 

362 

363 ``datafile`` is the suite or resource file whose imports have removed, 

364 ``type`` is either ``resource``, ``library``, or ``variables``. 

365 """ 

366 pass 1ab

367 

368 

369class RideDataChangedToDirty(RideDataChanged): 1ab

370 """Sent when datafile changes from serialized version""" 

371 data = ['datafile'] 1ab

372 

373 

374class RideDataFileSet(RideDataChanged): 1ab

375 """Set when a whole datafile is replaced with new one in a controller 

376 """ 

377 data = ['item'] 1ab

378 

379 

380class RideUserKeyword(RideDataChanged): 1ab

381 """Base class for all messages about changes to any user keyword.""" 

382 pass 1ab

383 

384 

385class RideUserKeywordAdded(RideUserKeyword): 1ab

386 """Sent when a new user keyword is added to a suite or resource.""" 

387 data = ['datafile', 'name', 'item'] 1ab

388 

389 

390class RideUserKeywordRemoved(RideUserKeyword): 1ab

391 """Sent when a user keyword is removed from a suite or resource.""" 

392 data = ['datafile', 'name', 'item'] 1ab

393 

394 

395class RideUserKeywordRenamed(RideUserKeyword): 1ab

396 """Sent after a user keyword is renamed""" 

397 data = ['datafile', 'item', 'old_name'] 1ab

398 

399 

400class RideItem(RideDataChanged): 1ab

401 """Base class for all messages about changes to any data item.""" 

402 data = ['item'] 1ab

403 

404 

405class RideItemStepsChanged(RideItem): 1ab

406 """""" 

407 pass 1ab

408 

409 

410class RideItemNameChanged(RideItem): 1ab

411 """""" 

412 data = ['item', 'old_name', 'new_name'] 1ab

413 

414 

415class RideItemSettingsChanged(RideItem): 1ab

416 """""" 

417 pass 1ab

418 

419 

420class RideTestCaseAdded(RideDataChanged): 1ab

421 """Sent when a new test case is added to a suite.""" 

422 data = ['datafile', 'name', 'item'] 1ab

423 

424 

425class RideTestCaseRemoved(RideDataChanged): 1ab

426 """Sent when a test case is removed from a suite.""" 

427 data = ['datafile', 'name', 'item'] 1ab

428 

429 

430class RideItemMovedUp(RideDataChanged): 1ab

431 """Sent when an item (test, keyword, variable) is moved up.""" 

432 data = ['item'] 1ab

433 

434 

435class RideItemMovedDown(RideDataChanged): 1ab

436 """Sent when an item (test, keyword, variable) is moved down.""" 

437 data = ['item'] 1ab

438 

439 

440class RideVariableAdded(RideDataChanged): 1ab

441 """Sent when a new variable is added to a suite.""" 

442 data = ['datafile', 'name', 'item', 'index'] 1ab

443 

444 

445class RideVariableRemoved(RideDataChanged): 1ab

446 """Sent when a variable is removed from a suite.""" 

447 data = ['datafile', 'name', 'item'] 1ab

448 

449 

450class RideVariableMovedUp(RideItemMovedUp): 1ab

451 """Sent when a variable is moved up 

452 item is the item that has been moved up 

453 other is the item that was swapped down 

454 """ 

455 data = ['item', 'other'] 1ab

456 

457 

458class RideVariableMovedDown(RideItemMovedDown): 1ab

459 """Sent when a variable is moved down 

460 item is the item that has been moved down 

461 other is the item that was swapped up 

462 """ 

463 data = ['item', 'other'] 1ab

464 

465 

466class RideVariableUpdated(RideDataChanged): 1ab

467 """Sent when the state of a variable is changed""" 

468 data = ['item'] 1ab

469 

470 

471class RideOpenTagSearch(RideMessage): 1ab

472 """ Sent we when want to open Search Tags """ 

473 data = ['includes', 'excludes'] 1ab

474 

475 

476class RideTreeAwarePluginAdded(RideMessage): 1ab

477 data = ['plugin'] 1ab

478 

479 

480class RideRunnerStarted(RideMessage): 1ab

481 """ Sent when a process is started at Runner/RunAnything """ 

482 data = ['process'] 1ab

483 

484class RideRunnerStopped(RideMessage): 1ab

485 """ Sent when a process is stopped at Runner/RunAnything """ 

486 data = ['process'] 1ab

487 

488 

489__all__ = [name for name, cls in globals().items() 1ab

490 if inspect.isclass(cls) and issubclass(cls, RideMessage)]