36
36
import argparse
37
37
import requests
38
38
39
- #HOST_URL = "domus1:80/api/upload-arduino.php"
39
+ # Default URL overwritten by [env] and/or [env:tasmota32_base] upload_port
40
40
HOST_URL = "otaserver/ota/upload-tasmota.php"
41
41
42
42
def main (args ):
@@ -57,17 +57,27 @@ def main(args):
57
57
# end if
58
58
59
59
if not os .path .exists (args .image ):
60
- print ('Sorry: the file %s does not exist' , args .image )
60
+ print ('Sorry: the file {} does not exist' . format ( args .image ) )
61
61
return 2
62
62
# end if
63
63
64
- # copy firmware.bin to tasmota.bin or tasmota32.bin
65
- tname = os .path .normpath (os .path .dirname (args .image ))
66
- new_filename = tname + os .sep + os .path .basename (tname ) + '.bin'
67
- shutil .copy2 (args .image , new_filename )
64
+ if args .image .find ("firmware.bin" ) != - 1 :
65
+ # Legacy support for $SOURCE
66
+ # copy firmware.bin to tasmota.bin or tasmota32.bin
67
+ # C:\tmp\.pioenvs\tasmota-theo\firmware.bin
68
+ tname = os .path .normpath (os .path .dirname (args .image ))
69
+ # C:\tmp\.pioenvs\tasmota-theo\tasmota-theo.bin
70
+ upload_file = tname + os .sep + os .path .basename (tname ) + '.bin'
71
+ shutil .copy2 (args .image , upload_file )
72
+ else :
73
+ # Support for bin_file and bin_gz_file
74
+ upload_file = args .image
75
+ # end if
76
+
77
+ # print('Debug filename in {}, upload {}'.format(args.image, upload_file))
68
78
69
79
url = 'http://%s' % (args .host_url )
70
- files = {'file' : open (new_filename , 'rb' )}
80
+ files = {'file' : open (upload_file , 'rb' )}
71
81
req = requests .post (url , files = files )
72
82
print (req .text )
73
83
# end main
0 commit comments