dvsu / catalog-update-automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

catalog-update-automation

Part 1: Working with Supplier Images

  1. Grant executable permission to download_drive_file.sh

    sudo chmod +x ~/download_drive_file.sh
  2. Command to download supplier data

    ./download_drive_file.sh 1LePo57dJcgzoK4uiI_48S01Etck7w_5f supplier-data.tar.gz
  3. Extract the downloaded data

    tar xf ~/supplier-data.tar.gz
  4. Create a new Python script named changeImage.py to convert raw image data to jpeg

  5. Grant executable permission to changeImage.py

    sudo chmod +x ~/changeImage.py
  6. Confirm whether the properties of new image has been properly converted

    file ~/supplier-data/images/003.jpeg

Part 2: Uploading Images to Web Server

  1. Grant executable permission to example_upload.py

    sudo chmod +x ~/example_upload.py
  2. The command below will upload the sample image to web server

    ./example_upload.py
  3. Create a Python script named supplier_image_upload.py to upload converted images to web server

  4. Grant executable permission to supplier_image_upload.py

    sudo chmod +x ~/supplier_image_upload.py

Part 3: Upload Item Description to Web Server

  1. At this point, the Django server has been running. The Django REST framework can be accessed on URL below.

    {PUBLIC_IP}/fruits
  2. Try POST method with the following json data

    {
      "name": "Test Fruit",
      "weight": 100,
      "description": "This is the description of my test fruit",
      "image_name": "icon.sheet.png"
    }
  3. Create a Python script named run.py to read item description from directory and upload all description to web server

  4. Grant executable permission to run.py

    sudo chmod +x ~/run.py
  5. Run the script

    ./run.py
  6. Validate the process and ensure all images are shown on the web

    http://{public_ip}/
    

Part 4: Generate PDF Report and Send It through Email

  1. There are 3 scripts that have to be created, reports.py, emails.py, and report_email.py

  2. The reports.py will create a pdf report based on name and weight of items supplied by suppliers.

  3. The emails.py will create a message object and send message to receiver. The content of the email includes the pdf file generated by reports.py

  4. Finally report_email.py is the main script that will call both reports.py and emails.py to perform these tasks.

  5. Grant executable permissions to report_email.py

    sudo chmod +x ~/report_email.py
  6. Run the script

    ./report_email.py
  7. Confirm that the email is actually sent to the receiver by logging in to webmail

    {public_ip}/webmail
    

Part 5: System Health Check

  1. The final part is about creating an automatic alerting system in case abnormal behavior in the system is detected

  2. Create a Python script named health_check.py to monitor CPU usage, disk space, available memory, and localhost connection

  3. The check should be performed every 1 minute. If abnormal behavior occurs, the script will send an email to receiver.

  4. While the script is running, install stress toll to test the script

    sudo apt install stress
  5. Run the stress tool and check whether alert message is received on receiver side.

    stress --cpu 8

About

License:MIT License


Languages

Language:Python 92.6%Language:Shell 7.4%