Merge pull request #16159 from pgollor/pgollor-patch1

add option to change host url for OTA upload
This commit is contained in:
Theo Arends 2022-08-06 09:31:09 +02:00 committed by GitHub
commit 5086082de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -19,8 +19,8 @@ HOST_ADDR = "domus1"
HOST_PORT = 80
HOST_URL = "/api/upload-arduino.php"
def upload(hostAddr, hostPort, filename):
url = 'http://%s:%d%s' % (hostAddr, hostPort, HOST_URL)
def upload(hostAddr, hostPort, hostUrl, filename):
url = 'http://%s:%d%s' % (hostAddr, hostPort, hostUrl)
c = pycurl.Curl()
c.setopt(c.URL, url)
# 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."
)
# destination ip and port
# destination ip, port and url
group = optparse.OptionGroup(parser, "Destination")
group.add_option("-i", "--host_ip",
dest = "host_ip",
action = "store",
help = "Host IP Address.",
help = "Host IP Address. Default: " + HOST_ADDR,
default = HOST_ADDR
)
group.add_option("-p", "--host_port",
dest = "host_port",
type = "int",
help = "Host server ota Port. Default 80",
help = "Host server ota Port. Default: " + str(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)
# image
@ -104,9 +110,9 @@ def main(args):
return 1
# 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
if __name__ == '__main__':
sys.exit(main(sys.argv))
# end if
# end if