123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- import numpy as np
- import time,sys
- import requests
- import json
- import matplotlib
- import matplotlib as mpl
- mpl.use('Agg')
- import matplotlib.pyplot as plt
- import datetime
- import os
- import urllib
- import urllib.request
- import urllib.parse
- import base64
- #import cv2
- from PIL import Image
- import time
- def c21():
- head = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
- }
- url = ("http://52.195.10.119/MQTT/c21a.php")
- res = requests.post(url, headers=head)
- a =json.loads(res.text)
- time1a = int(a['time1a'])
- time2a = int(a['time2a'])
- time3a = int(a['time3a'])
- time4a = int(a['time4a'])
- time5a = int(a['time5a'])
- time6a = int(a['time6a'])
- time7a = int(a['time7a'])
- time8a = int(a['time8a'])
- time9a = int(a['time9a'])
- print(time1a)
- if (time1a == 0):
- print('wow')
- elif (time1a == 1):
- print('1')
- img21_1()
- print('2')
- throw21()
- print('3')
- if (time2a == 0):
- print('wow')
- elif (time2a == 1):
- print('1')
- img21_2()
- print('2')
- throw21()
- print('3')
- if (time3a == 0):
- print('wow')
- elif (time3a == 1):
- print('1')
- img21_3()
- print('2')
- throw21()
- print('3')
- if (time4a == 0):
- print('wow')
- elif (time4a == 1):
- print('1')
- img21_4()
- print('2')
- throw21()
- print('3')
- if (time5a == 0):
- print('wow')
- elif (time5a == 1):
- print('1')
- img21_5()
- print('2')
- throw21()
- print('3')
- if (time6a == 0):
- print('wow')
- elif (time6a == 1):
- print('1')
- img21_6()
- print('2')
- throw21()
- print('3')
- if (time7a == 0):
- print('wow')
- elif (time7a == 1):
- print('1')
- img21_7()
- print('2')
- throw21()
- print('3')
- if (time8a == 0):
- print('wow')
- elif (time8a == 1):
- print('1')
- img21_8()
- print('2')
- throw21()
- print('3')
- if (time9a == 0):
- print('wow')
- elif (time9a == 1):
- print('1')
- img21_9()
- print('2')
- throw21()
- print('3')
- def img21_1():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi1/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia1/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir1/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n1/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj1/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj1/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a1.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b1.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_1.txt','a')
- f.write(date)
- f.close()
- #plt.close(na)
- def img21_2():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi2/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia2/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir2/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n2/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj2/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj2/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a2.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b2.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_2.txt','a')
- f.write(date)
- f.close()
- def img21_3():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi3/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia3/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir3/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n3/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj3/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj3/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a3.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b3.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_3.txt','a')
- f.write(date)
- f.close()
- def img21_4():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi4/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia4/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir4/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n4/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj4/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj4/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a4.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b4.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_4.txt','a')
- f.write(date)
- f.close()
- def img21_5():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi5/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia5/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir5/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n5/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj5/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj5/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a5.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b5.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_5.txt','a')
- f.write(date)
- f.close()
- def img21_6():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi6/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia6/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir6/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n6/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj6/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj6/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a6.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b6.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_6.txt','a')
- f.write(date)
- f.close()
- def img21_7():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi7/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia7/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir7/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n7/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj7/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj7/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a7.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b7.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_7.txt','a')
- f.write(date)
- f.close()
- def img21_8():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi8/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia8/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir8/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n8/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj8/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj8/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a8.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b8.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21_8.txt','a')
- f.write(date)
- f.close()
- def img21_9():
- ndvis = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvi/%Y-%m-%d_%H.%M.tif') #ndvi is time.tif
- ndvia = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/%Y-%m-%d_%H.%M.png') #ndvi is time.png
- ndviajpg = datetime.datetime.now().strftime('/var/www/html/cust/21/ndvia/c.png') #ndvi is c.png
- irt = datetime.datetime.now().strftime('/var/www/html/cust/21/ir/%Y-%m-%d_%H.%M.tif') # irtif is time.tif
- nt = datetime.datetime.now().strftime('/var/www/html/cust/21/n/%Y-%m-%d_%H.%M.tif') # ntif is time.tif
- irj = datetime.datetime.now().strftime('/var/www/html/cust/21/irj/%Y-%m-%d_%H.%M.jpg') # irjpg is time.jpg
- nj = datetime.datetime.now().strftime('/var/www/html/cust/21/nj/%Y-%m-%d_%H.%M.jpg') # njpg is time.jpg
- date = datetime.datetime.now().strftime('\n%Y-%m-%d_%H.%Mn')
-
- rgb_img0 = Image.open('/var/www/html/cust/21/c/a.tif')
- ir_img0 = Image.open('/var/www/html/cust/21/c/b.tif')
- rgb_img0.save(nt)
- ir_img0.save(irt)
- rgb_img0.save(nj,quality=95)
- ir_img0.save(irj,quality=95)
- r,_,_ = rgb_img0.split()
- r = np.asarray(r, dtype=float)
-
-
- ir,_,_ = ir_img0.split()
- ir = np.asarray(ir, dtype=float)
-
-
- ndvi = np.zeros(r.size) # The NDVI image will be the same size as the input image
-
-
- np.seterr(divide='ignore', invalid='ignore')
- ndvi = np.true_divide(np.subtract(ir, r), np.add(ir, r))
-
-
- # Display the results
- plt.plot(ndvi)
- plt.imshow(ndvi, cmap=plt.cm.get_cmap('Spectral'))
- plt.colorbar()
- #plt.show()
- plt.savefig(ndvis)
- plt.savefig(ndvia)
- plt.savefig(ndviajpg)
- plt.close('all')
- f = open('/var/www/html/cust/c21.txt','a')
- f.write(date)
- f.close()
- def throw21():
- dress = '/var/www/html/cust/21/c/'
- for root, dirs, files in os.walk(dress):
- print('files: {}'.format(len(files)))
- if len(files)>=1:
- files.sort()
- for f in files:
- with open(os.path.join(root, f), "rb") as imageFile:
- str = base64.b64encode(imageFile.read())
- url = 'http://60.250.156.234/cust/t21.php'
- values = {'data1':str, 'name':f}
- data1 = urllib.parse.urlencode(values)
- data1 = data1.encode('utf-8')
- req = urllib.request.Request(url, data1)
- req.add_header('User-Agent','Magic Browser')
- resp = urllib.request.urlopen(req)
- respdata1 = resp.read()
- print(os.path.join(root, f))
- #print(respdata1)
- os.remove(os.path.join(root, f))
- print("ok")
- url = 'http://52.195.10.119/MQTT/BBtoNDVI.php'
- data = {'nrs': 'KDARES21'}
- data = urllib.parse.urlencode(data)
- data = data.encode('utf-8')
- req = urllib.request.Request(url, data)
- req.add_header('User-Agent', 'Magic Browser')
- resp = urllib.request.urlopen(req)
- respData = resp.read()
- print("ok")
- while True:
- c21()
|