Пример #1
0
 def start_gateways(self):
     nodedirs = get_nodedirs(config_dir)
     if nodedirs:
         minimize_preference = get_preference('startup', 'minimize')
         if not minimize_preference or minimize_preference == 'false':
             self.gui.show_main_window()
         yield self.select_executable()
         tor_available = yield get_tor(reactor)
         logging.debug("Starting Tahoe-LAFS gateway(s)...")
         for nodedir in nodedirs:
             gateway = Tahoe(nodedir, executable=self.executable)
             tcp = gateway.config_get('connections', 'tcp')
             if tcp == 'tor' and not tor_available:
                 msg.error(
                     self.gui.main_window, "Error Connecting To Tor Daemon",
                     'The "{}" connection is configured to use Tor, '
                     'however, no running tor daemon was found.\n\n'
                     'This connection will be disabled until you launch '
                     'Tor again.'.format(gateway.name))
             self.gateways.append(gateway)
             d = gateway.start()
             d.addCallback(gateway.ensure_folder_links)
         self.gui.populate(self.gateways)
     else:
         self.gui.show_welcome_dialog()
         yield self.select_executable()
Пример #2
0
 def maybe_enable_tor_checkbox(self):
     tor = yield get_tor(reactor)
     if tor and not self.tor_checkbox.isEnabled():
         self.tor_checkbox.setEnabled(True)
         self.tor_checkbox_animation_in.start()
         self.tor_info_button_animation_in.start()
     elif not tor and self.tor_checkbox.isEnabled():
         self.tor_checkbox.setEnabled(False)
         self.tor_checkbox_animation_out.start()
         self.tor_info_button_animation_out.start()
Пример #3
0
 def fetch_icon(self, url, dest):
     agent = None
     if self.use_tor:
         tor = yield get_tor(reactor)
         if not tor:
             raise TorError("Could not connect to a running Tor daemon")
         agent = tor.web_agent()
     resp = yield treq.get(url, agent=agent)
     if resp.code == 200:
         content = yield treq.content(resp)
         log.debug("Received %i bytes", len(content))
         with atomic_write(dest, mode="wb", overwrite=True) as f:
             f.write(content)
         self.got_icon.emit(dest)
     else:
         log.warning("Error fetching service icon: %i", resp.code)
Пример #4
0
 def start_gateways(self):
     nodedirs = get_nodedirs(config_dir)
     if nodedirs:
         minimize_preference = get_preference("startup", "minimize")
         if not minimize_preference or minimize_preference == "false":
             self.gui.show_main_window()
         yield self.select_executable()
         tor_available = yield get_tor(reactor)
         logging.debug("Starting Tahoe-LAFS gateway(s)...")
         for nodedir in nodedirs:
             gateway = Tahoe(nodedir, executable=self.executable)
             tcp = gateway.config_get("connections", "tcp")
             if tcp == "tor" and not tor_available:
                 logging.error("No running tor daemon found")
                 msg.error(
                     self.gui.main_window,
                     "Error Connecting To Tor Daemon",
                     'The "{}" connection is configured to use Tor, '
                     "however, no running tor daemon was found.\n\n"
                     "This connection will be disabled until you launch "
                     "Tor again.".format(gateway.name),
                 )
             self.gateways.append(gateway)
             d = gateway.start()
             d.addCallback(gateway.ensure_folder_links)
         self.gui.populate(self.gateways)
     else:
         self.gui.show_welcome_dialog()
         yield self.select_executable()
     try:
         yield self.get_tahoe_version()
     except Exception as e:  # pylint: disable=broad-except
         logging.critical("Error getting Tahoe-LAFS version")
         msg.critical(
             "Error getting Tahoe-LAFS version",
             "{}: {}".format(type(e).__name__, str(e)),
         )
         reactor.stop()
Пример #5
0
def test_get_tor_return_none_feature_disabled(monkeypatch):
    monkeypatch.setattr(
        "gridsync.tor.settings", {"features": {"tor": "false"}}
    )
    tor = yield get_tor(None)
    assert tor is None
Пример #6
0
def test_get_tor_return_none(monkeypatch):
    fake_connect = MagicMock(side_effect=RuntimeError())
    monkeypatch.setattr("txtorcon.connect", fake_connect)
    tor = yield get_tor(None)
    assert tor is None
Пример #7
0
def test_get_tor(monkeypatch):
    fake_tor = MagicMock()
    monkeypatch.setattr("txtorcon.connect", lambda _: fake_tor)
    tor = yield get_tor(None)
    assert tor == fake_tor
Пример #8
0
 def maybe_enable_tor(self):
     tor = yield get_tor(reactor)
     if tor:
         self.mode_combobox.model().item(1).setEnabled(True)