Commit 882a6dad authored by Yannick DAYER's avatar Yannick DAYER

[fix] Get os environment variable correctly.

Tests if an os environment variable exists before using it.
parent 179c75a3
Pipeline #45525 failed with stages
in 7 minutes and 20 seconds
......@@ -68,9 +68,11 @@ def get_pipeline(face_cropper, transform_extra_arguments):
)
# Set default temporary directory
default_temp = os.path.join("/idiap","temp",os.environ["USER"])
if os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp")
user_env_var = os.getenv(["USER"], None)
if user_env_var:
default_temp = os.path.join("/idiap","temp",user_env_var)
if user_env_var and os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp", "gabor_graph")
else:
# if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx
tempdir = tempfile.TemporaryDirectory().name
......
......@@ -42,9 +42,11 @@ def load(annotation_type, fixed_positions=None):
#### FEATURE EXTRACTOR ######
# Set default temporary directory
default_temp = os.path.join("/idiap","temp",os.environ["USER"])
if os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp")
user_env_var = os.getenv(["USER"], None)
if user_env_var:
default_temp = os.path.join("/idiap","temp",user_env_var)
if user_env_var and os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp", "lda")
else:
# if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx
tempdir = tempfile.TemporaryDirectory().name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment