Ejemplo n.º 1
0
 def close():
     nonlocal cmd
     resp = sendCmd(host,  port, stream(cmd))
     delete = getElement(resp, "Delete")
     if delete is None:
         validationFailure("Failed to remove publication \n%s"%stream(cmd))
     return delete.get("IDFILE") if isinstance(delete, (etree._Element, )) else None
Ejemplo n.º 2
0
 def close() -> tuple:
     resp = sendCmd(host, port, stream(RemovePublicationDevicesCmd(ID, devices)))
     error = getElement(resp, "ERROR")
     if error is not None:
         validationFailure("removePublicationDevices failed for %s because %s for devices %s"%(ID, error.text, tuple(devices)))
         return ID, RESULTCODES.FAIL
     else:
         return ID, RESULTCODES.PASS
Ejemplo n.º 3
0
 def close() -> tuple:
     resp = sendCmd(host, port, stream(x))
     error = getElement(resp, "ERROR")
     if error is not None:
         validationFailure("addPublication failed because %s:\n%s"%(error.text, stream(x)))
         return getAttrText(resp, "IDFILE"), RESULTCODES.FAIL
     else:
         return getAttrText(resp, "IDFILE"), RESULTCODES.PASS
Ejemplo n.º 4
0
def removeUnusedDevices(cmdgen=removeUnusedDeviceCmds, srv="192.168.168.21", port=5011) -> Generator:
    for cmd in cmdgen():
        resp = sendCmd(srv, port, stream(cmd))
        elst = getElementList(resp, "Delete")
        if elst is None or len(elst) == 0:
            validationFailure("removeUnusedDevices failed. Response was empty.")
        else:
            yield [getAttrText(delel, "IDDEVICE") for delel in elst]
    return
Ejemplo n.º 5
0
 def close() -> tuple:
     resp = sendCmd(host, port, stream(x[0]))
     error = getElement(resp, "ERROR")
     undi = getAttrText(resp, "UNDI")
     if error is not None:
         validationFailure("addDevice for %s failed because because '%s'"%(undi, error))
         return undi, RESULTCODES.FAIL
     else:
         return undi, RESULTCODES.PASS
Ejemplo n.º 6
0
def getPublicationIDs(host="192.168.168.21", port=5011) -> Generator:
    """
    produce a generator of publication ID's.
    """
    resp = sendCmd(host, port, stream(QPublications()))
    error = getElement(resp, "ERROR")
    if error is not None:
        validationFailure("getPublicationIDs failed because %s"%error.text)
    else:
        yield from (x.get("IDFILE") for x in getElementList(resp, "File") if x is not None)
    return