0 0 1
default
Jean-Francois Pieronne - 8 months ago 2019-05-16 16:23:39
jf.pieronne@laposte.net
setimr.py initial version
1 file changed with 58 insertions and 0 deletions:
↑ Collapse Diff ↑
 
new file 100644
1
 
"""OpenVMS setimr"""
2
 

	
3
 
import vms.crtl
4
 
import vms.descrip
5
 
import os
6
 
import time
7
 
import ctypes
8
 

	
9
 
VMSSYS = "/SYS$COMMON/SYSLIB/SYS$PUBLIC_VECTORS.EXE"
10
 
SYS = ctypes.CDLL(VMSSYS)
11
 
vmssetimr = getattr(SYS, "SYS$SETIMR")
12
 
vmswaitfr = getattr(SYS, "SYS$WAITFR")
13
 

	
14
 
VMSLIBRTL = "/SYS$COMMON/SYSLIB/LIBRTL.EXE"
15
 
LIBRTL = ctypes.CDLL(VMSLIBRTL)
16
 
vmsget_ef = getattr(LIBRTL,"LIB$GET_EF")
17
 
vmsfree_ef= getattr(LIBRTL,"LIB$FREE_EF")
18
 

	
19
 
def vmscall(f, *args, **kargs):
20
 
    s = f(*args, **kargs)
21
 
    if s & 1:
22
 
        return s
23
 
    else:
24
 
        raise VMSError(s)
25
 

	
26
 
def clref(efn):
27
 
    return vmscall(vmsclref, ctypes.c_uint(efn))
28
 

	
29
 
def waitfr(efn):
30
 
    return vmscall(vmswaitfr, ctypes.c_uint(efn))
31
 

	
32
 
def get_ef():
33
 
    efn = ctypes.c_uint()
34
 
    s = vmscall(vmsget_ef, ctypes.byref(efn))
35
 
    return efn.value
36
 

	
37
 
def free_ef(efn):
38
 
    return vmscall(vmsfree_ef, ctypes.byref(ctypes.c_uint(efn)))
39
 

	
40
 
def setimr(efn, tim):
41
 
    s = vmscall(vmssetimr, ctypes.c_uint(efn),
42
 
                ctypes.byref(ctypes.c_longlong(tim)),
43
 
                None, None, None)
44
 
    return s
45
 

	
46
 
def sleepbin(tim):
47
 
    efn = get_ef()
48
 
    setimr(efn, tim)
49
 
    waitfr(efn)
50
 
    free_ef(efn)
51
 

	
52
 
def sleepasc(timbuf):
53
 
    from vms.starlet import bintim
54
 
    s, tim = bintim(timbuf)
55
 
    sleepbin(tim)
56
 

	
57
 
if __name__=='__main__':
58
 
    sleepasc("0 00:00:30.00")
0 comments (0 inline, 0 general)