From a4d7148a5220e488efec14fe7a017ed39eaa1023 Mon Sep 17 00:00:00 2001 From: Pascal Gollor Date: Fri, 5 Aug 2022 14:21:11 +0200 Subject: [PATCH] add option to change host url for OTA upload --- tools/espupload.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/espupload.py b/tools/espupload.py index 0b2766cd0..625e20229 100644 --- a/tools/espupload.py +++ b/tools/espupload.py @@ -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 \ No newline at end of file +# end if