Skip to content
Permalink
Browse files

Merge pull request #2 from kylekirkby/develop

Latest changes to the Connect Automation container
  • Loading branch information
kylekirkby committed Jan 7, 2020
2 parents a7a0c5e + f97b07a commit c890674219329797b233972a0b3964f149fc48a9
@@ -1,2 +1,4 @@
venv/
secrets.py
assets/images/*
!assets/images/placeholder.jpg
@@ -15,15 +15,13 @@ ENV LC_ALL en_US.UTF-8

COPY requirements.txt /tmp/

COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh

RUN pip3 install -r /tmp/requirements.txt
RUN pip3 install git+https://github.com/linaro-marketing/JekyllPostTool.git
RUN pip3 install git+https://github.com/linaro-marketing/linaro_connect_resources_updater.git
RUN pip3 install git+https://github.com/linaro-marketing/SchedDataInterface.git@master
RUN pip3 install git+https://github.com/linaro-marketing/SocialMediaImageGenerator.git
RUN pip3 install git+https://github.com/linaro-marketing/SchedPresentationTool.git
RUN pip3 install \
git+https://github.com/linaro-marketing/JekyllPostTool.git@master \
git+https://github.com/linaro-marketing/linaro_connect_resources_updater.git@master \
git+https://github.com/linaro-marketing/SchedDataInterface.git@master \
git+https://github.com/linaro-marketing/SocialMediaImageGenerator.git \
git+https://github.com/linaro-marketing/SchedPresentationTool.git

WORKDIR /app
COPY . /app
@@ -32,4 +30,4 @@ RUN chmod +x /app/*

ENV ENV="/app:${PATH}"

ENTRYPOINT [ "entrypoint.sh" ]
ENTRYPOINT [ "/app/main.py" ]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

76 main.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python3

import argparse
import datetime
from slugify import slugify

from social_image_generator import SocialImageGenerator
from sched_data_interface import SchedDataInterface
from connect_json_updater import ConnectJSONUpdater
@@ -10,39 +13,46 @@


def create_jekyll_posts(post_tool, json_data, connect_code):
for session in json_data:

for session in json_data.values():
session_image = {
"path": "/assets/images/featured-images/{}/{}.png".format(connect_code.lower(), session["session_id"]),
"featured": "true"
}
post_frontmatter = {
"title": session_id + " - " + session_name,
"session_id": session_id,
"session_speakers": revised_speakers,
"description": "{}".format(session_abstract).replace("'", ""),
"title": session["session_id"] + " - " + session["name"],
"session_id": session["session_id"],
"session_speakers": session["speakers"],
# "description": "{}".format(session["abstract"]).replace("'", ""),
"image": session_image,
"session_room": session_room,
"session_slot": session_slot,
"tags": session_tracks,
"tags": session["event_type"],
"categories": [connect_code],
"session_track": session_track,
"session_track": session["event_type"],
"tag": "session",
}
post_file_name = datetime.datetime.now().strftime(
"%Y-%m-%d") + "-" + session_id.lower() + ".md"
"%Y-%m-%d") + "-" + session["session_id"].lower() + ".md"
# Edit posts if file already exists
created = post_tool.write_post(post_frontmatter, "", post_file_name)
post_tool.write_post(post_frontmatter, "", post_file_name)


def generate_images(social_image_generator, json_data):
for session in json_data:
speakers_list = session["session_speakers"]

for session in json_data.values():
for speaker in session["speakers"]:
speaker_avatar_url = speaker["avatar"]
if len(speaker_avatar_url) < 3:
speaker["image"] = "placeholder.jpg"
else:
file_name = social_image_generator.grab_photo(
speaker_avatar_url, slugify(speaker["name"]))
speaker["image"] = file_name
# speakers_list = session["speakers"]
# Create the image options dictionary
image_options = {
"file_name": session["session_id"],
"elements" : {
"elements": {
"images": [
{
"background_image": "True",
"image_name": "background_image_test.jpg",
"circle": "False"
},
{
"dimensions": {
"x": 300,
@@ -52,7 +62,7 @@ def generate_images(social_image_generator, json_data):
"x": 820,
"y": 80
},
"image_name": session["session_speakers"][0]["speaker_image"],
"image_name": session["speakers"][0]["image"],
"circle": "True"
}
],
@@ -63,7 +73,7 @@ def generate_images(social_image_generator, json_data):
"wrap_width": 28,
"value": "test",
"position": {
"x": [920,970],
"x": [920, 970],
"y": 400
},
"font": {
@@ -99,7 +109,7 @@ def generate_images(social_image_generator, json_data):
"multiline": "False",
"centered": "False",
"wrap_width": 28,
"value": session["tags"][0],
"value": session["event_type"],
"position": {
"x": 80,
"y": 400
@@ -118,7 +128,7 @@ def generate_images(social_image_generator, json_data):
"multiline": "True",
"centered": "False",
"wrap_width": 28,
"value": session["title"],
"value": session["name"],
"position": {
"x": 80,
"y": 440
@@ -140,12 +150,11 @@ def generate_images(social_image_generator, json_data):
social_image_generator.create_image(image_options)




class AutomationContainer:
def __init__(self, args):
# Instatiate the ScehdDataInterfa ce which is used by other modules for the data source
self.sched_data = SchedDataInterface("https://linaroconnectsandiego.sched.com", SCHED_API_KEY, "SAN19")
self.sched_data = SchedDataInterface(
"https://linaroconnectsandiego.sched.com", SCHED_API_KEY, "SAN19")
self.args = args
self.main(args)

@@ -160,31 +169,32 @@ def main(self, args):
print(json_data)
# Determine the results of the args
# Build Jekyll Markdown posts for Connect sessions
print(args)
if args.jekyll_posts:
post_tool = JekyllPostTool(
"https://linaroconnectsandiego.sched.com", SCHED_API_KEY, "san19/")
create_jekyll_posts(post_tool, json_data, "SAN19")
elif args.social_images:
if args.social_images:
print("Generating social media share images")
social_image_generator = SocialImageGenerator(
{"output": "output", "template": "san19-placeholder.jpg"})
{"output": "output", "template": "assets/templates/san19-placeholder.jpg"})
generate_images(social_image_generator, json_data)
elif args.update_json:
if args.update_json:
json_updater = ConnectJSONUpdater(
"static-linaro-org", "connect/san19/presentations/", "connect/san19/videos/", "connect/san19/resources.json")
json_updater.update()
elif args.upload_presentations:
if args.upload_presentations:
upload_presentations = SchedPresentationTool(
"https://linaroconnectsandiego.sched.com", "san19")


if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Connect Automation")
parser.add_argument('-s', '--sched-url', help='Specify the Sched.com URL')
parser.add_argument('-u', '--uid', help='Specific the Unique ID for the Linaro Connect event i.e. SAN19')
parser.add_argument(
'-u', '--uid', help='Specific the Unique ID for the Linaro Connect event i.e. SAN19')
parser.add_argument('--social-images', action='store_true',
help='If specified then the Social Media Share images are generated.')
parser.add_argument('--update-resources-json', action='store_true',
help='If specified then the resources.json file is updated.')
parser.add_argument('--upload-presentations', action='store_true',
help='If specified then presentations are uploaded.')
parser.add_argument('--jekyll-posts', action='store_true',
2 run.sh
@@ -4,4 +4,4 @@ AWS_SECRET_ACCESS_KEY=$(aws --profile default configure get aws_secret_access_ke
docker run -it --rm \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
connect_automation:latest
connect_automation:latest "$@"

0 comments on commit c890674

Please sign in to comment.
You can’t perform that action at this time.