Python on OpenVMS
(go to: table of contents,
index)
The 'pyvms' module provides access to OpenVMS-related components:
C-RTL functions, command history, item codes (fac$_name), bitmasks (fac$M_name),
constants (fac$C_name or fac$K_name) and other information.
IMPLEMENTATION IS NOT COMPLETE.
Items:
- vms_version_number
- Numeric value of vms version number that is used internally.
You cannot translate the number to the string, because some strings (e.g.
'A5.5-2H4' and 'V5.5-2H4' map to the same number (05524). So, this is NOT
the same as SYS$GETSYI(SYI$_VERSION) !!
Lists:
- definitions
- List of all definitions (e.g. '$DVIDEF','$QUIDEF').
Methods:
- access to VMSDEF
- item_list
- returns all list of items from a definition (e.g. '$DVIDEF')
- item_get
- returns a dictionary with all details about a specific item code
(e.g. 'DVI$_CYLINDERS') within a definition (e.g. '$DVIDEF').
- access to command history
- history_delete
- delete command history
- history_get
- return current command history in a list
- history_size
- return current size of command history>
- history_show
- just output command history to screen
- access to the user authorisation file (UAF)
- uaf_get_usernames
- return a list of all usernames from SYSUAF.DAT
- RMS file I/O
- crtl_from_vms
- call the C RTL decc$from_vms() function to translate a file specification
from OpenVMS format into Unix style.
- crtl_open
- call the C RTL open() function with the possibility to specify additional
keywords for RMS.
- crtl_to_vms
- call the C RTL decc$to_vms() function to translate a file specification
from Unix style into OpenVMS format.
Examples:
>>> import pyvms
>>> dir (pyvms)
['__doc__', '__name__', 'definitions', 'history_delete', 'error',
'history_get', 'item_get', 'history_size', 'item_list', 'history_show',
'vms_version_number']>>>
>>> type (pyvms.definitions)
<type 'list'>
>>> print pyvms.definitions
['$CIADEF', '$DCDEF', '$DMTDEF', '$DVIDEF', '$DVSDEF', '$FABDEF',
'$FSCNDEF', '$INITDEF', '$JPIDEF', '$LCKDEF', '$LNMDEF', '$MAILDEF',
'$MNTDEF', '$NAMDEF', '$OSSDEF', '$PQLDEF', '$PRCDEF', '$PRVDEF',
'$PSCANDEF', '$QUIDEF', '$RABDEF', '$RSDMDEF', '$SJCDEF', '$STATEDEF',
'$SYIDEF', '$TRMDEF', '$UAIDEF', '$XABALLDEF', '$XABFHCDEF',
'$XABITMDEF', '$XABKEYDEF', '$XABPRODEF']
>>>
>>> type (pyvms.vms_version_number)
<type 'int'>
>>> print pyvms.vms_version_number
6100
-- compare this
with:
>>> import vms_lib
>>> print vms_lib.getsyi ('SYI$_VERSION',0)
(0, 'V6.1 ')
>>>
>>> import os
>>> os.system('write sys$output F$GETSYI("VERSION")')
V6.1 <--- output from F$GETSYI()
65537 <--- status from os.system() = RMS$_NORMAL
>>> print pyvms.definitions[1]
$JPIDEF
>>> print len(pyvms.definitions)
4
>>> item_list = pyvms.item_list ('$DVIDEF');
>>> print len(item_list)
161
>>> print item_list
['DVI$_ACPPID', 'DVI$_ACPTYPE', 'DVI$_ALL', 'DVI$_ALLDEVNAM',
'DVI$_ALLOCLASS', 'DVI$_ALT_HOST_AVAIL', 'DVI$_ALT_HOST_NAME',
[...]
'DVI$_VPROT', 'DVI$_WCK']
>>> values = pyvms.item_get ('$DVIDEF', 'DVI$_CYLINDERS', None)
>>> type (values)
<type 'dictionary'>
>>> print values
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
'vms_version_min' : 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 0, 'item_code': 40}
>>> print values['vms_version_max']
32767
>>> values = pyvms.item_get ('$SYIDEF', 'SYI$_CHECK_CLUSTER', None)
>>> print values
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 0,
'vms_version_min' : 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 0, 'item_code': 8243}
--> 'applies_to_alpha': 0
>>> values = pyvms.item_get ('$QUIDEF', 'QUI$_FILE_FLAGS', None)
>>> print values
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
'vms_version_min' : 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 1, 'item_code': 19}
>>>
>>> values = pyvms.item_get ('$QUIDEF', 'QUI$_FILE_FLAGS', 1)
>>> print values
{'buffer_size': 4, 'applies_to_vax': 1,
'applies_to_alpha': 1, 'vms_version_min' : 5520, 'vms_version_max': 32767,
'bitmask': ['QUI_M_FILE_BURST', 'QUI_M_FILE_BURST_EXP', 'QUI_M_FILE_DELETE',
'QUI_M_FILE_DELETE_ALWAYS', 'QUI_M_FILE_DOUBLE_SPACE', 'QUI_M_FILE_FLAG',
'QUI_M_FILE_FLAG_EXP', 'QUI_M_FILE_PAGE_HEADER', 'QUI_M_FILE_PAGINATE',
'QUI_M_FILE_PAGINATE_EXP', 'QUI_M_FILE_PASSALL', 'QUI_M_FILE_TRAILER',
'QUI_M_FILE_TRAILER_EXP'], 'returns_bitmask': 1, 'item_code': 19}
>>>
>>> bitmask_list = values['bitmask']
>>> type (bitmask_list)
<type 'list'>
>>> import vms_quidef
>>> bit_name = bitmask_list[1]
>>> print bit_name
QUI_M_FILE_BURST_EXP
>>> bit_value = getattr (vms_quidef,bit_name)
>>> print bit_value
2
>>> print vms_quidef.QUI_M_FILE_BURST_EXP
2
>>>
>>> item_list = pyvms.item_list ('$DVIDEF');
>>> for item_code in item_list:
... print item_code
... item_data = pyvms.item_get ('$DVIDEF', item_code, None)
... print item_data
... #end
...
DVI$_ACPPID
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
'vms_version_min' : 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 0, 'item_code': 64}
DVI$_ACPTYPE
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
[...]
DVI$_VPROT
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
'vms_version_min': 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 0, 'item_code': 18}
DVI$_WCK
{'buffer_size': 4, 'applies_to_vax': 1, 'applies_to_alpha': 1,
'vms_version_min': 5520, 'vms_version_max': 32767, 'bitmask': None,
'returns_bitmask': 0, 'item_code': 124}
>>>
- command history related routines
>>> import pyvms
>>> pyvms.history_show()
1 import pyvms
2 pyvms.history_show()
>>> a=1
>>> pyvms.history_show()
1 import pyvms
2 pyvms.history_show()
3 a=1
4 pyvms.history_show()
>>> list = pyvms.history_get()
>>> print pyvms.history_size()
>>> pyvms.history_show()
1 import pyvms
2 pyvms.history_show()
3 a=1
4 pyvms.history_show()
5 list = pyvms.history_get()
6 print pyvms.history_size()
7 pyvms.history_show()
>>> print list # output is manually wrapped for RUNOFF format
[('\012>>> ', 'import pyvms\012'), ('\012>>> ', 'pyvms.show_histo
ry()\012'), ('\012>>> ', 'a=1\012'), ('\012>>> ', 'pyvms.show_his
tory()\012'), ('\012>>> ', 'list = pyvms.history_get()\012')]
>>> pyvms.history_delete(0)
9
>>> pyvms.history_show()
1 pyvms.history_show()
>>>
Alphabetical list of UAF-related routines:
Alphabetical list of RMS file I/O-related routines:
@@ to be enhanced
(go to: table of contents,
index)
15-JUL-1999 ZE.