Giter Club home page Giter Club logo

taskick-example's Introduction

Taskick Example Application

Here we will create an application that, when a PNG image is saved to a specific folder, converts the image to PDF and saves it to the output folder.

The application works with the following algorithm.

  1. Detects when a PNG file is saved in the input folder.
  2. The saved file path is propagated to the conversion script, which converts the file to PDF.
  3. The converted PDF is saved in the output folder.
  4. The input folder is deleted periodically to keep it clean.

See Taskick for usage.

Structures

This repository consists of the following folders.

├── LICENSE
├── README.md         # This file.
├── batch.yaml
├── config
│   ├── logging.conf  # Can be specified by using the -l option.
│   ├── logging.yaml  # Can be specified by using the -l option.
│   ├── main.yaml     # Configuration file to main processing.
│   └── welcome.yaml  # Configuration file to display Welcome message at startup.
├── input             # When a PNG image is saved here, png2pdf.py is executed.
├── output            # Converted PDF is saved in this folder.
├── requirements.txt
└── src
    └── png2pdf.py    # Script to convert PNG to PDF.

Tusk and each file share functions and responsibilities as follows.

  1. Detects when a PNG file is saved in the input folder. <- Taskick(Set main.yaml)
  2. The saved file path is propagated to the conversion script, which converts the file to PDF. <- Taskick(Execute png2pdf.py)
  3. The converted PDF is saved in the output folder. <- png2pdf.py
  4. The input folder is deleted periodically to keep it clean. <- Taskick(rm -f input/.)

The detailed settings are configured in the following YAML(welcome.yaml and main.yaml) file.

welcome.yaml

Welcome_taskick: # Task name
  status: 1 # Task status
  commands:
    - "echo $(date) Welcome to Taskick!"
    - "&&"
    - "echo waiting 5 seconds..."
    - "&&"
    - "sleep 5"
  execution:
    event_type: null # If event_type is NULL, it is executed only at startup.

main.yaml

remove_files_in_input_folder:
  status: 1
  commands:
    - "rm -f input/*"
  execution:
    startup: true # If true, it is executed at startup.
    await_task:
      - "Welcome_taskick" # Set this task to run after the "Welcome_taskick" has finished running.
    event_type: "time"
    detail:
      when: "*/1 * * * *" # Crontab format: Run every 1 minute.

png2pdf:
  status: 1
  commands:
    - "python"
    - "./src/png2pdf.py"
  execution:
    startup: false
    event_type: "file"
    propagate: true # If true, events that occur at runtime (such as the path of an edited file) are passed to the running script.
    detail:
      path: "./input"
      recursive: false
      handler: # Support all watchdog.events.*EventHandler.
        name: "PatternMatchingEventHandler"
        args: # This args is passed to the handler.
          patterns:
            - "*.png"
      when: # Support created, deleted, modified, closed, moved event.
        - "created"

Appendix

The execution interval and the criteria for starting can be changed by simply editing the main.yaml file.

For example,

  • If you want a 5 minute interval to clean the input folder .
when: "*/1 * * * *"

when: "*/5 * * * *"
  • If you want to convert not only PNG but also JPEG files.
patterns:
  - "*.png"

patterns:
  - "*.png"
  - "*.jpeg"

taskick-example's People

Contributors

atsuyaide avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.