As most of the program only needs to be run once I thought about using a loop in Python instead and this is what I have come up with. My concern at the moment is having to use camera.capture twice, is there a better way of saving the same image to 2 places?
Also is there a better way of achieving what I am doing?
Code: Select all
#!/usr/bin/env python import picamera import time import tweepy from datetime import datetime mydir = '/var/www/' photo_path = mydir+'webcam.jpg' # Consumer keys and access tokens, used for OAuth consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' # OAuth process, using the keys and tokens auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) # Creation of the actual interface, using authentication api = tweepy.API(auth) while True: now = datetime.now() timeInfo = now.strftime('%d/%m/%y %H.%M') timestamp = now.strftime('%H:%M') if now.minute % 5 == 0 and now.second <= 10: with picamera.PiCamera() as camera: camera.resolution = (1280, 1024) camera.annotate_background = picamera.Color('black') camera.annotate_text = timeInfo time.sleep(2) # Take a picture including the annotation camera.capture(photo_path) camera.capture(mydir + 'webcam/webcam' + timestamp + '.jpg') if now.minute <= 4: status = 'Weather #Yeovil: ' + timeInfo api.update_with_media(photo_path, status=status) time.sleep(40) time.sleep(5)