Dropbox のアップローダhttps://github.com/andreafabrizi/Dropbox-Uploaderを調べたときに、何か見落としていたのかもしれません。RPi に接続された USB からファイルをアップロードする Python スクリプトを作成していますが、アップロードが完了するとブール値が false に変わるようにする必要があります。これを検出する方法はありますか?これを発生させたい場所にコードがコメントされています。
import pygame
from pygame.locals import *
from subprocess import call
uploadSym = pygame.image.load('uploadsymbol.png')
loadingSym = pygame.image.load('loading.png')
uploadSym = pygame.transform.scale(uploadSym, (250,300))
loadingSym = pygame.transform.scale(loadingSym, (300,300))
rect = uploadSym.get_rect()
rect = rect.move((200,60))
rect = loadingSym.get_rect()
rect = rect.move((200,60))
firstSlide = False
def toggle_fullscreen():
screen = pygame.display.get_surface()
tmp = screen.convert()
caption = pygame.display.get_caption()
cursor = pygame.mouse.get_cursor()
w,h = screen.get_width(),screen.get_height()
flags = screen.get_flags()
bits = screen.get_bitsize()
pygame.display.quit()
pygame.display.init()
screen = pygame.display.set_mode((w,h),flags^FULLSCREEN,bits)
screen.blit(tmp,(0,0))
pygame.display.set_caption(*caption)
pygame.key.set_mods(0)
pygame.mouse.set_cursor( *cursor )
return screen
if __name__ == '__main__':
SW,SH = 640,480
screen = pygame.display.set_mode((SW,SH),pygame.NOFRAME)
pygame.display.set_caption('Uploader')
_quit = False
while not _quit:
for e in pygame.event.get():
if (e.type is KEYDOWN and e.key == K_RETURN and (e.mod&(KMOD_LALT|KMOD_RALT)) != 0):
toggle_fullscreen()
elif e.type is QUIT:
_quit = True
elif e.type is KEYDOWN and e.key == K_ESCAPE:
_quit = True
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
screen = pygame.display.get_surface()
screen.fill([255, 255, 255])
#Click within the given area and upload begins
if 450 > mouse[0] > 250 and 360 > mouse[1] > 60 and click[0] == 1:
firstSlide = True
#T/F keeps png up for new slide
elif firstSlide == True:
loadRot = pygame.transform.rotate(loadingSym,0)
screen.blit(loadRot, rect)
#Upload test file to dropbox
Upload = "/home/pi/Uploader/Dropbox-Uploader/dropbox_uploader.sh upload loading.png /"
call ([Upload], shell=True)
#Here I need an if statement that says, when upload done firstSlide = False
#{
#
#
#}
else:
screen.blit(uploadSym, rect)
pygame.display.update()