20250117.1737144422
This commit is contained in:
parent
6c2f5819e8
commit
df2469e105
1 changed files with 36 additions and 1 deletions
|
@ -259,8 +259,17 @@ def fetch_weather(
|
|||
|
||||
|
||||
def doctor():
|
||||
if len(sys.argv) < 3:
|
||||
args_len = len(sys.argv)
|
||||
check_diary = False
|
||||
fix_diary = False
|
||||
if args_len < 3:
|
||||
sys.exit("Usage: script.py doctor <diary_name>")
|
||||
if args_len >= 4 and sys.argv[3] == "check_diary":
|
||||
check_diary = True
|
||||
|
||||
if args_len >= 4 and sys.argv[3] == "check_and_fix_diary":
|
||||
fix_diary = True
|
||||
check_diary = True
|
||||
|
||||
diary_name = sys.argv[2]
|
||||
diary_path = get_diary_path_by_name(diary_name).parent
|
||||
|
@ -283,6 +292,32 @@ def doctor():
|
|||
if not location:
|
||||
print(f"There is no location info about {m[0]} - {m[1]}")
|
||||
|
||||
if check_diary:
|
||||
dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ)))
|
||||
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
||||
# print(diary_datetime)
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["jrnl", diary_name, "-on", diary_datetime],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if not result.stdout:
|
||||
print(
|
||||
f"There is some metadata that is not associated with a diary entity: {diary_datetime}."
|
||||
)
|
||||
if not fix_diary:
|
||||
print(
|
||||
"You can automatically remove it by running the scripts with 'check_and_fix_diary' argument."
|
||||
)
|
||||
else:
|
||||
remove_metadata(conn, m[0])
|
||||
print("The problem was fixed.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e)
|
||||
raise
|
||||
|
||||
|
||||
def make_hash(file: Path):
|
||||
sha256_hash = hashlib.sha256()
|
||||
|
|
Loading…
Add table
Reference in a new issue