def getResult(jobId):
    printDebugMessage(u'getResult', u'Begin', 1)
    printDebugMessage(u'getResult', (u'jobId: ' + jobId), 1)
    if (outputLevel > 1):
        print(('Getting results for job %s' % jobId))
    clientPoll(jobId)
    resultTypes = serviceGetResultTypes(jobId)
    for resultType in resultTypes:
        if options.outfile:
            filename = ((((options.outfile + u'.') + unicode(resultType[u'identifier'])) + u'.') + unicode(resultType[u'fileSuffix']))
        else:
            filename = ((((jobId + u'.') + unicode(resultType[u'identifier'])) + u'.') + unicode(resultType[u'fileSuffix']))
        outformat_parm = str(options.outformat).split(',')
        for outformat_type in outformat_parm:
            outformat_type = outformat_type.replace(' ', '')
            if (outformat_type == 'None'):
                outformat_type = None
            if ((not outformat_type) or (outformat_type == unicode(resultType[u'identifier']))):
                if (outputLevel > 1):
                    print(('Getting %s' % unicode(resultType[u'identifier'])))
                result = serviceGetResult(jobId, unicode(resultType[u'identifier']))
                if ((unicode(resultType[u'mediaType']) == u'image/png') or (unicode(resultType[u'mediaType']) == u'image/jpeg') or (unicode(resultType[u'mediaType']) == u'application/gzip')):
                    fmode = 'wb'
                else:
                    fmode = 'w'
                try:
                    fh = open(filename, fmode)
                    fh.write(result)
                    fh.close()
                except TypeError:
                    fh.close()
                    fh = open(filename, 'wb')
                    fh.write(result)
                    fh.close()
                if (outputLevel > 0):
                    print(('Creating result file: ' + filename))
    printDebugMessage(u'getResult', u'End', 1)
def getResult(jobId):
    printDebugMessage(u'getResult', u'Begin', 1)
    printDebugMessage(u'getResult', (u'jobId: ' + jobId), 1)
    if (outputLevel > 1):
        print(('Getting results for job %s' % jobId))
    clientPoll(jobId)
    resultTypes = serviceGetResultTypes(jobId)
    for resultType in resultTypes:
        if options.outfile:
            filename = ((((options.outfile + u'.') + unicode(resultType[u'identifier'])) + u'.') + unicode(resultType[u'fileSuffix']))
        else:
            filename = ((((jobId + u'.') + unicode(resultType[u'identifier'])) + u'.') + unicode(resultType[u'fileSuffix']))
        outformat_parm = str(options.outformat).split(',')
        for outformat_type in outformat_parm:
            outformat_type = outformat_type.replace(' ', )
            if (outformat_type == 'None'):
                outformat_type = None
            if ((not outformat_type) or (outformat_type == unicode(resultType[u'identifier']))):
                if (outputLevel > 1):
                    print(('Getting %s' % unicode(resultType[u'identifier'])))
                result = serviceGetResult(jobId, unicode(resultType[u'identifier']))
                if ((unicode(resultType[u'mediaType']) == u'image/png') or (unicode(resultType[u'mediaType']) == u'image/jpeg') or (unicode(resultType[u'mediaType']) == u'application/gzip')):
                    fmode = 'wb'
                else:
                    fmode = 'w'
                try:
                    fh = open(filename, fmode)
                    fh.write(result)
                    fh.close()
                except TypeError:
                    fh.close()
                    fh = open(filename, 'wb')
                    fh.write(result)
                    fh.close()
                if (outputLevel > 0):
                    print(('Creating result file: ' + filename))
    printDebugMessage(u'getResult', u'End', 1)