From 8c81033ea32f4804afb3b19d73f4c4f3e9901a8a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Nov 2024 15:20:06 +0100 Subject: [PATCH] FDroidPopenBytes: do not crash if options are not set This makes writing test cases a lot easier. For example: ====================================================================== ERROR: test_devices (tests.test_install.InstallTest.test_devices) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/hans/code/fdroid/server/tests/test_install.py", line 31, in test_devices devices = fdroidserver.install.devices() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/install.py", line 225, in devices p = common.SdkToolsPopen(['adb', "devices"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 2921, in SdkToolsPopen return FDroidPopen([abscmd] + commands[1:], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 3024, in FDroidPopen result = FDroidPopenBytes(commands, cwd, envs, output, stderr_to_stdout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 2987, in FDroidPopenBytes if output and options.verbose: ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'verbose' --- fdroidserver/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 6a24c74e..a6cf2009 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -2976,7 +2976,7 @@ def FDroidPopenBytes(commands, cwd=None, envs=None, output=True, stderr_to_stdou while not stdout_reader.eof(): while not stdout_queue.empty(): line = stdout_queue.get() - if output and options.verbose: + if output and options and options.verbose: # Output directly to console sys.stderr.buffer.write(line) sys.stderr.flush()