[PYTHON] I wrote a script to revive the gulp watch that will die soon

Gulp watch is very frustrating because it dies quickly and some plugins can't catch exceptions. So I wrote a Python script that will revive like a zombie as soon as it dies

zombie.py


#!/usr/bin/env python
# -*- codint: utf-8 -*-

import sys
import signal
import subprocess

def rite(silent):
    print("start rite of gulp watch be zombie")
    print("if you want stop this program, Ctrl+C")
    cmd = "gulp watch"
    while True:
        p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        for line in iter(p.stdout.readline, b''):
            print(line.rstrip())
        if not silent:
            print("\a")
        print("\ngulp watch is dead. but revive soon.\n")

def signalHandler(signal, frame):
    print("\ngulp zombie killed")
    sys.exit(0)

if __name__ == '__main__':
    signal.signal(signal.SIGINT, signalHandler)
    try:
        sys.argv.index("-s")
        rite(True)
    except ValueError:
        rite(False)

Put this in the same place as gulpfile.js

python zombie.py

If so, even if the gulp watch dies, it will be revived like a zombie. By the way, it usually sounds like a beep, but

python zombie.py -s

If you do, you can also be quiet. You can also kill this zombie with Ctrl + C as you would with a normal command. Gist

Recommended Posts

I wrote a script to revive the gulp watch that will die soon
I wrote a script to combine the divided ts files
I wrote a script that splits the image in two
I wrote a script to upload a WordPress plugin
I wrote you to watch the signal with Go
I wrote a script to get a popular site in Japan
I wrote a Python script that exports all my posts using the Qiita API v2
I want to find a stock that will rise 5 minutes after the Nikkei Stock Average rises
I wrote a script to get you started with AtCoder fast!
I just wrote a script to build Android on another machine
I wrote a function to load a Git extension script in Python
I wrote a script to extract a web page link in Python
A script that returns 0, 1 attached to the first Python prime number
I wrote a script to help goodnotes5 and Anki work together
I will publish a shell script created to reduce the trouble of creating LiveUSB on Linux
I made a script to display emoji
I want to identify the alert email. --Is that x a wildcard? ---
I made a library konoha that switches the tokenizer to a nice feeling
I tried to make a skill that Alexa will return as cold
The story of IPv6 address that I want to keep at a minimum
I wrote a PyPI module that extends the parameter style in Python's sqlite3 module
I made a script to record the active window using win32gui of Python
A memo that I wrote a quicksort in Python
[Python] I will upload the FTP to the FTP server.
Note that I was addicted to npm script not passing in the verification environment
I will try to summarize the links that seem to be useful for the time being
The story of Linux that I want to teach myself half a year ago
I made a script to put a snippet in README.md
A story that I was addicted to at np.where
A memo that I touched the Datastore with python
I made a command to markdown the table clipboard
I felt that I ported the Python code to C ++ 98.
"Stop committing Japanese files to git on Mac> <" For the time being, I wrote a script to search for incompatible Japanese files on Mac and Linux.
A script that makes it easy to create rich menus with the LINE Messaging API
I tried to create a Python script to get the value of a cell in Microsoft Excel
A Python script that goes from Google search to saving the Search results page at once
[Python] I wrote a test of "Streamlit" that makes it easy to create visualization applications.
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
A Python script that allows you to check the status of the server from your browser
I wrote a script to create a Twitter Bot development environment quickly with AWS Lambda + Python 2.7
I tried to make a script that traces the tweets of a specific user on Twitter and saves the posted image at once
I replaced the Windows PowerShell cookbook with a python script.
A Python script that saves a clipboard (GTK) image to a file.
I wrote a program quickly to study DI with Python ①
Creating a Python script that supports the e-Stat API (ver.2)
A shell script that just emails the SQL execution result
I made a function to check the model of DCGAN
I wrote it in Go to understand the SOLID principle
Listen to a novel that will be on Amazon Polly
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
A script that displays the running CloudFormation stack like a mannequin
A python script that converts Oracle Database data to csv
I want to create a Dockerfile for the time being.
A Python script that compares the contents of two directories
I made a script to say hello at my Koshien
I tried to make a site that makes it easy to see the update information of Azure
I wrote AWS Lambda, and I was a little addicted to the default value of Python arguments
I implemented a method to calculate the evaluation index (specificity, NPV) that scikit-learn does not have
Note that I was addicted to accessing the DB with Python's mysql.connector using a web application.
[Python] I tried to make a simple program that works on the command line using argparse.
A story that didn't work when I tried to log in with the Python requests module