Last active
August 10, 2020 23:50
-
-
Save jedberg/143c12c79c7cba916a53f4f26ba1c11d to your computer and use it in GitHub Desktop.
Some utilities that are handy
This file contains 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
# Convert fahrenheit to celcius | |
def f2c(temp): | |
c = ((temp-32)/9)*5 | |
return round(c, 2) | |
# Check if a file is older than some number of seconds. | |
import time, os, stat | |
def file_too_old(pathname, seconds=600): | |
try: | |
os.stat(pathname) | |
except FileNotFoundError: | |
return True | |
if (time.time() - os.stat(pathname)[stat.ST_MTIME]) > seconds: | |
return True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment