diff --git a/python/local/ovms_module/ovms/accountng.py b/python/local/ovms_module/ovms/accountng.py index a3e428f4938bc17344be0358c9b1cf30f0d8a7c8_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvYWNjb3VudG5nLnB5..601acd250e2a42bbd8246c1bb7cf579776ba89db_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvYWNjb3VudG5nLnB5 100755 --- a/python/local/ovms_module/ovms/accountng.py +++ b/python/local/ovms_module/ovms/accountng.py @@ -3,7 +3,6 @@ # Appendix C. Accounting Information for Programmers import ordb import ordb.utils -import struct import os from ovms.acrdef import ( ACR_K_PRCDEL, @@ -7,7 +6,6 @@ import os from ovms.acrdef import ( ACR_K_PRCDEL, - ACR_K_SYSINIT, ACR_K_ID, ACR_K_RESOURCE, ACR_K_IMGDEL, @@ -26,10 +24,9 @@ Bytes, this, IfThenElse, - PascalString, Pointer, Const, ) from ovms.vmsconstruct import VMSDateTime RecordAcc = Struct( @@ -30,8 +27,8 @@ Pointer, Const, ) from ovms.vmsconstruct import VMSDateTime RecordAcc = Struct( - 'type' + "type" / BitStruct( @@ -37,7 +34,7 @@ / 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 ), @@ -43,4 +40,4 @@ ), - '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 @@ -46,5 +43,5 @@ # 'systime' / Int64ul, # event system time - 'data' / Bytes(this.length - 12), + "data" / Bytes(this.length - 12), ) PacketHead = Struct( @@ -48,5 +45,5 @@ ) PacketHead = Struct( - 'type' + "type" / BitStruct( @@ -52,7 +49,7 @@ / 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 ), @@ -58,5 +55,5 @@ ), - 'length' / Int16ul, # packet length + "length" / Int16ul, # packet length ) PacketResource = Struct( @@ -60,5 +57,5 @@ ) PacketResource = Struct( - 'type' + "type" / BitStruct( @@ -64,7 +61,7 @@ / 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 ), @@ -70,5 +67,5 @@ ), - '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, # @@ -73,4 +70,4 @@ # 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 @@ -76,4 +73,4 @@ # 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 @@ -79,3 +76,3 @@ # 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 @@ -81,3 +78,3 @@ # 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 @@ -83,3 +80,3 @@ # 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 @@ -85,9 +82,9 @@ # 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 ) @@ -91,10 +88,8 @@ # 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( @@ -99,4 +94,4 @@ PacketID = Struct( - 'type' + "type" / BitStruct( @@ -102,7 +97,7 @@ / 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 ), @@ -108,11 +103,10 @@ ), - '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. @@ -118,18 +112,20 @@ # 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( @@ -135,19 +131,3 @@ / 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"") ), @@ -153,3 +133,11 @@ ), - '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( @@ -155,7 +143,3 @@ / 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"") ), @@ -161,3 +145,3 @@ ), - 'fulladdr' + "fullname" / IfThenElse( @@ -163,3 +147,3 @@ / IfThenElse( - this.pfulladdr > 0, Pointer(this.pfulladdr, Pascal16Bytes), Const(b'') + this.pfullname > 0, Pointer(this.pfullname, Pascal16Bytes), Const(b"") ), @@ -165,9 +149,5 @@ ), - 'fullname' - / IfThenElse( - this.pfullname > 0, Pointer(this.pfullname, Pascal16Bytes), Const(b'') - ), - 'data' / Bytes(this.length - 50), + "data" / Bytes(this.length - 50), ) PacketImageName = Struct( @@ -171,5 +151,5 @@ ) PacketImageName = Struct( - 'type' + "type" / BitStruct( @@ -175,7 +155,7 @@ / 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 ), @@ -181,6 +161,6 @@ ), - '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,6 +231,6 @@ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""" ) - 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) @@ -255,6 +235,6 @@ while True: rec = os.read(f, 512) - if rec == b'': + if rec == b"": break racc = RecordAcc.parse(rec) ptype = racc.type.type @@ -278,8 +258,8 @@ 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 @@ -282,10 +262,10 @@ 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,5 +326,5 @@ os.close(f) ordb.commit() - print('Processes') + print("Processes") for i in range(5): @@ -350,3 +330,3 @@ for i in range(5): - print('%-12s: %8d' % (dstype[i], pdt[i] - idt[i])) + print("%-12s: %8d" % (dstype[i], pdt[i] - idt[i])) print() @@ -352,3 +332,3 @@ print() - print('Images') + print("Images") for i in range(5): @@ -354,5 +334,5 @@ 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) @@ -357,4 +337,4 @@ -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 index a3e428f4938bc17344be0358c9b1cf30f0d8a7c8_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvc2RhLnB5..601acd250e2a42bbd8246c1bb7cf579776ba89db_cHl0aG9uL2xvY2FsL292bXNfbW9kdWxlL292bXMvc2RhLnB5 100644 --- 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)