rcsb/py-rcsb_app_file

Using variable 'ct' before assignment (used-before-assignment)

Closed this issue · 1 comments

Using variable 'ct' before assignment (used-before-assignment).

logger.exception("Failing for %r %r with %s", fn, ct, str(e))

To fix, should initialize ct = None prior to the try/except block:

    ct = None
    try:
        cachePath = os.environ.get("CACHE_PATH", ".")
        configFilePath = os.environ.get("CONFIG_FILE")
        cP = ConfigProvider(cachePath, configFilePath)
        #
        fn = uploadFile.filename
        ct = uploadFile.content_type
        logger.debug("sliceIndex %d sliceTotal %d fn %r", sliceIndex, sliceTotal, fn)
        ioU = IoUtils(cP)
        ret = await ioU.storeSlice(uploadFile.file, sliceIndex, sliceTotal, sessionId, copyMode=copyMode, hashType=hashType, hashDigest=hashDigest)
        logger.debug("sliceIndex %d sliceTotal %d return %r", sliceIndex, sliceTotal, ret)
    except Exception as e:
        logger.exception("Failing for %r %r with %s", fn, ct, str(e))
        ret = {"success": False, "statusCode": 400, "statusMessage": "Slice upload fails with %s" % str(e)}

Resolved with 7586c79