Add exception for file read

merge-requests/30/head
Bob Mottram 2024-07-19 11:59:00 +01:00
parent b93b8e43f0
commit ace9f84d9a
1 changed files with 135 additions and 126 deletions

View File

@ -44,6 +44,9 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
index_lines = []
delete_schedule_post = False
nickname = handle.split('@')[0]
shared_items_federated_domains = httpd.shared_items_federated_domains
shared_item_federation_tokens = httpd.shared_item_federation_tokens
try:
with open(schedule_index_filename, 'r', encoding='utf-8') as fp_sched:
for line in fp_sched:
if ' ' not in line:
@ -60,7 +63,8 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
try:
os.remove(post_filename)
except OSError:
print('EX: _update_post_schedule unable to delete ' +
print('EX: ' +
'_update_post_schedule unable to delete ' +
str(post_filename))
continue
# create the new index file
@ -79,7 +83,8 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
if curr_time.time().minute < post_time.time().minute:
continue
if not os.path.isfile(post_filename):
print('WARN: schedule missing post_filename=' + post_filename)
print('WARN: schedule missing post_filename=' +
post_filename)
index_lines.remove(line)
continue
# load post
@ -138,9 +143,10 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
httpd.twitter_replacement_domain,
httpd.show_published_date_only,
httpd.allow_local_network_access,
httpd.city, httpd.system_language,
httpd.shared_items_federated_domains,
httpd.shared_item_federation_tokens,
httpd.city,
httpd.system_language,
shared_items_federated_domains,
shared_item_federation_tokens,
httpd.low_bandwidth,
httpd.signing_priv_key_pem,
httpd.peertube_instances,
@ -177,6 +183,9 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
index_lines.remove(line)
if len(index_lines) > max_scheduled_posts:
delete_schedule_post = True
except OSError as exc:
print('EX: _update_post_schedule unable to read ' +
schedule_index_filename + ' ' + str(exc))
# write the new schedule index file
schedule_index_file = \