File upload with HTTP-POST

Asked

Viewed 46 times

1

When running the script to send the file it returns me this message.

Traceback (most recent call last):
File "modelo.py", line 102, in <module>
filepath = args.filepath
AttributeError: 'Namespace' object has no attribute 'filepath'

The snippet of the code he claims is the one inside the.py model.

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'c:/users/arquivo',
        help='Caminho completo até o arquivo que se deseja enviar'
    )
    parser.add_argument(
        'teste',
        help='Nome do método do respectivo arquivo'
    )
    parser.add_argument(
        'seee',
        help='Nome do usuário cadastrado no sistema'
    )
    parser.add_argument(
        'sdfgfgdffhgt54828',
        help='Chave secreta que autentica o usuário'
    )
    parser.add_argument(
        '20190511180000.csv.gz',
        help='Nome do arquivo que será salvo no data lake.'
    )
    args = parser.parse_args()

    **filepath = args.filepath** <-- ESSA É A LINHA 102
    filename = args.filename
    methodname = args.methodname
    username = args.username
    secretkey = args.secretkey

    file_obj = File(filepath, filename)

    # Send data
    file_obj.post(username, methodname, secretkey) 
  • What exactly are you trying to do? The library argparse serves to create a CLI, but it seems that you are trying to use it to execute a command. And where exactly enter the python-requests and http-post which you have placed as a question tag?

  • I’m sending a . gzip file to a data analysis server... To send this file that will be read, it has to be in gzip and sent by http-post. In the.py template file I have the upload parameters, but when I run it, it returns me the message as if I were not inserted the args "file path".

  • So you’re really trying to execute a command? The library argparse doesn’t do that.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.