mirror of https://github.com/sean1832/GPT-Brain
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
2 years ago
|
import os
|
||
|
import time
|
||
2 years ago
|
import modules.utilities as util
|
||
2 years ago
|
|
||
|
file_path = r'.user\input.txt'
|
||
|
temp_file = r'.user\input_last-run.temp'
|
||
|
|
||
2 years ago
|
|
||
2 years ago
|
def compare_time(t1, t2):
|
||
|
return t1 == t2
|
||
|
|
||
2 years ago
|
|
||
2 years ago
|
def isUpdated():
|
||
|
if os.path.exists(file_path):
|
||
|
# get modification time of the file
|
||
|
mod_time = os.path.getmtime(file_path)
|
||
|
|
||
|
# convert the modification time to readable format
|
||
|
read_mod_time = time.ctime(mod_time)
|
||
|
|
||
|
if os.path.exists(temp_file):
|
||
|
temp_info = util.read_file(temp_file)
|
||
|
if compare_time(read_mod_time, temp_info):
|
||
|
print('File has not been updated.')
|
||
|
return False
|
||
|
else:
|
||
|
print('File has been updated.')
|
||
|
util.write_file(read_mod_time, temp_file)
|
||
|
return True
|
||
|
else:
|
||
|
print('Temp file not exist, writing temp file...')
|
||
|
# write to temp file
|
||
|
util.write_file(read_mod_time, temp_file)
|
||
2 years ago
|
time.sleep(1)
|
||
|
return True
|
||
2 years ago
|
else:
|
||
2 years ago
|
raise FileNotFoundError(f'File: {file_path} does not exist.')
|