import kivy
import sys
import os
import time
import requests
kivy.require('1.9.1')
import xml.etree.ElementTree as ET
from datetime import datetime
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.clock import Clock
# from kivy.loader import Loader
# image = Loader.image('nophoto.png')
# Loader.error_image = 'nophoto.png'
# SET ADDRESS FOR SOAP
from suds.client import Client
url = 'http://qag.petpoint.com/webservices/AdoptableSearch.asmx?WSDL'
client = Client(url)
# DELETES PRELOADED IMAGES TO START WITH AN EMPTY USB FOLDER
for ea_file in os.listdir('/media/pi/PRELOAD'):
thedress = '/media/pi/PRELOAD' + '/' + ea_file
os.remove(thedress)
# PUSHES DYNAMIC INFO TO SCROLLER.KV
class TheBox(FloatLayout):
def update(self, *args):
global date_now, which_petL, which_petR, total_count, Lname, Lsex, Lbreed, Lage, Lphoto, Rname, Rsex, Rbreed, Rage, Rphoto
quantity = len(ans_lists[0]) - 1
ans_particular = feeder()
Lname = ans_particular[0]
Lsex = ans_particular[1]
Lbreed = ans_particular[2]
Lage = ans_particular[3]
Lphoto = ans_particular[4]
Rname = ans_particular[5]
Rsex = ans_particular[6]
Rbreed = ans_particular[7]
Rage = ans_particular[8]
Rphoto = ans_particular[9]
self.ids.Start_Time.text = '%02d %02d %05d' % (date_now.day, date_now.hour, total_count)
if (total_count % 2) == 0:
if which_petL < quantity:
which_petL += 1
else:
which_petL = 0
self.ids.PetL_name.text = str.upper(Lname)
self.ids.PetL_sex.text = str(Lsex)
self.ids.PetL_breed.text = str(Lbreed)
self.ids.PetL_age.text = str(Lage)
self.ids.PetL_photo.source = str(Lphoto)
else:
if which_petR < quantity:
which_petR += 1
else:
which_petR = 0
self.ids.PetR_name.text = str.upper(Rname)
self.ids.PetR_sex.text = str(Rsex)
self.ids.PetR_breed.text = str(Rbreed)
self.ids.PetR_age.text = str(Rage)
self.ids.PetR_photo.source = str(Rphoto)
# SOAP RESPONSE IS CONVERTED TO XML FORMAT
def reformat_soap():
result = client.service.adoptableSearch('0', 'A', 'All', 'not4u')
..
root = ET.fromstring(closeit)
return root
# ITERATES THE SOAP RESPONSE TO ASSIGN DATA TO LISTS
def pull_data(ans_root):
lpetid = []
lname = []
lsex = []
lbreed = []
lage = []
lphoto = []
for child in ans_root.iter('pet_id'):
..
iphoto = child.find('pet_photo').text
# WEB ADDRESSES FOR IMAGES ARE USED TO CREATE LOCAL ADDRESSES
local_name = iphoto.replace('http://sms.petpoint.com/sms/photos/615/','/media/pi/PRELOAD/')
ghost_pet = local_name.replace('http://sms.petpoint.com/sms3/emails/images/','/media/pi/PRELOAD/')
lphoto.extend([ghost_pet])
# IMAGES ARE DOWNLOADED FROM THE WEB AND SAVED LOCALLY
photo_cache = open(ghost_pet, 'wb')
photo_cache.write(requests.get(iphoto).content)
# time.sleep(2)
photo_cache.close()
return(lname, lsex, lbreed, lage, lphoto)
# ASSEMBLES PET DATA PRIOR TO PUSH
def feeder():
global which_petL, which_petR, cname, csex, cbreed, cage, cphoto
pname = cname[which_petL]
psex = csex[which_petL]
pbreed = cbreed[which_petL]
page = cage[which_petL]
pphoto = cphoto[which_petL]
qname = cname[which_petR]
qsex = csex[which_petR]
qbreed = cbreed[which_petR]
qage = cage[which_petR]
qphoto = cphoto[which_petR]
return(pname, psex, pbreed, page, pphoto, qname, qsex, qbreed, qage, qphoto)
ans_root = reformat_soap()
ans_lists = pull_data(ans_root)
which_petR = int(len(ans_lists[0]) / 2)
cname = ans_lists[0]
csex = ans_lists[1]
cbreed = ans_lists[2]
cage = ans_lists[3]
cphoto = ans_lists[4]
# DEFINES THE KIVY APP, INTERVAL BETWEEN PET DISPLAYS, AND TIES TO SCROLLER.KV
class ScrollerApp(App):
def build(self):
self.load_kv('Scroller.kv')
x = TheBox()
x.update()
Clock.schedule_interval(x.update, 10)
return(x)
# KIVY WINDOW CREATION
if __name__ == '__main__':
ScrollerApp().run()
import kivy
import sys
import os
import time
import requests
kivy.require('1.9.1')
import xml.etree.ElementTree as ET
from datetime import datetime
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.clock import Clock
# from kivy.loader import Loader
# image = Loader.image('nophoto.png')
# Loader.error_image = 'nophoto.png'
# SET ADDRESS FOR SOAP
from suds.client import Client
url = 'http://qag.petpoint.com/webservices/AdoptableSearch.asmx?WSDL'
client = Client(url)
# DELETES PRELOADED IMAGES TO START WITH AN EMPTY USB FOLDER
for ea_file in os.listdir('/media/pi/PRELOAD'):
thedress = '/media/pi/PRELOAD' + '/' + ea_file
os.remove(thedress)
# PUSHES DYNAMIC INFO TO SCROLLER.KV
class TheBox(FloatLayout):
def update(self, *args):
global date_now, which_petL, which_petR, total_count, Lname, Lsex, Lbreed, Lage, Lphoto, Rname, Rsex, Rbreed, Rage, Rphoto
quantity = len(ans_lists[0]) - 1
ans_particular = feeder()
Lname = ans_particular[0]
Lsex = ans_particular[1]
Lbreed = ans_particular[2]
Lage = ans_particular[3]
Lphoto = ans_particular[4]
Rname = ans_particular[5]
Rsex = ans_particular[6]
Rbreed = ans_particular[7]
Rage = ans_particular[8]
Rphoto = ans_particular[9]
self.ids.Start_Time.text = '%02d %02d %05d' % (date_now.day, date_now.hour, total_count)
if (total_count % 2) == 0:
if which_petL < quantity:
which_petL += 1
else:
which_petL = 0
self.ids.PetL_name.text = str.upper(Lname)
self.ids.PetL_sex.text = str(Lsex)
self.ids.PetL_breed.text = str(Lbreed)
self.ids.PetL_age.text = str(Lage)
self.ids.PetL_photo.source = str(Lphoto)
else:
if which_petR < quantity:
which_petR += 1
else:
which_petR = 0
self.ids.PetR_name.text = str.upper(Rname)
self.ids.PetR_sex.text = str(Rsex)
self.ids.PetR_breed.text = str(Rbreed)
self.ids.PetR_age.text = str(Rage)
self.ids.PetR_photo.source = str(Rphoto)
# SOAP RESPONSE IS CONVERTED TO XML FORMAT
def reformat_soap():
result = client.service.adoptableSearch('0', 'A', 'All', 'not4u')
..
root = ET.fromstring(closeit)
return root
# ITERATES THE SOAP RESPONSE TO ASSIGN DATA TO LISTS
def pull_data(ans_root):
lpetid = []
lname = []
lsex = []
lbreed = []
lage = []
lphoto = []
for child in ans_root.iter('pet_id'):
..
iphoto = child.find('pet_photo').text
# WEB ADDRESSES FOR IMAGES ARE USED TO CREATE LOCAL ADDRESSES
local_name = iphoto.replace('http://sms.petpoint.com/sms/photos/615/','/media/pi/PRELOAD/')
ghost_pet = local_name.replace('http://sms.petpoint.com/sms3/emails/images/','/media/pi/PRELOAD/')
lphoto.extend([ghost_pet])
# IMAGES ARE DOWNLOADED FROM THE WEB AND SAVED LOCALLY
photo_cache = open(ghost_pet, 'wb')
photo_cache.write(requests.get(iphoto).content)
# time.sleep(2)
photo_cache.close()
return(lname, lsex, lbreed, lage, lphoto)
# ASSEMBLES PET DATA PRIOR TO PUSH
def feeder():
global which_petL, which_petR, cname, csex, cbreed, cage, cphoto
pname = cname[which_petL]
psex = csex[which_petL]
pbreed = cbreed[which_petL]
page = cage[which_petL]
pphoto = cphoto[which_petL]
qname = cname[which_petR]
qsex = csex[which_petR]
qbreed = cbreed[which_petR]
qage = cage[which_petR]
qphoto = cphoto[which_petR]
return(pname, psex, pbreed, page, pphoto, qname, qsex, qbreed, qage, qphoto)
ans_root = reformat_soap()
ans_lists = pull_data(ans_root)
which_petR = int(len(ans_lists[0]) / 2)
cname = ans_lists[0]
csex = ans_lists[1]
cbreed = ans_lists[2]
cage = ans_lists[3]
cphoto = ans_lists[4]
# DEFINES THE KIVY APP, INTERVAL BETWEEN PET DISPLAYS, AND TIES TO SCROLLER.KV
class ScrollerApp(App):
def build(self):
self.load_kv('Scroller.kv')
x = TheBox()
x.update()
Clock.schedule_interval(x.update, 10)
return(x)
# KIVY WINDOW CREATION
if __name__ == '__main__':
ScrollerApp().run()
答案 0 :(得分:0)
在这种相关性上对此并不积极,但似乎有道理。我将Raspberry Pi的GPU内存从64位增加到128MB,现在该应用程序能够以更小的图像间隔间隔成功显示图像。