pyvms module

(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index)

The 'pyvms' module provides access to OpenVMS-related components: command history, item codes (fac$_name), bitmasks (fac$M_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 $GETSYI(SYI$_VERSION) !!

Lists:

definitions
List of all definitions (e.g. '$DVIDEF','$QUIDEF').

Methods:


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'>
>>> type (pyvms.vms_version_number)
<type 'int'>
>>>
>>> print pyvms.definitions
['$DVIDEF', '$JPIDEF', '$LNMDEF', '$QUIDEF', '$SYIDEF']
>>> 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()
>>>
@@ to be enhanced
(go to: table of contents, index)

23-MAR-1998 ZE.