Skip to content

Commit 873a22e

Browse files
picamera2 init: Don't override LIBCAMERA_RPI_CONFIG_FILE if valid
If the environment variable already exists and points to a valid file, keep it. This allows the config file to be user-specified from outside the Python script. Signed-off-by: Nick Hollinghurst <[email protected]>
1 parent 2abf57a commit 873a22e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

picamera2/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020

2121
def _set_configuration_file(filename):
22+
oldval = os.environ.get('LIBCAMERA_RPI_CONFIG_FILE')
23+
if oldval is not None and os.path.isfile(oldval):
24+
return
25+
2226
platform_dir = "vc4" if get_platform() == Platform.VC4 else "pisp"
2327
dirs = [
2428
os.path.expanduser(
@@ -29,12 +33,10 @@ def _set_configuration_file(filename):
2933

3034
for directory in dirs:
3135
file = os.path.join(directory, filename)
32-
3336
if os.path.isfile(file):
3437
os.environ['LIBCAMERA_RPI_CONFIG_FILE'] = file
3538
break
3639

37-
3840
_set_configuration_file("rpi_apps.yaml")
3941

4042

0 commit comments

Comments
 (0)