def join_grid(self, settings): nickname = settings['nickname'] if self.use_tor: msg = "Connecting to {} via Tor...".format(nickname) else: msg = "Connecting to {}...".format(nickname) self.update_progress.emit(msg) icon_path = None if nickname == 'Least Authority S4': icon_path = resource('leastauthority.com.icon') self.got_icon.emit(icon_path) elif 'icon_base64' in settings: icon_path = os.path.join(config_dir, '.icon.tmp') self.decode_icon(settings['icon_base64'], icon_path) elif 'icon_url' in settings: # A temporary(?) measure to get around the performance issues # observed when transferring a base64-encoded icon through Least # Authority's wormhole server. Hopefully this will go away.. See: # https://github.com/LeastAuthority/leastauthority.com/issues/539 log.debug("Fetching service icon from %s...", settings['icon_url']) icon_path = os.path.join(config_dir, '.icon.tmp') try: # It's probably not worth cancelling or holding-up the setup # process if fetching/writing the icon fails (particularly # if doing so would require the user to get a new invite code) # so just log a warning for now if something goes wrong... yield self.fetch_icon(settings['icon_url'], icon_path) except Exception as e: # pylint: disable=broad-except log.warning("Error fetching service icon: %s", str(e)) executable = yield select_executable() nodedir = os.path.join(config_dir, nickname) self.gateway = Tahoe(nodedir, executable=executable) yield self.gateway.create_client(**settings) newscap = settings.get('newscap') if newscap: with open(os.path.join(nodedir, 'private', 'newscap'), 'w') as f: f.write(newscap) if icon_path: try: shutil.copy(icon_path, os.path.join(nodedir, 'icon')) except OSError as err: log.warning("Error copying icon file: %s", str(err)) if 'icon_url' in settings: try: with open(os.path.join(nodedir, 'icon.url'), 'w') as f: f.write(settings['icon_url']) except OSError as err: log.warning("Error writing icon url to file: %s", str(err)) self.update_progress.emit(msg) yield self.gateway.start() self.client_started.emit(self.gateway) self.update_progress.emit(msg) yield self.gateway.await_ready()
def select_executable(self): self.executable = yield select_executable() logging.debug("Selected executable: %s", self.executable) if not self.executable: msg.critical( "Tahoe-LAFS not found", "Could not find a suitable 'tahoe' executable in your PATH. " "Please install Tahoe-LAFS (version >= 1.12) and try again.") reactor.stop()