Last active
December 8, 2016 12:35
-
-
Save brianpeiris/8708cdf8812d656fa418 to your computer and use it in GitHub Desktop.
A python program (for windows) that plays tones based on disk activity
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
import time | |
import psutil | |
import winsound | |
last_disk_time = None | |
last_time = None | |
while (True): | |
curr_time = time.time() | |
counters = psutil.disk_io_counters() | |
read_time = counters.read_time | |
write_time = counters.write_time | |
curr_disk_time = read_time + write_time | |
if last_disk_time is not None: | |
ddisk = curr_disk_time - last_disk_time | |
dtime = curr_time - last_time | |
disk_rate = ddisk / dtime | |
diff = 500 + round(disk_rate / 3000) | |
print('{0: > 010n}, {1}'.format(round(disk_rate), diff)) | |
if diff > 550: | |
winsound.Beep(diff, 200) | |
else: | |
time.sleep(0.2) | |
last_disk_time = curr_disk_time | |
last_time = curr_time | |
time.sleep(0.05) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Brian
Can you please explain how did you choose these constants - 500, 3000, 550, 200 in your code above?