Skip to content

Instantly share code, notes, and snippets.

@zrks
Last active December 28, 2017 06:33
Show Gist options
  • Save zrks/1d5bb58b823185131c23f816d2ec4b8e to your computer and use it in GitHub Desktop.
Save zrks/1d5bb58b823185131c23f816d2ec4b8e to your computer and use it in GitHub Desktop.

Revisions

  1. zrks revised this gist Apr 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ pipeline {
    stage('Lint presentation text') {
    steps {
    sh ". venv/bin/activate && python get-text.py > text.txt"
    sh "grammar-check --disable=WHITESPACE_RULE,CD_NN[1] text.txt"
    sh ". venv/bin/activate && grammar-check --disable=WHITESPACE_RULE,CD_NN[1] text.txt"
    }
    }

  2. zrks revised this gist Apr 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ pipeline {

    stage('Lint presentation text') {
    steps {
    sh "python get-text.py > text.txt"
    sh ". venv/bin/activate && python get-text.py > text.txt"
    sh "grammar-check --disable=WHITESPACE_RULE,CD_NN[1] text.txt"
    }
    }
  3. zrks revised this gist Apr 10, 2017. 2 changed files with 9 additions and 1 deletion.
    7 changes: 7 additions & 0 deletions Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,13 @@ pipeline {
    }
    }

    stage('Lint presentation text') {
    steps {
    sh "python get-text.py > text.txt"
    sh "grammar-check --disable=WHITESPACE_RULE,CD_NN[1] text.txt"
    }
    }

    stage('Archive artifacts') {
    steps {
    archive "$PRESENTATION_NAME"
    3 changes: 2 additions & 1 deletion get-text.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,8 @@

    from pptx import Presentation

    prs = Presentation(os.getenv('PRESENTATION_NAME', 'devops-for-powerpoint.pptx'))
    prs = Presentation(os.getenv('PRESENTATION_NAME',
    'devops-for-powerpoint.pptx'))

    # text_runs will be populated with a list of strings,
    # one for each text run in presentation
  4. zrks revised this gist Apr 10, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions requirements.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    3to2==1.1.1
    appdirs==1.4.3
    autopep8==1.3.1
    configparser==3.5.0
    enum34==1.1.6
    flake8==3.3.0
    grammar-check==1.3.1
    lxml==3.7.3
    mccabe==0.6.1
    olefile==0.44
  5. zrks revised this gist Apr 10, 2017. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions get-text.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import os

    from pptx import Presentation

    prs = Presentation(os.getenv('PRESENTATION_NAME', 'devops-for-powerpoint.pptx'))

    # text_runs will be populated with a list of strings,
    # one for each text run in presentation
    text_runs = []

    for slide in prs.slides:
    for shape in slide.shapes:
    if not shape.has_text_frame:
    continue
    for paragraph in shape.text_frame.paragraphs:
    for run in paragraph.runs:
    text_runs.append(run.text)


    for i in text_runs:
    print(i)
  6. zrks revised this gist Apr 10, 2017. 1 changed file with 50 additions and 50 deletions.
    100 changes: 50 additions & 50 deletions Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -1,51 +1,51 @@
    pipeline {

    agent {
    label "master"
    }

    environment {
    CONFIGURATION_FILENAME = "presentation.yml"
    PRESENTATION_NAME = "devops-for-powerpoint.pptx"
    }

    stages {

    stage('Checkout') {
    steps {
    git url: 'https://gist.github.com/1d5bb58b823185131c23f816d2ec4b8e.git'
    }
    }
    stage('Create virtualenv') {
    steps {
    sh 'virtualenv venv'
    }
    }
    stage('Fetch dependencies') {
    steps {
    sh '. venv/bin/activate && pip install -r requirements.txt'
    }
    }
    stage('Lint source') {
    steps {
    sh "flake8 --show-source --ignore=E999,E113 *.py *.yml"
    }
    }
    stage('Build presentation') {
    steps {
    sh ". venv/bin/activate && python generate-presentation.py"
    }
    }
    stage('Archive artifacts') {
    steps {
    archive "check.pptx"
    }
    }

    }
    pipeline {

    agent {
    label "master"
    }

    environment {
    CONFIGURATION_FILENAME = "presentation.yml"
    PRESENTATION_NAME = "devops-for-powerpoint.pptx"
    }

    stages {

    stage('Checkout') {
    steps {
    git url: 'https://gist.github.com/1d5bb58b823185131c23f816d2ec4b8e.git'
    }
    }

    stage('Create virtualenv') {
    steps {
    sh 'virtualenv venv'
    }
    }

    stage('Fetch dependencies') {
    steps {
    sh '. venv/bin/activate && pip install -r requirements.txt'
    }
    }

    stage('Lint source') {
    steps {
    sh "flake8 --show-source --ignore=E999,E113 *.py *.yml"
    }
    }

    stage('Build presentation') {
    steps {
    sh ". venv/bin/activate && python generate-presentation.py"
    }
    }

    stage('Archive artifacts') {
    steps {
    archive "$PRESENTATION_NAME"
    }
    }

    }
    }
  7. zrks revised this gist Apr 10, 2017. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,14 @@ pipeline {
    label "master"
    }

    environment {
    CONFIGURATION_FILENAME = "presentation.yml"
    PRESENTATION_NAME = "devops-for-powerpoint.pptx"
    }

    stages {

    stage('Checkout') {

    environment {
    CONFIGURATION_FILENAME = "presentation.yml"
    PRESENTATION_NAME = "devops-for-powerpoint.pptx"
    }

    steps {
    git url: 'https://gist.github.com/1d5bb58b823185131c23f816d2ec4b8e.git'
    }
  8. zrks revised this gist Apr 10, 2017. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions generate-presentation.py
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,8 @@ def read_configuration(config_file):


    def generate_presentation():
    cfg = read_configuration(os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))
    cfg = read_configuration(
    os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))

    prs = Presentation()
    title_slide = prs.slide_layouts[0]
    @@ -33,7 +34,8 @@ def layout_handler(layout_name, presentation_object):


    def generate_slides():
    cfg = read_configuration(os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))
    cfg = read_configuration(
    os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))
    prs = Presentation()

    for i in sorted(cfg):
  9. zrks revised this gist Apr 10, 2017. 2 changed files with 58 additions and 4 deletions.
    52 changes: 52 additions & 0 deletions Jenkinsfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    pipeline {

    agent {
    label "master"
    }

    stages {

    stage('Checkout') {

    environment {
    CONFIGURATION_FILENAME = "presentation.yml"
    PRESENTATION_NAME = "devops-for-powerpoint.pptx"
    }

    steps {
    git url: 'https://gist.github.com/1d5bb58b823185131c23f816d2ec4b8e.git'
    }
    }

    stage('Create virtualenv') {
    steps {
    sh 'virtualenv venv'
    }
    }

    stage('Fetch dependencies') {
    steps {
    sh '. venv/bin/activate && pip install -r requirements.txt'
    }
    }

    stage('Lint source') {
    steps {
    sh "flake8 --show-source --ignore=E999,E113 *.py *.yml"
    }
    }

    stage('Build presentation') {
    steps {
    sh ". venv/bin/activate && python generate-presentation.py"
    }
    }

    stage('Archive artifacts') {
    steps {
    archive "check.pptx"
    }
    }

    }
    }
    10 changes: 6 additions & 4 deletions generate-presentation.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    import os

    import yaml
    from pptx import Presentation
    from pptx.util import Inches
    @@ -12,7 +14,7 @@ def read_configuration(config_file):


    def generate_presentation():
    cfg = read_configuration('presentation.yml')
    cfg = read_configuration(os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))

    prs = Presentation()
    title_slide = prs.slide_layouts[0]
    @@ -21,7 +23,7 @@ def generate_presentation():
    title = slide.shapes.title
    title.text = cfg['title_page']['title']

    prs.save('devops-for-powerpoint.pptx')
    prs.save(os.getenv('PRESENTATION_NAME', 'devops-for-powerpoint.pptx'))


    def layout_handler(layout_name, presentation_object):
    @@ -31,7 +33,7 @@ def layout_handler(layout_name, presentation_object):


    def generate_slides():
    cfg = read_configuration('presentation.yml')
    cfg = read_configuration(os.getenv('CONFIGURATION_FILENAME', 'presentation.yml'))
    prs = Presentation()

    for i in sorted(cfg):
    @@ -62,7 +64,7 @@ def generate_slides():
    shape.text = 'Step yo: %d' % n
    left = left + width - Inches(0.4)

    prs.save('check.pptx')
    prs.save(os.getenv('PRESENTATION_NAME', 'devops-for-powerpoint.pptx'))


    if __name__ == '__main__':
  10. zrks revised this gist Apr 10, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions generate-presentation.py
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ def generate_slides():

    for i in sorted(cfg):
    slide = prs.slides.add_slide(
    layout_handler(cfg[i]['slide_layout'], prs))
    layout_handler(cfg[i]['slide_layout'], prs))
    title = slide.shapes.title
    title.text = cfg[i]['title']

    @@ -52,13 +52,13 @@ def generate_slides():
    height = Inches(cfg[i]['position']['height'])

    shape = shapes.add_shape(
    MSO_SHAPE.CHEVRON, left, top, width, height)
    MSO_SHAPE.CHEVRON, left, top, width, height)
    left = left + width - Inches(0.4)
    width = Inches(2.0)

    for n in range(2, 6):
    shape = shapes.add_shape(
    MSO_SHAPE.CHEVRON, left, top, width, height)
    MSO_SHAPE.CHEVRON, left, top, width, height)
    shape.text = 'Step yo: %d' % n
    left = left + width - Inches(0.4)

  11. zrks revised this gist Apr 10, 2017. 2 changed files with 21 additions and 17 deletions.
    31 changes: 14 additions & 17 deletions presentation.yml
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,19 @@
    #title_page:
    page_1:
    slide_layout: Title Slide
    title: DevOps for PowerPoint
    slide_layout: Title Slide
    title: DevOps for PowerPoint

    #second_page:
    page_2:
    slide_layout: Title and Content
    title: Current approach
    content: |
    Current problems
    Version control
    slide_layout: Title and Content
    title: Current approach
    content: |
    Current problems
    Version control
    #third_page:
    page_3:
    slide_layout: Title Only
    title: PowerPoint Pipeline
    position:
    left: 0.93
    top: 3.0
    width: 1.75
    height: 1.0
    slide_layout: Title Only
    title: PowerPoint Pipeline
    position:
    left: 0.93
    top: 3.0
    width: 1.75
    height: 1.0
    7 changes: 7 additions & 0 deletions requirements.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,15 @@
    appdirs==1.4.3
    autopep8==1.3.1
    configparser==3.5.0
    enum34==1.1.6
    flake8==3.3.0
    lxml==3.7.3
    mccabe==0.6.1
    olefile==0.44
    packaging==16.8
    Pillow==4.1.0
    pycodestyle==2.3.1
    pyflakes==1.5.0
    pyparsing==2.2.0
    python-pptx==0.6.5
    PyYAML==3.12
  12. zrks revised this gist Apr 9, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Just for the kicks
  13. zrks created this gist Apr 9, 2017.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Just for the kicks
  14. zrks created this gist Apr 9, 2017.
    70 changes: 70 additions & 0 deletions generate-presentation.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    import yaml
    from pptx import Presentation
    from pptx.util import Inches
    from pptx.enum.shapes import MSO_SHAPE


    def read_configuration(config_file):
    with open(config_file) as f:
    cfg = yaml.load(f)

    return cfg


    def generate_presentation():
    cfg = read_configuration('presentation.yml')

    prs = Presentation()
    title_slide = prs.slide_layouts[0]

    slide = prs.slides.add_slide(title_slide)
    title = slide.shapes.title
    title.text = cfg['title_page']['title']

    prs.save('devops-for-powerpoint.pptx')


    def layout_handler(layout_name, presentation_object):
    for layout in presentation_object.slide_layouts:
    if layout.name == layout_name:
    return layout


    def generate_slides():
    cfg = read_configuration('presentation.yml')
    prs = Presentation()

    for i in sorted(cfg):
    slide = prs.slides.add_slide(
    layout_handler(cfg[i]['slide_layout'], prs))
    title = slide.shapes.title
    title.text = cfg[i]['title']

    if 'content' in cfg[i]:
    content = slide.placeholders[1]
    content.text = cfg[i]['content']

    if 'position' in cfg[i]:
    shapes = slide.shapes
    left = Inches(cfg[i]['position']['left'])
    top = Inches(cfg[i]['position']['top'])
    width = Inches(cfg[i]['position']['width'])
    height = Inches(cfg[i]['position']['height'])

    shape = shapes.add_shape(
    MSO_SHAPE.CHEVRON, left, top, width, height)
    left = left + width - Inches(0.4)
    width = Inches(2.0)

    for n in range(2, 6):
    shape = shapes.add_shape(
    MSO_SHAPE.CHEVRON, left, top, width, height)
    shape.text = 'Step yo: %d' % n
    left = left + width - Inches(0.4)

    prs.save('check.pptx')


    if __name__ == '__main__':
    # generate_presentation()
    generate_slides()
    22 changes: 22 additions & 0 deletions presentation.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #title_page:
    page_1:
    slide_layout: Title Slide
    title: DevOps for PowerPoint

    #second_page:
    page_2:
    slide_layout: Title and Content
    title: Current approach
    content: |
    Current problems
    Version control
    #third_page:
    page_3:
    slide_layout: Title Only
    title: PowerPoint Pipeline
    position:
    left: 0.93
    top: 3.0
    width: 1.75
    height: 1.0
    10 changes: 10 additions & 0 deletions requirements.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    appdirs==1.4.3
    lxml==3.7.3
    olefile==0.44
    packaging==16.8
    Pillow==4.1.0
    pyparsing==2.2.0
    python-pptx==0.6.5
    PyYAML==3.12
    six==1.10.0
    XlsxWriter==0.9.6