Beispiel #1
0
def load_barbershop(dirname):
    for filename in os.listdir(dirname):
        name = base64.urlsafe_b64encode(uuid.uuid4().bytes).decode('utf-8')
        password = name
        title = re.sub('_', ' ', filename).split('.')[0]
        image = aws.upload_file(dirname, filename)
        lat, lon = get_rand_lat_lon()

        barbershop_table = BarberShopTable()
        barbershop_table.put_barbershop(name, password, title, image, lat, lon)
Beispiel #2
0
def cleanup():

    # TODO:
    # Check if any certificate has been updated, skip upload to S3 if it doesnt

    logger.info('Compressing certbot config dir')
    with tarfile.open('/tmp/' + BACKUP_FILE, mode='w:gz') as archive:
        archive.add(env['config_dir'], arcname='')

    logger.info('Uploading certbot config dir to S3')
    aws.upload_file('/tmp/' + BACKUP_FILE,
                    env['bucket_dir'] + '/' + BACKUP_FILE, env['bucket'])

    logger.info('Uploading certificates to S3')
    aws.upload_dir(env['config_dir'] + '/live',
                   env['bucket_dir'] + '/' + env['certs'], env['bucket'])

    shutil.rmtree(env['logs_dir'])

    unlock()
Beispiel #3
0
## Automatic gain control delay
time.sleep(2)

## Fixed values
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g

# Finally, take a photo with the fixed settings
img_ = BytesIO()
camera.capture(img_, 'jpeg')
img_.seek(0)
upload_file(img_, img_file)

bad, good = image_analysis(img_)
bad = float(bad*100)
good = float(good*100)
print(bad)
print(good)

data = {}
data['img_file'] = img_file
data['hour'] = str(hour_min.hour)
data['minute'] = str(hour_min.minute)
data['posture'] = {'good':good, 'bad':bad}


import os
Beispiel #4
0
"""Script for uploading all non-html files to AWS S3.

This allows you to mass update on the live site after you've updated the code.
"""
from aws import upload_file

upload_file("css/style.css", content_type="text/css")
upload_file("images/favicon.png", content_type="image/png")
upload_file("less/style.less", content_type="text/less")
Beispiel #5
0
import picamera
import logging
import sys
from datetime import datetime
from aws import upload_file

# logging settings
root = logging.getLogger()
root.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
root.addHandler(handler)

if __name__ == "__main__":
    logging.info("Starting Recording")
    camera = picamera.PiCamera()
    camera.resolution = (640, 480)
    camera.start_recording("local_footage.h264")
    camera.wait_recording(60)  # seconds
    camera.stop_recording()
    logging.info("Finished Recording")
    upload_file("local_footage.h264")