| Total Complexity | 6 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python |
||
| 2 | |||
| 3 | import log |
||
| 4 | import background |
||
|
|
|||
| 5 | |||
| 6 | from memegen.settings import ProductionConfig |
||
| 7 | from memegen.factory import create_app |
||
| 8 | from memegen.domain import Text |
||
| 9 | |||
| 10 | |||
| 11 | def main(): |
||
| 12 | log.info("Generating sample images...") |
||
| 13 | |||
| 14 | app = create_app(ProductionConfig) |
||
| 15 | |||
| 16 | with app.app_context(): |
||
| 17 | |||
| 18 | for template in app.template_service.all(): |
||
| 19 | for text in [Text("_"), template.sample_text]: |
||
| 20 | for watermark in ["", "memegen.link"]: |
||
| 21 | create_image(app, template, text, watermark) |
||
| 22 | |||
| 23 | |||
| 24 | def create_image(app, template, text, watermark): |
||
| 25 | |||
| 26 | @background.task |
||
| 27 | def run(): |
||
| 28 | app.image_service.create(template, text, watermark=watermark) |
||
| 29 | |||
| 30 | run() |
||
| 31 | |||
| 32 | |||
| 33 | if __name__ == '__main__': |
||
| 34 | main() |
||
| 35 |