def test_tahoe_get_features_no_magic_folder_support(tahoe, monkeypatch): monkeypatch.setattr( 'gridsync.tahoe.Tahoe.command', MagicMock( side_effect=TahoeCommandError('Unknown command: magic-folder'))) output = yield tahoe.get_features() assert output == ('tahoe_exe', False, False)
def _win32_popen(self, args, env, callback_trigger=None): # This is a workaround to prevent Command Prompt windows from opening # when spawning tahoe processes from the GUI on Windows, as Twisted's # reactor.spawnProcess() API does not allow Windows creation flags to # be passed to subprocesses. By passing 0x08000000 (CREATE_NO_WINDOW), # the opening of the Command Prompt window will be surpressed while # still allowing access to stdout/stderr. See: # https://twistedmatrix.com/pipermail/twisted-python/2007-February/014733.html import subprocess proc = subprocess.Popen(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, creationflags=0x08000000) output = BytesIO() for line in iter(proc.stdout.readline, ''): output.write(line.encode('utf-8')) self.line_received(line.rstrip()) if callback_trigger and callback_trigger in line.rstrip(): return proc.pid proc.poll() if proc.returncode: raise TahoeCommandError(str(output.getvalue()).strip()) else: return str(output.getvalue()).strip()
def test_tahoe_get_features_no_multi_magic_folder_support(tahoe, monkeypatch): monkeypatch.setattr( "gridsync.tahoe.Tahoe.command", MagicMock(side_effect=TahoeCommandError("Unknown command: list")), ) output = yield tahoe.get_features() assert output == ("tahoe_exe", True, False)
def processExited(self, reason): if not self.done.called and not isinstance(reason.value, ProcessDone): self.done.errback( TahoeCommandError( self.output.getvalue().decode('utf-8').strip()))