mirror of https://github.com/arendst/Tasmota.git
Merge pull request #16159 from pgollor/pgollor-patch1
add option to change host url for OTA upload
This commit is contained in:
commit
5086082de0
|
@ -19,8 +19,8 @@ HOST_ADDR = "domus1"
|
||||||
HOST_PORT = 80
|
HOST_PORT = 80
|
||||||
HOST_URL = "/api/upload-arduino.php"
|
HOST_URL = "/api/upload-arduino.php"
|
||||||
|
|
||||||
def upload(hostAddr, hostPort, filename):
|
def upload(hostAddr, hostPort, hostUrl, filename):
|
||||||
url = 'http://%s:%d%s' % (hostAddr, hostPort, HOST_URL)
|
url = 'http://%s:%d%s' % (hostAddr, hostPort, hostUrl)
|
||||||
c = pycurl.Curl()
|
c = pycurl.Curl()
|
||||||
c.setopt(c.URL, url)
|
c.setopt(c.URL, url)
|
||||||
# The "Expect:" is there to suppress "Expect: 100-continue" behaviour that is
|
# The "Expect:" is there to suppress "Expect: 100-continue" behaviour that is
|
||||||
|
@ -36,20 +36,26 @@ def parser():
|
||||||
description = "Upload image to over the air Host server for the esp8266 module with OTA support."
|
description = "Upload image to over the air Host server for the esp8266 module with OTA support."
|
||||||
)
|
)
|
||||||
|
|
||||||
# destination ip and port
|
# destination ip, port and url
|
||||||
group = optparse.OptionGroup(parser, "Destination")
|
group = optparse.OptionGroup(parser, "Destination")
|
||||||
group.add_option("-i", "--host_ip",
|
group.add_option("-i", "--host_ip",
|
||||||
dest = "host_ip",
|
dest = "host_ip",
|
||||||
action = "store",
|
action = "store",
|
||||||
help = "Host IP Address.",
|
help = "Host IP Address. Default: " + HOST_ADDR,
|
||||||
default = HOST_ADDR
|
default = HOST_ADDR
|
||||||
)
|
)
|
||||||
group.add_option("-p", "--host_port",
|
group.add_option("-p", "--host_port",
|
||||||
dest = "host_port",
|
dest = "host_port",
|
||||||
type = "int",
|
type = "int",
|
||||||
help = "Host server ota Port. Default 80",
|
help = "Host server ota Port. Default: " + str(HOST_PORT),
|
||||||
default = HOST_PORT
|
default = HOST_PORT
|
||||||
)
|
)
|
||||||
|
group.add_option("-u", "--host_url",
|
||||||
|
dest = "host_url",
|
||||||
|
action = "store",
|
||||||
|
help = "Host Url with / at beginning. Default: '" + HOST_URL + "'",
|
||||||
|
default = HOST_URL
|
||||||
|
)
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
# image
|
# image
|
||||||
|
@ -104,9 +110,9 @@ def main(args):
|
||||||
return 1
|
return 1
|
||||||
# end if
|
# end if
|
||||||
|
|
||||||
upload(options.host_ip, options.host_port, options.image)
|
upload(options.host_ip, options.host_port, options.host_url, options.image)
|
||||||
# end main
|
# end main
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(sys.argv))
|
sys.exit(main(sys.argv))
|
||||||
# end if
|
# end if
|
||||||
|
|
Loading…
Reference in New Issue