Last active
October 18, 2021 22:03
-
-
Save rickyhewitt/3493500 to your computer and use it in GitHub Desktop.
dd.py -- A frontend for dd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
dd.py | |
dd.py provides a wrapper around the standard | |
dd command. Provides status updates through | |
the use of the -USR1 signal. | |
Updated for Python 3 04/01/16 | |
Author: Ricky Hewitt <[email protected]> | |
http://rickyhewitt.com | |
License: GNU GPL v3 <http://www.gnu.org> | |
""" | |
import subprocess | |
import os | |
import time | |
import sys | |
import shutil | |
def main(*args, **kwargs): | |
dd_bin = shutil.which("dd") | |
ddargs = args[0] | |
ddargs.insert(0, dd_bin) | |
pipe = subprocess.Popen(ddargs, shell=False, executable=dd_bin) | |
while(1): | |
output = subprocess.call("kill -USR1 %s" % pipe.pid, shell=True) | |
if pipe.poll() is None: | |
time.sleep(1) | |
else: | |
return pipe.poll() | |
main([i for i in sys.argv[1:]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment