Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check hardware type?
#1
Hi folks.

I'm currently needing to run some code on a Raspberry pi and a Tinker Board.

What's the best way to check which hardware the code is running on? This will only need checking at applet startup so overhead isn't too much of a problem.

I'm happy to grep a bash command, or psutils, or something else, it doesn't really matter.

Many thanks.
Reply
#2
I would like at what os.uname() looks like on both platforms.
Reply
#3
to check hardware, see: https://docs.python.org/2/library/platform.html
Reply
#4
There are already some info programs out there. Some even written in python (archey) is one i know of. screenfetch i think is a universal distro one. If you want to make your own just open them up and see how they they obtain the info.

metulburr@ubuntu:~$ screenfetch
                          ./+o+-       metulburr@ubuntu
                  yyyyy- -yyyyyy+      OS: Ubuntu 16.04 xenial
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.4.0-142-generic
           .++ .:/++++++/-.+sss/`      Uptime: 1d 1h 23m
         .:++o:  /++++++++/:--:/-      Packages: 2892
        o:+o+:++.`..```.-/oo+++++/     Shell: bash 4.3.48
       .:+o:+o/.          `+sssoo+/    Resolution: 3840x1093
  .++/+:+oo+o:`             /sssooo.   DE: Unity 7.4.5
 /+++//+:`oo+o               /::--:.   WM: Compiz
 \+/+o+++`o++o               ++////.   WM Theme: Ambiance
  .++.o+++oo+:`             /dddhhh.   GTK Theme: Ambiance [GTK2/3]
       .+.o+oo:.          `oddhhhh+    Icon Theme: ubuntu-mono-dark
        \+.++o+o``-````.:ohdhhhhh+     Font: Ubuntu 11
         `:o+++ `ohhhhhhhhyo++os:      CPU: Intel Core i7-2600 CPU @ 3.8GHz
           .o:`.syhhhhhhh/.oo++o`      RAM: 5896MiB / 13941MiB
               /osyyyyyyo++ooo+++/    
                   ````` +oo+++o\:    
                          `oo++.      
metulburr@ubuntu:~$ archey

                          .oyhhs:   User: metulburr
                 ..--.., shhhhhh-   Hostname: ubuntu
               -+++++++++`:yyhhyo`  OS: Ubuntu 16.04 x86_64
          .--  -++++++++/-.-::-`    Kernel: 4.4.0-142-generic
        .::::-   :-----:/+++/++/.   Uptime: 1 day, 1:23
       -:::::-.          .:++++++:  Window Manager: Compiz
  ,,, .:::::-`             .++++++- Shell: Bash
./+++/-`-::-                ./////: Terminal: Xterm-256color
+++++++ .::-                        Packages: 2892
./+++/-`-::-                :yyyyyo CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  ``` `-::::-`             :yhhhhh: RAM: -10319 MB / 13941 MB
       -:::::-.         `-ohhhhhh+  Disk: 4.3T / 4.6T
        .::::-` -o+///+oyhhyyyhy:   
         `.--  /yhhhhhhhy+,....     
               /hhhhhhhhh-.-:::;    
               `.:://::- -:::::;    
                         `.-:-'     
                                    
im pretty sure archey just parses out linux info files such as
metulburr@ubuntu:~$ cat /proc/cpuinfo | grep model
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
model		: 42
model name	: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
or for parsing for RAM
$ free -m
              total        used        free      shared  buff/cache   available
Mem:          13941        5158        1053         819        7729        7591
Swap:         14245           0       14245
Recommended Tutorials:
Reply
#5
Glances is good,written in Python.
It also warn if there is a problems,here problems on our server before update to 2-cores.
[Image: e5Gktc.jpg]
Work also on windows,here running in browser.
[Image: TGUdXq.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  isinstance() always return true for object type check Yoki91 2 2,498 Jul-22-2020, 06:52 PM
Last Post: Yoki91
  check pandas variable type cools0607 3 6,510 Jun-12-2020, 09:28 AM
Last Post: buran
  Hardware question re running Anaconda pberrett 6 2,892 Jan-23-2020, 04:23 PM
Last Post: rmspacedashrf
  Type hinting - return type based on parameter micseydel 2 2,425 Jan-14-2020, 01:20 AM
Last Post: micseydel
  how i can check the input type? Firdaos 3 2,798 Dec-13-2018, 11:39 PM
Last Post: wavic
  how to check for file type in a folder SoulsKeeper 4 4,870 Sep-15-2018, 02:48 PM
Last Post: ichabod801
  How to talk with Real Time Clock hardware? jackbk 12 11,134 Feb-15-2017, 05:53 AM
Last Post: jackbk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020