(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index, list of vms_sys, prev: DELPRC, next: DISMOU)


DEVICE_SCAN - Scan for Devices


Returns the names of all devices that match a specified set of search criteria.

Format:

    return_devnam, contxt = vms_sys.device_scan \
        ([search_devnam], [itmlst], [contxt))
Returns:
return_devnam
the device name of the first or next matching (if context is used) device name.
contxt
The contxt argument which was updated from SYS$DEVICE_SCAN. If the 'contxt' argument to the routine is not used, then a 'None' otherwise a Python long integer is returned. That means a value is _always_ returned for consistency.
Arguments:
search_devnam
Name of the device for which SYS$DEVICE_SCAN is to search. Wildcards are allowed - please see the system services reference manual or the following examples section.
itmlst
Input item list to specify search criteria. See the examples section below.
contxt
Value used to indicate the current position of a SYS$DEVICE_SCAN search. On the initial call a 0L (a Python long integer) must be delivered. For the next calls the returned 'contxt' must be delivered.
Special notes about the item codes:
Device types and device classes are located in module 'vms_dcdef'. WARNING! This module contains over 500 constants. Unfortunately there is currently (10-OCT-1998) no way to access them via the 'pyvms' module.

Examples:

>>> import vms_sys

>>> # a simple loop over ALL devices
>>> # Note: no networking software was active on this system
>>> ctx = 0L
>>> while (1):
...   dev, ctx = vms_sys.device_scan('*',None,ctx)
...   print dev
...
_$99$DKB100:
_HERE$OPA0:
_HERE$MBA1:
_HERE$MBA2:
[...]
_HERE$MBA368:
_NLA0:
_HERE$PKB0:
_HERE$LTA0:
_HERE$TTA0:
_HERE$TTA1:
_HERE$TTA2:
_HERE$TTA3:
_HERE$PKA0:
_ESA0:
_GAA0:
_$99$DKA0:
_$99$DKA100:
_HERE$FTA0:
_HERE$FTA5:
[...]
_HERE$FTA16:
_INA0:
_IMA0:
_IKA0:
_WSA0:
_WSA1:
_HERE$PXA0:
_HERE$HPA0:
Traceback (innermost last):
  File "<stdin>", line 2, in ?
vms_sys.error: (2648, '%SYSTEM-W-NOMOREDEV, no more devices')
>>> #


>>> # loop over a limited set of devices specified by wildcard
>>> search_devnam = '*$DKA*'  # $99$DKB100: does exist
>>> ctx = 0L
>>> while (1):
...   dev, ctx = vms_sys.device_scan(search_devnam,None,ctx)
...   print dev, ctx
...
_$99$DKA0: 2169249856L
_$99$DKA100: 431665979456L
Traceback (innermost last):
  File "<stdin>", line 2, in ?
vms_sys.error: (2648, '%SYSTEM-W-NOMOREDEV, no more devices')
>>>


>>> # search for disks, get maxblock
>>> import vms_lib
>>> import vms_sys
>>> DC__DISK = 1    # bypass module 'vms_dcdef'
>>> itmlst = (('DVS$_DEVCLASS',DC__DISK),)
>>> ctx = 0L
>>> while (1):
...   dev, ctx = vms_sys.device_scan('*',itmlst,ctx)
...   print dev, vms_lib.getdvi('DVI$_MAXBLOCK',None,dev)
...
_$99$DKB100: 2091144
_$99$DKA0: 0
_$99$DKA100: 2091144
Traceback (innermost last):
  File "<stdin>", line 2, in ?
vms_sys.error: (2648, '%SYSTEM-W-NOMOREDEV, no more devices')
>>> # Note: _$99$DKA0: was not mounted


>>> # search for a combination of device class and type
>>> # two terminals have been set to VT100
>>> DC__TERM = 66    # bypass module 'vms_dcdef'
>>> DT_VT100 = 96
>>> itmlst = (('DVS$_DEVCLASS',DC__TERM),\
...           ('DVS$_DEVTYPE', DT_VT100) )
>>> ctx = 0L
>>> while (1):
...   dev, ctx = vms_sys.device_scan('*',itmlst,ctx)
...   print dev
...
_HERE$FTA13:
_HERE$FTA17:
Traceback (innermost last):
  File "<stdin>", line 2, in ?
vms_sys.error: (2648, '%SYSTEM-W-NOMOREDEV, no more devices')
>>>


>>> # if no context is specified, then 'None' is returned
>>> dev, ctx = vms_sys.device_scan('*')
>>> print dev,ctx
_$99$DKB100: None
>>>

>>> dev, ctx = vms_sys.device_scan('*',None,'X')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 3: contxt - must be long integer or None
>>>

>>> dev, ctx = vms_sys.device_scan('*','X')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: itmlst - must be a tuple
>>> # it doesn't say which argument, because this message
>>> #   is from a generic routine at a deeper level

>>> dev, ctx = vms_sys.device_scan(1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 1: expected read-only buffer, int found
>>> #   that means 'string' --- ^^^^^^^^^^^^^^^^
>>>

(go to: table of contents, index, list of vms_sys, prev: DELPRC, next: DISMOU)

10-DEC-1998 ZE.