import config
import os
import base64;
from shutil import copyfile
import sys

def capture_picture():
    os.system(config.PICTURE_COMMAND)

def get_transfer_picture_base64():
    try:
        with open(config.PICTURE_TRANSFER_FILE, "rb") as image_file:
            return base64.b64encode(image_file.read())
    except:
        print("Unexpected error:", sys.exc_info()[0])
        return None

def remove_transfer_picture():
    try:
        os.remove(config.PICTURE_TRANSFER_FILE)
    except:
        print("Error removing: ", config.PICTURE_TRANSFER_FILE )

def make_transfer_picture():
    try:
        copyfile(config.PICTURE_INPUT_FILE, config.PICTURE_TRANSFER_FILE)
    except:
        print("Error copying: ", config.PICTURE_INPUT_FILE, config.PICTURE_TRANSFER_FILE )
