Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] expanding user #733

Closed
Vincent-Stragier opened this issue Jul 3, 2023 · 1 comment
Closed

[BUG] expanding user #733

Vincent-Stragier opened this issue Jul 3, 2023 · 1 comment

Comments

@Vincent-Stragier
Copy link
Contributor

Hi,

I think expanding the user this way (line 14) could lead to some bugs:

def _set_configuration_file(filename):
user = os.environ.get('USER', "pi")
dirs = [os.path.join("/home", user, "libcamera/src/libcamera/pipeline/rpi/vc4/data"),
"/usr/local/share/libcamera/pipeline/rpi/vc4",
"/usr/share/libcamera/pipeline/rpi/vc4"]
for dir in dirs:
file = os.path.join(dir, filename)
if os.path.isfile(file):
os.environ['LIBCAMERA_RPI_CONFIG_FILE'] = file
break

In this SO answer, the author explains that the user directory is not always /home/<user>. Also, dir is a built-in function in Python. I would rewrite the code like so:

def _set_configuration_file(filename):
    user_directory = os.path.expanduser("~")
    dirs = [
        os.path.join(
            user_directory,
            "libcamera/src/libcamera/pipeline/rpi/vc4/data"
        ),
        "/usr/local/share/libcamera/pipeline/rpi/vc4",
        "/usr/share/libcamera/pipeline/rpi/vc4"]

    for directory in dirs:
        file = os.path.join(directory, filename)

        if os.path.isfile(file):
            os.environ['LIBCAMERA_RPI_CONFIG_FILE'] = file
            break

Regards,
Vincent

@davidplowman
Copy link
Collaborator

Hi, thanks for the suggestion. That might be a good candidate for a PR, if you'd like to submit one? Please read our contribution guidelines so that we can get through the process easily and quickly. Thanks!

(Just a minor warning that I think this is the new 3.10 release... but which we aren't "officially" distributing without some extra libcamera updates. Hopefully it will only be a few days at most for this, but just to let you know that things are not quite perfect at the minute.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants