def send_command(remote, filename='REMOTE.LOG'):</span>
print("### debug send_command")
f=open(filename,'wb')
print("### debug 000-0")
f.write(remote)
print("### debug 000-1")
f.close()
print("### debug 000-2")
try:
print("### debug 000-10")
debuglevel = 0
cookies = http.cookiejar.CookieJar()
print("### debug 000-10-1")
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookies),
urllib.request.HTTPHandler(debuglevel=debuglevel),
MultipartPostHandler)
print("### debug 000-11")
command_cgi = 'http://flashair/command.cgi'
get_params = {'op' : 108}
print("### debug 000-12")
print("### debug:" + command_cgi + '?' + urllib.parse.urlencode(get_params) )
print("### debug 000-13")
get_params = {'op' : 118}
print("### debug 000-14")
upload_cgi = 'http://flashair/upload.cgi'
print("### debug 000-14-1")
ftime = '0x5367b232'
print("### debug 000-14-2 : " + ftime )
get_params = {'UPDIR' : '/ADDON/' , 'FTIME' : ftime}
post_params = { "file" : open(filename, "rb") }
print("### debug 000-15-0-1 : " + upload_cgi + '?' + urllib.parse.urlencode(get_params))
print("### debug 000-15-0-3 : ")
stream = os.popen('curl "http://flashair/upload.cgi?UPDIR=/ADDON/&FTIME=0x5367b232"')
output = stream.read()
print(output)
print("### debug 000-15-0-4 : ")
stream = os.popen('curl --form "file=@REMOTE.LOG" "http://flashair/upload.cgi"')
output = stream.read()
print(output)
print("### debug 000-15-0-5 : ")
output = stream.read()
print(output)
print("### debug 000-15-1")
print("### debug 000-16")
response = opener.open(upload_cgi, post_params)
opener.close()
soup = BeautifulSoup(response)
if soup.html.h1.string != "Success":
raise Exception(soup.prettify())
print(" ... Successed")
except urllib.error.URLError as e :
print("### debug 001")
print(e.reason)
return False
except Exception as e:
print("### debug 002")
print(e)
return False
except:
print("### debug 003")
print(sys.exc_info())
return False
return True