src/eric7/MicroPython/Devices/DeviceBase.py

branch
eric7
changeset 9906
39daf45010c8
parent 9889
49728322ffb4
child 9928
f98f0c28c1eb
--- a/src/eric7/MicroPython/Devices/DeviceBase.py	Thu Mar 16 09:20:00 2023 +0100
+++ b/src/eric7/MicroPython/Devices/DeviceBase.py	Thu Mar 16 12:03:23 2023 +0100
@@ -30,8 +30,9 @@
     If a board needs special treatment, the command should be overwritten
     in the board specific subclass. Commands are provided to perform operations
     on the file system of a connected MicroPython device, for getting and setting
-    the time on the board and getting board related data. Supported file system
-    commands are:
+    the time on the board and getting board related data.
+
+    Supported file system commands are:
     <ul>
     <li>cd: change directory</li>
     <li>exists: test the existence of a file or directory on the device</li>
@@ -971,13 +972,21 @@
 def get_device_data():
     res = {}
 
-    import os
-    uname = os.uname()
-    res['sysname'] = uname.sysname
-    res['nodename'] = uname.nodename
-    res['release'] = uname.release
-    res['version'] = uname.version
-    res['machine'] = uname.machine
+    try:
+        import os
+        uname = os.uname()
+        res['sysname'] = uname.sysname
+        res['nodename'] = uname.nodename
+        res['release'] = uname.release
+        res['version'] = uname.version
+        res['machine'] = uname.machine
+    except AttributeError:
+        import sys
+        res['sysname'] = sys.platform
+        res['nodename'] = sys.platform
+        res['release'] = '.'.join(str(v) for v in sys.implementation.version)
+        res['version'] = sys.version.split(';', 1)[-1].strip()
+        res['machine'] = sys.implementation._machine
 
     import sys
     res['py_platform'] = sys.platform
@@ -1055,13 +1064,21 @@
     res['mem_free_pc'] = mem_free / mem_total * 100.0
     del gc, mem_alloc, mem_free, mem_total
 
-    import os
-    uname = os.uname()
-    res['sysname'] = uname.sysname
-    res['nodename'] = uname.nodename
-    res['release'] = uname.release
-    res['version'] = uname.version
-    res['machine'] = uname.machine
+    try:
+        import os
+        uname = os.uname()
+        res['sysname'] = uname.sysname
+        res['nodename'] = uname.nodename
+        res['release'] = uname.release
+        res['version'] = uname.version
+        res['machine'] = uname.machine
+    except AttributeError:
+        import sys
+        res['sysname'] = sys.platform
+        res['nodename'] = sys.platform
+        res['release'] = '.'.join(str(v) for v in sys.implementation.version)
+        res['version'] = sys.version.split(';', 1)[-1].strip()
+        res['machine'] = sys.implementation._machine
 
     import sys
     res['py_platform'] = sys.platform

eric ide

mercurial