pyvms module

(LOGO.JPG) Python for 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:


Examples:


>>> import pyvms
>>> dir (pyvms)
['__doc__', '__name__', 'crtl_from_vms', 'crtl_open', 'crtl_to_vms', 'definitions', 'error', 'file_open', 'history_delete', 'history_get', 'history_show', 'history_size', 'item_get', 'item_list', 'test__o2pyl', 'test__pyl2o', 'test__pyl2q', 'test__q2pyl', 'test__uq2pyl', 'uaf_get_usernames', 'vms_version_number', 'vmsobj__membuf', 'vmsobj__ownership_names', 'vmsobj_fab', 'vmsobj_iosb', 'vmsobj_lksb', 'vmsobj_nam', 'vmsobj_rab', 'vmsobj_xaball', 'vmsobj_xabdat', 'vmsobj_xabfhc', 'vmsobj_xabitm', 'vmsobj_xabkey', 'vmsobj_xabpro', 'vmsobj_xabrdt', 'vmsobj_xabsum', 'vmsobj_xabtrm']

>>>
>>> type (pyvms.definitions)
<type 'list'>
>>> print pyvms.definitions
['$BRKDEF', '$CIADEF', '$DCDEF', '$DMTDEF', '$DVIDEF', '$DVSDEF',
'$FABDEF', '$FSCNDEF', '$INITDEF', '$JPIDEF', '$LBRDEF', '$LCKDEF',
'$LIBDTDEF', '$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]
$CIADEF
>>> print len(pyvms.definitions)
35

>>> 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 Python library support routines:

Alphabetical list of RMS file I/O-related routines:

Alphabetical list of UAF-related routines:

(go to: table of contents, index)

22-JAN-2000 ZE.