(attr, val, old)
| 881 | |
| 882 | |
| 883 | def _socket_changer(attr, val, old): |
| 884 | # type: (str, bool, bool) -> Any |
| 885 | if not isinstance(val, bool): |
| 886 | raise TypeError("This argument should be a boolean") |
| 887 | Interceptor.set_from_hook(conf, attr, val) |
| 888 | dependencies = { # Things that will be turned off |
| 889 | "use_pcap": ["use_bpf"], |
| 890 | "use_bpf": ["use_pcap"], |
| 891 | } |
| 892 | restore = {k: getattr(conf, k) for k in dependencies} |
| 893 | del restore[attr] # This is handled directly by _set_conf_sockets |
| 894 | if val: # Only if True |
| 895 | for param in dependencies[attr]: |
| 896 | Interceptor.set_from_hook(conf, param, False) |
| 897 | try: |
| 898 | _set_conf_sockets() |
| 899 | except (ScapyInvalidPlatformException, ImportError) as e: |
| 900 | for key, value in restore.items(): |
| 901 | Interceptor.set_from_hook(conf, key, value) |
| 902 | if isinstance(e, ScapyInvalidPlatformException): |
| 903 | raise |
| 904 | return getattr(conf, attr) |
| 905 | |
| 906 | |
| 907 | def _loglevel_changer(attr, val, old): |
nothing calls this directly
no test coverage detected