Example #1
0
def parse_cups_file_from_image(mac_info, filepath):
    '''Process individual job file (c00xxx) and return list of properties'''
    j_file = mac_info.Open(filepath)
    if j_file != None:
        ippdatas = j_file.read()
        request = pkipplib.IPPRequest(ippdatas)
        request.parse()
        j_file.close()
    else:
        log.error('Error parsing cups job file ' + filepath + ' Error=' +
                  str(ex))
        return None
    return get_job_properties(request, filepath)
Example #2
0
def parse_cups_file(filepath):
    '''Process individual job file (c00xxx) and return list of properties'''
    try:
        with open(filepath, 'rb') as j_file:
            ippdatas = j_file.read()
            try:
                request = pkipplib.IPPRequest(ippdatas)
                request.parse()
            except pkipplib.IPPError as ex:
                log.exception('Error from pkipplib - {} for file {}'.format(
                    str(ex), filepath))
    except (OSError):
        log.exception('Error opening cups job file ' + filepath)
        return None
    return get_job_properties(request, filepath)