def run(self, settings): if 'version' in settings and int(settings['version']) > 1: raise UpgradeRequiredError if self.use_tor or 'hide-ip' in settings or is_onion_grid(settings): settings['hide-ip'] = True self.use_tor = True tor = yield get_tor_with_prompt(reactor) if not tor: raise TorError("Could not connect to a running Tor daemon") self.gateway = self.get_gateway(settings.get('introducer'), settings.get('storage')) folders_data = settings.get('magic-folders') if not self.gateway: yield self.join_grid(settings) elif not folders_data: self.grid_already_joined.emit(settings.get('nickname')) yield self.ensure_recovery(settings) if folders_data: yield self.join_folders(folders_data) self.update_progress.emit('Done!') self.done.emit(self.gateway)
def run(self, settings): if "version" in settings and int(settings["version"]) > 1: raise UpgradeRequiredError if self.use_tor or "hide-ip" in settings or is_onion_grid(settings): settings["hide-ip"] = True self.use_tor = True tor = yield get_tor_with_prompt(reactor) if not tor: raise TorError("Could not connect to a running Tor daemon") self.gateway = self.get_gateway(settings.get("introducer"), settings.get("storage")) folders_data = settings.get("magic-folders") if not self.gateway: yield self.join_grid(settings) yield self.ensure_recovery(settings) elif not folders_data: self.grid_already_joined.emit(settings.get("nickname")) if folders_data: yield self.join_folders(folders_data) yield self.gateway.monitor.scan_rootcap() self.update_progress.emit("Done!") self.done.emit(self.gateway)
def test_get_tor_with_prompt_retry(monkeypatch): monkeypatch.setattr('gridsync.tor.get_tor', MagicMock(side_effect=[None, 'FakeTxtorcon'])) monkeypatch.setattr('PyQt5.QtWidgets.QMessageBox.exec_', MagicMock(return_value=QMessageBox.Retry)) tor = yield get_tor_with_prompt(None) assert tor == 'FakeTxtorcon'
def test_get_tor_with_prompt_abort(monkeypatch): monkeypatch.setattr("gridsync.tor.get_tor", MagicMock(return_value=None)) monkeypatch.setattr( "PyQt5.QtWidgets.QMessageBox.exec_", MagicMock(return_value=QMessageBox.Abort), ) tor = yield get_tor_with_prompt(None) assert tor is None