# HG changeset patch
# User jfp <jf.pieronne@laposte.net>
# Date 1716553564 -7200
#      Fri May 24 14:26:04 2024 +0200
# Node ID 601acd250e2a42bbd8246c1bb7cf579776ba89db
# Parent  a3e428f4938bc17344be0358c9b1cf30f0d8a7c8
Ruff clean, format code

diff --git a/python/local/ovms_module/ovms/accountng.py b/python/local/ovms_module/ovms/accountng.py
--- a/python/local/ovms_module/ovms/accountng.py
+++ b/python/local/ovms_module/ovms/accountng.py
@@ -3,11 +3,9 @@
 #      Appendix C. Accounting Information for Programmers
 import ordb
 import ordb.utils
-import struct
 import os
 from ovms.acrdef import (
     ACR_K_PRCDEL,
-    ACR_K_SYSINIT,
     ACR_K_ID,
     ACR_K_RESOURCE,
     ACR_K_IMGDEL,
@@ -26,161 +24,143 @@
     Bytes,
     this,
     IfThenElse,
-    PascalString,
     Pointer,
     Const,
 )
 from ovms.vmsconstruct import VMSDateTime
 
 RecordAcc = Struct(
-    'type'
+    "type"
     / BitStruct(
-        'type' / BitsInteger(7),  # packet type
-        'packet' / Flag,  # must be False (0)
-        'customer' / Flag,
-        'version' / BitsInteger(3),  # version of the record structure
-        'subtype' / Nibble,  # subtype
+        "type" / BitsInteger(7),  # packet type
+        "packet" / Flag,  # must be False (0)
+        "customer" / Flag,
+        "version" / BitsInteger(3),  # version of the record structure
+        "subtype" / Nibble,  # subtype
     ),
-    'length' / Int16ul,  # packet length
-    'systime' / VMSDateTime,  # type: ignore # event system time
+    "length" / Int16ul,  # packet length
+    "systime" / VMSDateTime,  # type: ignore # event system time
     # 'systime' / Int64ul,	        # event system time
-    'data' / Bytes(this.length - 12),
+    "data" / Bytes(this.length - 12),
 )
 
 PacketHead = Struct(
-    'type'
+    "type"
     / BitStruct(
-        'type' / BitsInteger(7),  # packet type
-        'packet' / Flag,  # must be False (0)
-        'customer' / Flag,
-        'version' / BitsInteger(3),  # version of the record structure
-        'subtype' / Nibble,  # subtype
+        "type" / BitsInteger(7),  # packet type
+        "packet" / Flag,  # must be False (0)
+        "customer" / Flag,
+        "version" / BitsInteger(3),  # version of the record structure
+        "subtype" / Nibble,  # subtype
     ),
-    'length' / Int16ul,  # packet length
+    "length" / Int16ul,  # packet length
 )
 
 PacketResource = Struct(
-    'type'
+    "type"
     / BitStruct(
-        'type' / BitsInteger(7),  # packet type
-        'packet' / Flag,  # must be False (0)
-        'customer' / Flag,
-        'version' / BitsInteger(3),  # version of the record structure
-        'subtype' / Nibble,  # subtype
+        "type" / BitsInteger(7),  # packet type
+        "packet" / Flag,  # must be False (0)
+        "customer" / Flag,
+        "version" / BitsInteger(3),  # version of the record structure
+        "subtype" / Nibble,  # subtype
     ),
-    'length' / Int16ul,  # packet length
-    'login' / VMSDateTime,  # type: ignore # absolute time at which the image was
+    "length" / Int16ul,  # packet length
+    "login" / VMSDateTime,  # type: ignore # absolute time at which the image was
     # run or the process was created
     # 'login' / Int64ul,		        #
-    'status' / Int32ul,  # Final exit status of the image, or for a
+    "status" / Int32ul,  # Final exit status of the image, or for a
     # process, the final status of the last image
-    'imgcnt' / Int32ul,  # Number of images run by the process
-    'cputime' / Int32ul,  # Total CPU time used by the image or process,
+    "imgcnt" / Int32ul,  # Number of images run by the process
+    "cputime" / Int32ul,  # Total CPU time used by the image or process,
     # measured in units of 10 milliseconds. This includes any vector CPU time
-    'faults' / Int32ul,  # Number of hard and soft page faults
+    "faults" / Int32ul,  # Number of hard and soft page faults
     # incurred by the image or process
-    'faultio' / Int32ul,  # Number of hard page faults incurred by
+    "faultio" / Int32ul,  # Number of hard page faults incurred by
     # the image or process
-    'wspeak' / Int32ul,  # Maximum working set size used by the
+    "wspeak" / Int32ul,  # Maximum working set size used by the
     # image or process
-    'pagefl' / Int32ul,  # Maximum page file usage
-    'diocnt' / Int32ul,  # Number of direct I/Os made by the image or process
-    'biocnt' / Int32ul,  # Number of buffered I/Os made by the image or process
-    'volumes' / Int32ul,  # Number of volumes mounted by the image or process
-    'cputimev' / Int32ul,  # Vector CPU time used by the image or process,
+    "pagefl" / Int32ul,  # Maximum page file usage
+    "diocnt" / Int32ul,  # Number of direct I/Os made by the image or process
+    "biocnt" / Int32ul,  # Number of buffered I/Os made by the image or process
+    "volumes" / Int32ul,  # Number of volumes mounted by the image or process
+    "cputimev" / Int32ul,  # Vector CPU time used by the image or process,
     # measured in units of 10 milliseconds
 )
 
-PascalBytes = Struct('len' / Int8ul, 'data' / Bytes(this.len))
-Pascal16Bytes = Struct('len' / Int16ul, 'data' / Bytes(this.len))
-TerminalBytes = Struct(
-    'len' / Int8ul, 'data' / Bytes(this.len - 4), 'unit' / Int32ul
-)
+PascalBytes = Struct("len" / Int8ul, "data" / Bytes(this.len))
+Pascal16Bytes = Struct("len" / Int16ul, "data" / Bytes(this.len))
+TerminalBytes = Struct("len" / Int8ul, "data" / Bytes(this.len - 4), "unit" / Int32ul)
 
 PacketID = Struct(
-    'type'
+    "type"
     / BitStruct(
-        'type' / BitsInteger(7),  # packet type
-        'packet' / Flag,  # must be False (0)
-        'customer' / Flag,
-        'version' / BitsInteger(3),  # version of the record structure
-        'subtype' / Nibble,  # subtype
+        "type" / BitsInteger(7),  # packet type
+        "packet" / Flag,  # must be False (0)
+        "customer" / Flag,
+        "version" / BitsInteger(3),  # version of the record structure
+        "subtype" / Nibble,  # subtype
     ),
-    'length' / Int16ul,  # packet length
-    'pid' / Int32ul,  # Process identifier (PID) of the process
-    'owner' / Int32ul,  # PID of the parent process
-    'mem' / Int16ul,  # UIC member
-    'grp' / Int16ul,  # UIC group
-    'priv'
-    / Int64sl,  # Privileges held by the process, use signed for storing in Rdb
-    'prio' / Int8ul,  # Base priority of the process
-    'idflgs' / Int8ul,  # Full address and full name present
+    "length" / Int16ul,  # packet length
+    "pid" / Int32ul,  # Process identifier (PID) of the process
+    "owner" / Int32ul,  # PID of the parent process
+    "mem" / Int16ul,  # UIC member
+    "grp" / Int16ul,  # UIC group
+    "priv" / Int64sl,  # Privileges held by the process, use signed for storing in Rdb
+    "prio" / Int8ul,  # Base priority of the process
+    "idflgs" / Int8ul,  # Full address and full name present
     # if low bit is set.
-    'pusername' / Int16ul,  #
-    'paccount' / Int16ul,  #
-    'pnodename' / Int16ul,  #
-    'pterminal' / Int16ul,  #
-    'pjobname' / Int16ul,  #
-    'jobid' / Int32ul,  #
-    'pqueue' / Int16ul,  #
-    'pnodeaddr' / Int16ul,  #
-    'premoteid' / Int16ul,  #
-    'pfulladdr' / Int16ul,  #
-    'pfullname' / Int16ul,  #
-    'username'
-    / IfThenElse(
-        this.pusername > 0, Pointer(this.pusername, PascalBytes), Const(b'')
-    ),
-    'account'
+    "pusername" / Int16ul,  #
+    "paccount" / Int16ul,  #
+    "pnodename" / Int16ul,  #
+    "pterminal" / Int16ul,  #
+    "pjobname" / Int16ul,  #
+    "jobid" / Int32ul,  #
+    "pqueue" / Int16ul,  #
+    "pnodeaddr" / Int16ul,  #
+    "premoteid" / Int16ul,  #
+    "pfulladdr" / Int16ul,  #
+    "pfullname" / Int16ul,  #
+    "username"
+    / IfThenElse(this.pusername > 0, Pointer(this.pusername, PascalBytes), Const(b"")),
+    "account"
+    / IfThenElse(this.paccount > 0, Pointer(this.paccount, PascalBytes), Const(b"")),
+    "nodename"
+    / IfThenElse(this.pnodename > 0, Pointer(this.pnodename, PascalBytes), Const(b"")),
+    "terminal"
     / IfThenElse(
-        this.paccount > 0, Pointer(this.paccount, PascalBytes), Const(b'')
-    ),
-    'nodename'
-    / IfThenElse(
-        this.pnodename > 0, Pointer(this.pnodename, PascalBytes), Const(b'')
-    ),
-    'terminal'
-    / IfThenElse(
-        this.pterminal > 0, Pointer(this.pterminal, TerminalBytes), Const(b'')
-    ),
-    'jobname'
-    / IfThenElse(
-        this.pjobname > 0, Pointer(this.pjobname, PascalBytes), Const(b'')
-    ),
-    'queue'
-    / IfThenElse(
-        this.pqueue > 0, Pointer(this.pqueue, PascalBytes), Const(b'')
+        this.pterminal > 0, Pointer(this.pterminal, TerminalBytes), Const(b"")
     ),
-    'nodeaddr'
+    "jobname"
+    / IfThenElse(this.pjobname > 0, Pointer(this.pjobname, PascalBytes), Const(b"")),
+    "queue"
+    / IfThenElse(this.pqueue > 0, Pointer(this.pqueue, PascalBytes), Const(b"")),
+    "nodeaddr"
+    / IfThenElse(this.pnodeaddr > 0, Pointer(this.pnodeaddr, PascalBytes), Const(b"")),
+    "remoteid"
+    / IfThenElse(this.premoteid > 0, Pointer(this.premoteid, PascalBytes), Const(b"")),
+    "fulladdr"
     / IfThenElse(
-        this.pnodeaddr > 0, Pointer(this.pnodeaddr, PascalBytes), Const(b'')
-    ),
-    'remoteid'
-    / IfThenElse(
-        this.premoteid > 0, Pointer(this.premoteid, PascalBytes), Const(b'')
+        this.pfulladdr > 0, Pointer(this.pfulladdr, Pascal16Bytes), Const(b"")
     ),
-    'fulladdr'
+    "fullname"
     / IfThenElse(
-        this.pfulladdr > 0, Pointer(this.pfulladdr, Pascal16Bytes), Const(b'')
+        this.pfullname > 0, Pointer(this.pfullname, Pascal16Bytes), Const(b"")
     ),
-    'fullname'
-    / IfThenElse(
-        this.pfullname > 0, Pointer(this.pfullname, Pascal16Bytes), Const(b'')
-    ),
-    'data' / Bytes(this.length - 50),
+    "data" / Bytes(this.length - 50),
 )
 
 PacketImageName = Struct(
-    'type'
+    "type"
     / BitStruct(
-        'type' / BitsInteger(7),  # packet type
-        'packet' / Flag,  # must be False (0)
-        'customer' / Flag,
-        'version' / BitsInteger(3),  # version of the record structure
-        'subtype' / Nibble,  # subtype
+        "type" / BitsInteger(7),  # packet type
+        "packet" / Flag,  # must be False (0)
+        "customer" / Flag,
+        "version" / BitsInteger(3),  # version of the record structure
+        "subtype" / Nibble,  # subtype
     ),
-    'length' / Int16ul,  # packet length
-    'imagename' / PascalBytes,
+    "length" / Int16ul,  # packet length
+    "imagename" / PascalBytes,
 )
 
 
@@ -225,8 +205,8 @@
     status, cntxt = ovms.rtl.lib.init_timer()
     pdt = [0, 0, 0, 0, 0]
     idt = [0, 0, 0, 0, 0]
-    dstype = ['INTERACTIVE', 'SUBPROCESS', 'DETACHED', 'BATCH', 'NETWORK']
-    ordb.attachDB('sql$database')
+    dstype = ["INTERACTIVE", "SUBPROCESS", "DETACHED", "BATCH", "NETWORK"]
+    ordb.attachDB("sql$database")
     ordb.statement(
         """set transaction read write
 reserving prc_accountng, img_accountng for exclusive write"""
@@ -251,10 +231,10 @@
 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
   ?, ?, ?, ?, ?, ?)"""
     )
-    f = os.open('/SYS$MANAGER/ACCOUNTNG.DAT', os.O_RDONLY)
+    f = os.open("/SYS$MANAGER/ACCOUNTNG.DAT", os.O_RDONLY)
     while True:
         rec = os.read(f, 512)
-        if rec == b'':
+        if rec == b"":
             break
         racc = RecordAcc.parse(rec)
         ptype = racc.type.type
@@ -278,14 +258,14 @@
                 recinfo.username = pckt.username.data
                 recinfo.account = pckt.account.data
                 recinfo.nodename = pckt.nodename
-                recinfo.terminal = pckt.terminal.data + b'%d' % pckt.terminal.unit + b':' if pckt.terminal else b''  # type: ignore
+                recinfo.terminal = pckt.terminal.data + b"%d" % pckt.terminal.unit + b":" if pckt.terminal else b""  # type: ignore
                 recinfo.jobname = pckt.jobname
                 recinfo.jobid = pckt.jobid
                 recinfo.queue = pckt.queue
                 recinfo.nodeaddr = pckt.nodeaddr
-                recinfo.remoteid = pckt.remoteid.data if pckt.remoteid else b''  # type: ignore
-                recinfo.fulladdr = pckt.fulladdr.data if pckt.fulladdr else b''  # type: ignore
-                recinfo.fullname = pckt.fullname.data if pckt.fullname else b''  # type: ignore
+                recinfo.remoteid = pckt.remoteid.data if pckt.remoteid else b""  # type: ignore
+                recinfo.fulladdr = pckt.fulladdr.data if pckt.fulladdr else b""  # type: ignore
+                recinfo.fullname = pckt.fullname.data if pckt.fullname else b""  # type: ignore
                 pdt[pstype - 1] += 1
             elif pckt.type.type == ACR_K_IMAGENAME:
                 idt[pstype - 1] += 1
@@ -346,15 +326,15 @@
 
     os.close(f)
     ordb.commit()
-    print('Processes')
+    print("Processes")
     for i in range(5):
-        print('%-12s: %8d' % (dstype[i], pdt[i] - idt[i]))
+        print("%-12s: %8d" % (dstype[i], pdt[i] - idt[i]))
     print()
-    print('Images')
+    print("Images")
     for i in range(5):
-        print('%-12s: %8d' % (dstype[i], idt[i]))
-    status = ovms.rtl.lib.show_timer(cntxt)
+        print("%-12s: %8d" % (dstype[i], idt[i]))
+    _ = ovms.rtl.lib.show_timer(cntxt)
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     test()
diff --git a/python/local/ovms_module/ovms/sda.py b/python/local/ovms_module/ovms/sda.py
--- a/python/local/ovms_module/ovms/sda.py
+++ b/python/local/ovms_module/ovms/sda.py
@@ -1,7 +1,5 @@
 # -*- coding: iso-8859-1 -*-
 
-from ovms import descrip, rmsdef, dvidef, devdef
-from ovms.rtl import lib
 import ctypes
 import sys
 import warnings
@@ -54,7 +52,6 @@
 
 
 if __name__ == '__main__':
-    import sys
     def output_routine(v):
         print(v)