Python Busy Strategy Hooks

Devices which are not supported by the Genius Server can be monitored (if they are busy or not) with a control over functionality created with Python.

In this way it is possible to configure "new" busy strategies without releasing a new version of the Genius Server.

Hooks Directory Structure

Hooks are special Python scripts, which are included into a folder named hooks in the phoenix-base directory.

Three device hook paths for Samsung devices are shown below:

Device Serial Number: Z6QTB1AC500002W
/phoenix-base/hooks/device/Z6QTB1AC500002W/busy.py

Samsung Model: CLX 92x1 93x1 series (lowercase and using underscore)
/phoenix-base/hooks/device-type/236/samsung_clx-92x1_93x1_series/busy.py

Vendor Number: 236
/phoenix-base/hooks/device-type/236/busy.py

Hook files are overwritten to specify:

  1. Serial Number.

  2. Model Name.

  3. Vendor Number.

Note

A lower number overwrites a higher number.

Example

from com.phoenix2.core.dto.mfpdevice.exception import MfpDeviceUnreachableException
from org.slf4j import LoggerFactory

log = LoggerFactory.getLogger("python")

def activejobs():
    from BeautifulSoup import BeautifulSoup
    from urllib import urlopen
    import contextlib

    try:
        with contextlib.closing(urlopen("http://%s/sws.application/gnb/activeJobsListView.sws" % device.address)) as conn:
            html = BeautifulSoup(conn.read())
            jobs = int(html.find('td', {'id': 'selectedRange'}).getString().split(':')[1])
            log.debug('active jobs {} for device {}', jobs, device.address)
            return jobs
    except Exception, e:
        log.error('py script busy.py error', e)
        raise MfpDeviceUnreachableException(e.message)

hrPrinterStatus = snmp.get('1.3.6.1.2.1.25.3.5.1.1.1').valueNumber.intValue()
log.debug("hrPrinterStatus {} for device {}", hrPrinterStatus, device.address)
busy = hrPrinterStatus in [4, 5] or ( hrPrinterStatus == 1 and activejobs() > 0 )

Note

Some devices require a specific strategy for busy detection. In that case, users can define a custom strategy with the hook files. In case of need, contact the support at support@geniusbytes.com.