(self)
| 130 | # command, and builds either an error message or a success message with |
| 131 | # some info from it. |
| 132 | def test(self): |
| 133 | try: |
| 134 | if self.nmctype == "namecoind": |
| 135 | try: |
| 136 | vers = self.callRPC("getinfo", [])["version"] |
| 137 | except RPCError: |
| 138 | vers = self.callRPC("getnetworkinfo", [])["version"] |
| 139 | |
| 140 | v3 = vers % 100 |
| 141 | vers = vers / 100 |
| 142 | v2 = vers % 100 |
| 143 | vers = vers / 100 |
| 144 | v1 = vers |
| 145 | if v3 == 0: |
| 146 | versStr = "0.%d.%d" % (v1, v2) |
| 147 | else: |
| 148 | versStr = "0.%d.%d.%d" % (v1, v2, v3) |
| 149 | return ('success', tr._translate("MainWindow",'Success! Namecoind version %1 running.').arg(unicode(versStr)) ) |
| 150 | |
| 151 | elif self.nmctype == "nmcontrol": |
| 152 | res = self.callRPC ("data", ["status"]) |
| 153 | prefix = "Plugin data running" |
| 154 | if ("reply" in res) and res["reply"][:len(prefix)] == prefix: |
| 155 | return ('success', tr._translate("MainWindow",'Success! NMControll is up and running.')) |
| 156 | |
| 157 | logger.error("Unexpected nmcontrol reply: %s", res) |
| 158 | return ('failed', tr._translate("MainWindow",'Couldn\'t understand NMControl.')) |
| 159 | |
| 160 | else: |
| 161 | assert False |
| 162 | |
| 163 | except Exception: |
| 164 | logger.info("Namecoin connection test failure") |
| 165 | return ( |
| 166 | 'failed', |
| 167 | tr._translate( |
| 168 | "MainWindow", "The connection to namecoin failed.") |
| 169 | ) |
| 170 | |
| 171 | # Helper routine that actually performs an JSON RPC call. |
| 172 | def callRPC (self, method, params): |
no test coverage detected