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

« back to all changes in this revision

Viewing changes to base/LedmWifi.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:
296
296
    if params is not None:
297
297
        try:
298
298
            severity= params['io:vsacodes-wifi:vsacode-dd:severity']
 
299
        except:
 
300
            severity = ""
 
301
        try:
299
302
            rule = params['io:vsacodes-wifi:vsacode-wifi:rulenumber']            
300
 
        except KeyError, e:
301
 
            log.error("Missing response key: %s" % str(e))
 
303
       # except KeyError, e:
 
304
           # log.error("Missing response key: %s" % str(e))
 
305
        except:
 
306
            rule = ""
302
307
        ret.append((rule, severity))       
303
308
    return ret  
304
309
 
362
367
    params,code,elementCount ={},HTTP_ERROR,0 
363
368
    
364
369
    data = format_http_get(URI,0,"")
365
 
    log.info(data)                        
366
 
    dev.openLEDM()
367
 
    dev.writeLEDM(data)
 
370
    log.info(data)
368
371
    response = cStringIO.StringIO()
369
 
    try:
370
 
        while dev.readLEDM(1024, response, timeout):
371
 
            pass
372
 
    except Error:
373
 
        dev.closeLEDM()
374
 
        log.error("Unable to read LEDM Channel") 
375
 
    dev.closeEWS_LEDM()    
376
 
    strResp = str(response.getvalue())    
 
372
    if dev.openLEDM() == -1:
 
373
        dev.openEWS_LEDM()
 
374
        dev.writeEWS_LEDM(data)
 
375
        try:
 
376
            while dev.readEWS_LEDM(1024, response, timeout):
 
377
                pass
 
378
        except Error:
 
379
            dev.closeEWS_LEDM()
 
380
            log.error("Unable to read EWS_LEDM Channel")
 
381
    else:
 
382
        dev.writeLEDM(data)
 
383
 
 
384
    #response = cStringIO.StringIO()
 
385
        try:
 
386
            while dev.readLEDM(1024, response, timeout):
 
387
                pass
 
388
        except Error:
 
389
            dev.closeLEDM()
 
390
            log.error("Unable to read LEDM Channel") 
 
391
    #dev.closeEWS_LEDM()    
 
392
    strResp = str(response.getvalue())
 
393
    #log.error(strResp)
377
394
    if strResp is not None:                             
378
395
        code = get_error_code(strResp)        
379
396
        pos = strResp.find(xmlRootNode,0,len(strResp))    
380
397
        repstr = strResp[pos:].strip()
 
398
        repstr = filter(lambda c: c not in "\r\t\n", repstr) # To remove formating characters from the received xml
 
399
        repstr = repstr.rstrip('0')   # To remove trailing zero from the received xml
381
400
        elementCount = repstr.count(xmlChildNode)                       
382
401
        try:
383
402
            params = utils.XMLToDictParser().parseXML(repstr)            
390
409
def writeXmlDataToURI(dev,URI,xml,timeout=5):
391
410
    code = HTTP_ERROR
392
411
 
393
 
    data = format_http_put(URI,len(xml),xml)  
394
 
    dev.openLEDM()
395
 
    dev.writeLEDM(data)
 
412
    data = format_http_put(URI,len(xml),xml)
396
413
    response = cStringIO.StringIO()
397
 
    try:
398
 
        while dev.readLEDM(1000, response, timeout):
399
 
            pass
400
 
    except Error:
401
 
        dev.closeLEDM()
402
 
        log.error("Unable to read LEDM Channel") 
403
 
    dev.closeLEDM()
 
414
 
 
415
    if dev.openLEDM() == -1:
 
416
        dev.openEWS_LEDM()
 
417
        dev.writeEWS_LEDM(data)
 
418
        try:
 
419
            while dev.readEWS_LEDM(1000, response, timeout):
 
420
                pass
 
421
        except Error:
 
422
                dev.closeEWS_LEDM()
 
423
                log.error("Unable to read EWS_LEDM Channel")
 
424
            
 
425
    else:
 
426
        dev.writeLEDM(data)
 
427
    #response = cStringIO.StringIO()
 
428
        try:
 
429
            while dev.readLEDM(1000, response, timeout):
 
430
                pass
 
431
        except Error:
 
432
            dev.closeLEDM()
 
433
            log.error("Unable to read LEDM Channel") 
 
434
        
 
435
 
404
436
    strResp = str(response.getvalue())    
405
437
    if strResp is not None:
406
438
        code = get_error_code(strResp)