Estou com este erro quando envio o comando python para requisição http e fazendo curl normalmente a requisição é realizada .podem ajudar ? O erro é este :
python portal_ativos.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0* Could not resolve host: application
* Closing connection 0
curl: (6) Could not resolve host: application
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3333 (#1)
> PUT /artefato HTTP/1.1
> Host: localhost:3333
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 28
> Content-Type: application/x-www-form-urlencoded
>
} [28 bytes data]
* upload completely sent off: 28 out of 28 bytes
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 115
< ETag: W/"73-51WIRsS/EMTI+evC7B0f8GGJS/c"
< Date: Wed, 26 Feb 2020 21:16:20 GMT
< Connection: keep-alive
<
{ [115 bytes data]
100 143 100 115 100 28 115 28 0:00:01 --:--:-- 0:00:01 1833
* Connection #1 to host localhost left intact
{
"message": " Ativo update !!",
"ativo": {
"n": 1,
"nModified": 0,
"ok": 1
}
}Command => curl -X PUT -v -H 'Content-Type: application/json' -d '{"nome":"Splunk","versao":"7.3.1"}' http://localhost:3333/artefato
import sys, subprocess, os, shutil, distutils.dir_util, distutils.file_util
from os import listdir, stat, getenv, path, remove
from sys import argv
class PortalAtivos(object):
def __init__(self):
self.APP_NAME = "Splunk"
self.APP_VERSION = "7.3.1"
self.PORTAL_URL = "http://localhost:3333/artefato"
def define_update(self, app_name, app_version, portal_url):
command = "curl -X PUT -v -H 'Content-Type: application/json' -d '{\"nome\"" + ":" + "\"" + app_name + "\"" + "," + "\"versao\"" + ":" + "\"" + app_version + "\"}' " + portal_url
print("Command => ", command)
subprocess.call(command)
def update(self):
self.define_update(self.APP_NAME, self.APP_VERSION, self.PORTAL_URL)
if __name__ == '__main__':
portalativos = PortalAtivos()
portalativos.update()