1

I am trying to pass a file from PHP into Python where I can upload to Azure Blob Storage via the Azure Python SDK.

PHP:

$output = shell_exec("/usr/bin/python /opt/UploadFile.py $filePath $container $blob");
die(var_dump($output));

Python:

import sys
from azure.storage import BlobService

upload = sys.argv[1];
container = sys.argv[2]; 
blob = sys.argv[3];
blob_service = BlobService(account_name='HIDDEN', account_key='HIDDEN')


try:
    blob_service.put_block_blob_from_path(
        continer,
        blob,
        upload
    )
except:
    print "error"

I am getting the catch exception. I have verified that the variables are coming over correctly from PHP. Not sure why its not working. I am new to Python what else can I do to debug that the .put_block_blob_from_path() is working?

4
  • Instead of printing just the string "error", you could try printing the actual error message. See this link for try/catch reference in Python: docs.python.org/2/tutorial/errors.html. Also print "container", "blob" and "upload" variable values to see correct values are being passed. HTH. Commented Feb 17, 2015 at 5:23
  • I printed the container, blob, and upload they are correct and being passed in correctly Commented Feb 17, 2015 at 6:41
  • How about printing the actual error message? Commented Feb 17, 2015 at 6:47
  • That is what I am looking at to do now. I see lots of exceptions like IO,etc. I am trying to find just a basic catch all exception for my issue Commented Feb 17, 2015 at 6:49

1 Answer 1

3

I figured out if I added

print sys.exc_info()[1]

in the except:.

I would get a nice print of the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.