Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for compatibility with Python 3 #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added logos/wyo_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 34 additions & 22 deletions scripts/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ class Configuration():
"""Configuration class acts as configuration keys/values holder"""
# default values
user_name = None
logo_file = None
logo_file = "../logos/wyo_logo.png"
enable_logo = True
countdown1 = 5 # seconds of preview before first snap
countdown2 = 3 # seconds of preview between snaps (Four pictures mode)
photoCaption = "" # Caption in the photo album
ARCHIVE = True # Do we archive photos locally
archive_dir = os.path.join("..","Photos") # Where do we archive photos
archive_to_all_usb_drives = True
usb_mount_point_root = "/media/pi/"
albumID = None # use install_credentials.py to create 'album.id'
album_name = "Drop Box"
emailSubject = "Here's your photo!" # subject line of the email sent from the photobooth
emailMsg = "Greetings, here's your photo sent from the photobooth" # Brief body of the message sent from the photobooth
full_screen = True #Start application in full screen
enable_email = True #Enable the 'send email" feature
enable_upload = True #Enable the upload feature
enable_nine_button = True #Enable the nine photo collage feature
enable_anim_button = True #Enable the animation feature
enable_print = False #Enable the printer feature
enable_effects = True
selected_printer = None #No printer select
Expand Down Expand Up @@ -47,35 +51,39 @@ def __read_config_file(self):
file_content = content_file.read()
config = json.loads(file_content)
except Exception as error:
print "Error while parsing %s config file : %s"%(self.config_file,error)
print("Error while parsing %s config file : %s"%(self.config_file,error))
self.is_valid = False
return False
if "gmail_user" in config.keys(): self.user_name = config['gmail_user']
if "gmail_user" in list(config.keys()): self.user_name = config['gmail_user']
else:
#mandatory configuration!!
self.is_valid = False


# all other configuration keys are optional
if "countdown_before_snap" in config.keys(): self.countdown1 = config["countdown_before_snap"]
if "countdown_inter_snap" in config.keys(): self.countdown2 = config["countdown_inter_snap"]
if "snap_caption" in config.keys(): self.photoCaption = config["snap_caption"]
if "local_archive" in config.keys(): self.ARCHIVE = config["local_archive"]
if "archive_to_all_usb_drives" in config.keys(): self.archive_to_all_usb_drives = config["archive_to_all_usb_drives"]
if "local_archive_dir" in config.keys(): self.archive_dir = config["local_archive_dir"]
if "google_photo_album_id" in config.keys(): self.albumID = config["google_photo_album_id"]
if "google_photo_album_name" in config.keys(): self.album_name = config["google_photo_album_name"]
if "email_subject" in config.keys(): self.emailSubject = config["email_subject"]
if "email_body" in config.keys(): self.emailMsg = config["email_body"]
if "logo_file" in config.keys(): self.logo_file = config["logo_file"]
if "full_screen" in config.keys(): self.full_screen = config["full_screen"]
if "enable_email" in config.keys(): self.enable_email = config["enable_email"]
if "enable_upload" in config.keys(): self.enable_upload = config["enable_upload"]
if "enable_print" in config.keys(): self.enable_print = config["enable_print"]
if "enable_effects" in config.keys(): self.enable_effects = config["enable_effects"]
if "selected_printer" in config.keys(): self.selected_printer = config["selected_printer"]
if "enable_hardware_buttons" in config.keys(): self.enable_hardware_buttons = config["enable_hardware_buttons"]
if "enable_email_logging" in config.keys(): self.enable_email_logging = config["enable_email_logging"]
if "countdown_before_snap" in list(config.keys()): self.countdown1 = config["countdown_before_snap"]
if "countdown_inter_snap" in list(config.keys()): self.countdown2 = config["countdown_inter_snap"]
if "snap_caption" in list(config.keys()): self.photoCaption = config["snap_caption"]
if "local_archive" in list(config.keys()): self.ARCHIVE = config["local_archive"]
if "archive_to_all_usb_drives" in list(config.keys()): self.archive_to_all_usb_drives = config["archive_to_all_usb_drives"]
if "usb_mount_point_root" in list(config.keys()): self.usb_mount_point_root = config["usb_mount_point_root"]
if "local_archive_dir" in list(config.keys()): self.archive_dir = config["local_archive_dir"]
if "google_photo_album_id" in list(config.keys()): self.albumID = config["google_photo_album_id"]
if "google_photo_album_name" in list(config.keys()): self.album_name = config["google_photo_album_name"]
if "email_subject" in list(config.keys()): self.emailSubject = config["email_subject"]
if "email_body" in list(config.keys()): self.emailMsg = config["email_body"]
if "logo_file" in list(config.keys()): self.logo_file = config["logo_file"]
if "enable_logo" in list(config.keys()): self.enable_logo = config["enable_logo"]
if "full_screen" in list(config.keys()): self.full_screen = config["full_screen"]
if "enable_email" in list(config.keys()): self.enable_email = config["enable_email"]
if "enable_upload" in list(config.keys()): self.enable_upload = config["enable_upload"]
if "enable_nine_button" in list(config.keys()): self.enable_nine_button = config["enable_nine_button"]
if "enable_anim_button" in list(config.keys()): self.enable_anim_button = config["enable_anim_button"]
if "enable_print" in list(config.keys()): self.enable_print = config["enable_print"]
if "enable_effects" in list(config.keys()): self.enable_effects = config["enable_effects"]
if "selected_printer" in list(config.keys()): self.selected_printer = config["selected_printer"]
if "enable_hardware_buttons" in list(config.keys()): self.enable_hardware_buttons = config["enable_hardware_buttons"]
if "enable_email_logging" in list(config.keys()): self.enable_email_logging = config["enable_email_logging"]


return self.is_valid
Expand All @@ -90,15 +98,19 @@ def write(self):
"snap_caption": self.photoCaption,
"local_archive" : self.ARCHIVE,
"archive_to_all_usb_drives" : self.archive_to_all_usb_drives,
"usb_mount_point_root" : self.usb_mount_point_root,
"local_archive_dir" : self.archive_dir,
"google_photo_album_id" : self.albumID,
"google_photo_album_name" : self.album_name,
"email_subject": self.emailSubject,
"email_body":self.emailMsg,
"logo_file": self.logo_file,
"enable_logo": self.enable_logo,
"full_screen": self.full_screen,
"enable_email": self.enable_email,
"enable_upload": self.enable_upload,
"enable_nine_button": self.enable_nine_button,
"enable_anim_button": self.enable_anim_button,
"enable_print": self.enable_print,
"enable_effects": self.enable_effects,
"selected_printer": self.selected_printer,
Expand Down
8 changes: 6 additions & 2 deletions scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
},
"Four": {
'snap_size' : (820,616), #(width, height) of each shots of the 2x2 collage
'foreground_image' : "../logos/collage_four_square_logo.png" # Overlay image on top of the collage
'foreground_image' : "../logos/collage_four_square.png" # Overlay image on top of the collage
},
"Nine": {
'snap_size' : (546,410), #(width, height) of each shots of the 2x2 collage
'foreground_image' : "../logos/collage_nine_square_logo.png" # Overlay image on top of the collage
'foreground_image' : "../logos/collage_nine_square.png" # Overlay image on top of the collage
},
"Animation": {
'snap_size' : (500, 500), #(width, height) => Caution, gif animation can be huge, keep this small
Expand All @@ -60,18 +60,22 @@
SOFTWARE_BUTTONS = {
"Four": {
"icon" : os.path.join("ressources","ic_four.png"),
"enabled": True,
"order":1
},
"Nine": {
"icon" : os.path.join("ressources","ic_nine.png"),
"enabled": True,
"order":2
},
"None": {
"icon" : os.path.join("ressources","ic_portrait.png"),
"enabled": True,
"order":0
},
"Animation": {
"icon" : os.path.join("ressources","ic_anim.png"),
"enabled": True,
"order":3
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/cv2_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ def test():
cv2.destroyAllWindows()

if __name__ == '__main__':
print 'type "q" to quit'
print('type "q" to quit')
test()
8 changes: 4 additions & 4 deletions scripts/hardware_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ def state(self):
buttons = Buttons()
last = 0
if buttons.has_buttons():
print "Press hardware buttons to see change, ctrl+C to exit"
print("Press hardware buttons to see change, ctrl+C to exit")
else:
print "No button configured (no access to GPIO or empty button list)"
print "Number of buttons is %d" % buttons.buttons_number()
print("No button configured (no access to GPIO or empty button list)")
print("Number of buttons is %d" % buttons.buttons_number())
sys.exit()

while True:
state = buttons.state()
if last != state:
print "new state: %d"%state
print("new state: %d"%state)
last = state
time.sleep(0.1)
17 changes: 9 additions & 8 deletions scripts/mykb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@

"""

import re
import logging
log=logging.getLogger(__name__)

from Tkinter import *
from tkinter import *

class Key:
"""Implements common behavior for a Keyboard Key"""
Expand Down Expand Up @@ -131,7 +132,7 @@ def set_mode(self,mode):
"""
self.mode = mode
self.current_value = ""
for state in self.key_states.keys():
for state in list(self.key_states.keys()):
if state == mode:
self.canvas.itemconfigure(state,state="normal")
self.current_value = self.key_states[state]
Expand Down Expand Up @@ -539,7 +540,7 @@ def apply_stylesheet(self,stylesheet):
self.bound_entry.configure(font=styledef["font"])
continue
#print "Applying stylesheet for %s"%tag
for style in styledef.keys():
for style in list(styledef.keys()):
try:
if style == 'tag' : continue
#apply all styles to tag
Expand All @@ -562,7 +563,7 @@ def apply_stylesheet(self,stylesheet):
except:
pass
self.canvas.update()
except Exception, e:
except Exception as e:
log.exception("Error while applying stylesheet")

__email_validator = re.compile(r'^[^@]+@[^@]+\.[^@]+$')
Expand All @@ -573,11 +574,11 @@ def email_validator(addr):
r = Tk()
myres = StringVar()
def onEnter():
print 'Enter Pressed'
print "result %s"%myres.get()
print('Enter Pressed')
print("result %s"%myres.get())
def onCancel():
print 'Cancel Pressed'
print "result %s"%myres.get()
print('Cancel Pressed')
print("result %s"%myres.get())

keyboard = TouchKeyboard(r,myres, onEnter = onEnter, onCancel=onCancel,
validator=email_validator)
Expand Down
20 changes: 10 additions & 10 deletions scripts/oauth2services.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get_user_albums(self, as_title_id = True, exclude_non_app_created_data = Tru
for album in albums:
entry = {}
#skip albums with no title
if not ("title" in album.keys()):
if not ("title" in list(album.keys())):
continue
entry['title'] = album.get("title")
entry['id'] = album.get("id")
Expand Down Expand Up @@ -365,7 +365,7 @@ def test():
""" test email and uploading """
logging.basicConfig()

username = raw_input("Please enter your email address: ")
username = input("Please enter your email address: ")

# creating test image
from PIL import Image
Expand All @@ -380,20 +380,20 @@ def test():
gservice = OAuthServices("client_id.json","storage.json",username,log_level=logging.DEBUG)


print "\nTesting email sending..."
print gservice.send_message(username,"oauth2 message sending works!","Here's the Message body",attachment_file="test_image.png")
print "\nTesting album list retrieval..."
print("\nTesting email sending...")
print(gservice.send_message(username,"oauth2 message sending works!","Here's the Message body",attachment_file="test_image.png"))
print("\nTesting album list retrieval...")
albums = gservice.get_user_albums()
for i, album in enumerate(albums):
print "\t title: %s, id: %s"%(album['title'],album['id'])
print("\t title: %s, id: %s"%(album['title'],album['id']))
if i >= 10:
print "skipping the remaining albums..."
print("skipping the remaining albums...")
break
print "\nTesting album creation and image upload"
print("\nTesting album creation and image upload")
album_id = gservice.create_album(album_name="Test", add_placeholder_picture = True)
print "New album id:",album_id
print("New album id:",album_id)
print("Uploading to a bogus album")
print(gservice.upload_picture("testfile.png",album_id = "BOGUS STRING" , caption="In bogus album", generate_placeholder_picture = True))
print((gservice.upload_picture("testfile.png",album_id = "BOGUS STRING" , caption="In bogus album", generate_placeholder_picture = True)))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion scripts/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def snap(delay=0):
fn = "%4d-%02d-%02d_%02d%02d%02d.jpg" % (Y, M, D, h, m, s)
fn = os.path.join(pictures, fn)
ImageGrab.grab().save(fn, "JPEG")
print 'saved', fn
print('saved', fn)

if __name__ == '__main__':
snap(delay=5)
Loading