Ejemplo n.º 1
0
 def __init__(self):
     self.config = configuration.get_args()
     
     try:
         # test connection, throw error if not valid
         con = self.get_connection()
         con.close()
         log.debug("Connected to db OK")
     except:
         log.fatal("Database connection is invalid, application exiting...")
         #sys.exit()
     
     # connectin is good, setup tables if they don't exist        
     self.check_or_create_additional_tables()
 def test_configuration_can_initialise_with_no_config_file(self):
     # by default tests will run in their own directory with no config file available
     conf = configuration.get_args()
 def test_configuration_has_sane_defaults(self):
     conf = configuration.get_args()
     self.assertIsNotNone(conf.tv_dir)
Ejemplo n.º 4
0
def calc_font_details(top, bot, img_size):
    font_size = 50
    font = ImageFont.truetype(FONT_PATH, font_size)
    max_width = img_size[0] - 20
    # Get ideal font size
    while font.getsize(top)[0] > max_width or font.getsize(bot)[0] > max_width:
        font_size = font_size - 1
        font = ImageFont.truetype(FONT_PATH, font_size)
    # Get font locations
    top_loc = ((img_size[0] - font.getsize(top)[0]) / 2, -5)
    bot_size = font.getsize(bot)
    bot_loc = ((img_size[0] - bot_size[0]) / 2, img_size[1] - bot_size[1] - 5)
    return font, top_loc, bot_loc


# Draws the given text with a border
def draw_text(draw, x, y, text, font):
    # Draw border
    draw.text((x - 1, y - 1), text, font=font, fill="black")
    draw.text((x + 1, y - 1), text, font=font, fill="black")
    draw.text((x - 1, y + 1), text, font=font, fill="black")
    draw.text((x + 1, y + 1), text, font=font, fill="black")
    # Draw text
    draw.text((x, y), text, font=font, fill="white")


if __name__ == '__main__':
    # Run dev server (for debugging only)
    args = get_args()
    app.run(host=args.host, port=args.port, debug=True)
Ejemplo n.º 5
0
 def __init__(self, dal=DAL.DAL()):
     self.config = configuration.get_args()
     self.dal = dal