Skip to main content

Linux Information

work in progress

Answers:

  • is this a raspberry pi?
    • functions return None on error
  • is this a raspbian or ubuntu distro?
  • is this distro based on debian?
  • reads /proc/cpuinfo for revision code
  • reads /etc/os-release for linux OS info

Info

Reads the revision code which encodes a bunch of information as uuuuuuuuFMMMCCCCPPPPTTTTTTTTRRRR. This library decodes that number.

RPiInfo = namedtuple("RPiInfo", "type processor memory revision manufacturer flag")
LinuxInfo = namedtuple("LinuxInfo", "distro distro_pretty debian_based version version_codename")

Example

from linuxinfo import linux_info()
from linuxinfo import pi_info
from linuxinfo import RPiInfo, LinuxInfo  # not sure you need these
from linuxinfo.rpi import decode          # normally you don't use this!

# given a revision code, it decodes it (see below). Normally you
# wouldn't do this ... this is just a test
print(decode(0xa020a0))  # compute module 3
print(decode(0xa22042))  # Pi2B
print(decode(0xc03111))  # Pi4B

print(pi_info())  # reads /proc/cpuinfo and get revision code
RPiInfo(type='CM3', processor='BCM2837', memory='1GB', revision=0, manufacturer='Sony UK', flag='new-style revision')
RPiInfo(type='2B', processor='BCM2837', memory='1GB', revision=2, manufacturer='Embest', flag='new-style revision')
RPiInfo(type='4B', processor='BCM2711', memory='4GB', revision=1, manufacturer='Sony UK', flag='new-style revision')

Change Log

Date Version Notes
2020 Dec 4 0.1.0 changed name because it does more
2019 Oct 27 0.0.3 simple clean up
2019 Oct 27 0.0.1 init

MIT License

Copyright (c) 2019 Kevin J. Walchko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for linuxinfo 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linuxinfo 0.1.1
File Size Uploaded
linuxinfo-0.1.1.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linuxinfo 0.1.1
File Interpreter ABI Platform
linuxinfo-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / linuxinfo-0.1.1.tar.gz

Download URL linuxinfo-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b8cae1916bf279db626128c13439c7c7cd37f16a80d346ac38f11bb1143ad53b
BLAKE2b-256 checksum
How to use checksums
1ce8a3203defeb25db491ad488a403ca2a03c50f4f57dfbcf32a65ae7a9d7a21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.7.5 Linux/5.3.0-29-generic

Release files / linuxinfo-0.1.1-py3-none-any.whl

Download URL linuxinfo-0.1.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d67382b1ffe7be152031d7711fcd53a1506edf2e8040e8d407f2490df99eecd9
BLAKE2b-256 checksum
How to use checksums
6a89314d3bacd7e60c70f7296c52cee600e50eced5d9a42f1325c7e83a7f726d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.7.5 Linux/5.3.0-29-generic

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page