~ubuntu-branches/ubuntu/saucy/hplip/saucy-proposed

« back to all changes in this revision

Viewing changes to base/status.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1490
1490
    if data[0] is not '<':
1491
1491
        size = -1
1492
1492
        temp = ""
1493
 
        while size: 
 
1493
        while size:
1494
1494
            index = data.find('\r\n')
1495
1495
            size = int(data[0:index+1], 16)
1496
1496
            temp = temp + data[index+2:index+2+size]
1498
1498
        data = temp
1499
1499
    return data
1500
1500
 
1501
 
def StatusType10FetchUrl(dev, url, footer=""):
 
1501
def StatusType10FetchUrl(func, url, footer=""):
1502
1502
    data_fp = cStringIO.StringIO()
1503
1503
    if footer:
1504
 
        data = dev.getEWSUrl_LEDM(url, data_fp, footer)
 
1504
        #data = dev.getEWSUrl_LEDM(url, data_fp, footer)
 
1505
        data = func(url, data_fp, footer)
1505
1506
    else:
1506
 
        data = dev.getEWSUrl_LEDM(url, data_fp)
 
1507
        #data = dev.getEWSUrl_LEDM(url, data_fp)
 
1508
        data = func(url, data_fp)
1507
1509
        if data:
1508
1510
            data = data.split('\r\n\r\n', 1)[1]
1509
1511
            if data:
1510
1512
                data = clean(data)
1511
1513
    return data
1512
1514
 
1513
 
def StatusType10(dev): # Low End Data Model
 
1515
def StatusType10(func): # Low End Data Model
1514
1516
    status_block = { 'revision' :    STATUS_REV_UNKNOWN,
1515
1517
                     'agents' :      [],
1516
1518
                     'top-door' :    TOP_DOOR_NOT_PRESENT,
1528
1530
        return status_block
1529
1531
 
1530
1532
    # Get the dynamic consumables configuration
1531
 
    data = StatusType10FetchUrl(dev, "/DevMgmt/ConsumableConfigDyn.xml")
 
1533
    data = StatusType10FetchUrl(func, "/DevMgmt/ConsumableConfigDyn.xml")
1532
1534
    if not data:
1533
1535
        return status_block
1534
1536
    data = data.replace("ccdyn:", "").replace("dd:", "")
1562
1564
                        ink_level = 100
1563
1565
 
1564
1566
                log.debug("type '%s' state '%s' ink_type '%s' ink_level %d" % (type, state, ink_type, ink_level))
1565
 
    
 
1567
 
1566
1568
                entry = { 'kind' : element_type10_xlate.get(type, AGENT_KIND_NONE),
1567
1569
                          'type' : pen_type10_xlate.get(ink_type, AGENT_TYPE_NONE),
1568
1570
                          'health' : pen_health10_xlate.get(state, AGENT_HEALTH_OK),
1579
1581
    status_block['agents'] = agents
1580
1582
 
1581
1583
    # Get the media handling configuration
1582
 
    data = StatusType10FetchUrl(dev, "/DevMgmt/MediaHandlingDyn.xml")
 
1584
    data = StatusType10FetchUrl(func, "/DevMgmt/MediaHandlingDyn.xml")
1583
1585
    if not data:
1584
1586
        return status_block
1585
1587
    data = data.replace("mhdyn:", "").replace("dd:", "")
1613
1615
            status_block['duplexer'] = DUPLEXER_DOOR_CLOSED
1614
1616
 
1615
1617
    # Get the product status
1616
 
    data = StatusType10FetchUrl(dev, "/DevMgmt/ProductStatusDyn.xml")
 
1618
    data = StatusType10FetchUrl(func, "/DevMgmt/ProductStatusDyn.xml")
1617
1619
    if not data:
1618
1620
        return status_block
1619
1621
    data = data.replace("psdyn:", "").replace("locid:", "")