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

fix: is_rockpi and is_raspberry_pi should not break outside Balena #69

Closed
marvinmarnold opened this issue Nov 24, 2021 · 4 comments
Closed
Assignees

Comments

@marvinmarnold
Copy link
Contributor

User Story
As a user, I should not hit an exception if running outside Balena.

Notes
We currently detect hardware by inspecting the BALENA_DEVICE_TYPE environment variable, created by Balena. In test cases, this will raise an exception.

    def is_raspberry_pi():
        """
        Pulled from
        https://www.balena.io/docs/reference/base-images/devicetypes/
        """
        device_type = os.getenv('BALENA_DEVICE_TYPE')
        device_type_match = [
            'raspberry-pi2',
            'raspberrypi3',
            'raspberrypi3-64',
            'raspberrypi4-64',
            'nebra-hnt',
            'raspberrypicm4-ioboard'
        ]
    
        for device in device_type_match:
>           if device in device_type:
E           TypeError: argument of type 'NoneType' is not iterable

Acceptance Criteria

  • is_rockpi and is_raspberry_pi should not raise exceptions if invoked outside Balena. Return False in both cases.
@shawaj
Copy link
Member

shawaj commented Nov 30, 2021

@marvinmarnold for the version check, perhaps we could use cat /proc/device-tree/model when not on balena...

This gives the following output:

ROCK PI 4B
Raspberry Pi Compute Module 3 Plus Rev 1.0

@shawaj
Copy link
Member

shawaj commented Nov 30, 2021

/proc/cpuinfo has this for RasPi too but not RockPi

@vpetersson
Copy link
Contributor

@marvinmarnold for the version check, perhaps we could use cat /proc/device-tree/model when not on balena...

This gives the following output:

ROCK PI 4B Raspberry Pi Compute Module 3 Plus Rev 1.0

Seems like a reasonable fallback.

@shawaj
Copy link
Member

shawaj commented Dec 26, 2021

Partially solved by #84

@pritamghanghas pritamghanghas self-assigned this Feb 28, 2022
pritamghanghas added a commit that referenced this issue Feb 28, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 4, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 4, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 4, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 7, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 7, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 7, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 7, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 8, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 8, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 9, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 9, 2022
* read model information from /proc/device-tree/model
in the absense of balena env variable
pritamghanghas added a commit that referenced this issue Mar 9, 2022
fix: is_rockpi and is_raspberry_pi should not break outside Balena #69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants