mirror of https://gitlab.com/bashrc2/epicyon
File encoding
parent
1d20d7f531
commit
b8b25760e9
24
daemon.py
24
daemon.py
|
@ -2922,7 +2922,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nw_filename = newswire_blocked_filename
|
nw_filename = newswire_blocked_filename
|
||||||
nw_written = False
|
nw_written = False
|
||||||
try:
|
try:
|
||||||
with open(nw_filename, 'w+') as nofile:
|
with open(nw_filename, 'w+',
|
||||||
|
encoding='utf-8') as nofile:
|
||||||
nofile.write('\n')
|
nofile.write('\n')
|
||||||
nw_written = True
|
nw_written = True
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
|
@ -5672,7 +5673,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
city_filename = \
|
city_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/city.txt'
|
acct_dir(base_dir, nickname, domain) + '/city.txt'
|
||||||
try:
|
try:
|
||||||
with open(city_filename, 'w+') as fp_city:
|
with open(city_filename, 'w+',
|
||||||
|
encoding='utf-8') as fp_city:
|
||||||
fp_city.write(fields['cityDropdown'])
|
fp_city.write(fields['cityDropdown'])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write city ' + city_filename)
|
print('EX: unable to write city ' + city_filename)
|
||||||
|
@ -6403,7 +6405,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
eds = fields['editors'].split(',')
|
eds = fields['editors'].split(',')
|
||||||
try:
|
try:
|
||||||
with open(editors_file, 'w+') as edfil:
|
with open(editors_file, 'w+',
|
||||||
|
encoding='utf-8') as edfil:
|
||||||
for ed_nick in eds:
|
for ed_nick in eds:
|
||||||
ed_nick = ed_nick.strip()
|
ed_nick = ed_nick.strip()
|
||||||
ed_dir = base_dir + \
|
ed_dir = base_dir + \
|
||||||
|
@ -6428,8 +6431,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
eds = fields['editors'].split('\n')
|
eds = fields['editors'].split('\n')
|
||||||
try:
|
try:
|
||||||
with open(editors_file,
|
with open(editors_file, 'w+',
|
||||||
'w+') as edfile:
|
encoding='utf-8') as edfile:
|
||||||
for ed_nick in eds:
|
for ed_nick in eds:
|
||||||
ed_nick = ed_nick.strip()
|
ed_nick = ed_nick.strip()
|
||||||
ed_dir = \
|
ed_dir = \
|
||||||
|
@ -8106,7 +8109,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(ontology_filename):
|
if os.path.isfile(ontology_filename):
|
||||||
ontology_file = None
|
ontology_file = None
|
||||||
try:
|
try:
|
||||||
with open(ontology_filename, 'r') as fp_ont:
|
with open(ontology_filename, 'r',
|
||||||
|
encoding='utf-8') as fp_ont:
|
||||||
ontology_file = fp_ont.read()
|
ontology_file = fp_ont.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to read ontology ' + ontology_filename)
|
print('EX: unable to read ontology ' + ontology_filename)
|
||||||
|
@ -11509,7 +11513,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
ssml_str = None
|
ssml_str = None
|
||||||
try:
|
try:
|
||||||
with open(ssml_filename, 'r') as fp_ssml:
|
with open(ssml_filename, 'r', encoding='utf-8') as fp_ssml:
|
||||||
ssml_str = fp_ssml.read()
|
ssml_str = fp_ssml.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
@ -18639,7 +18643,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
media_tag_filename = media_filename + '.etag'
|
media_tag_filename = media_filename + '.etag'
|
||||||
if os.path.isfile(media_tag_filename):
|
if os.path.isfile(media_tag_filename):
|
||||||
try:
|
try:
|
||||||
with open(media_tag_filename, 'r') as efile:
|
with open(media_tag_filename, 'r',
|
||||||
|
encoding='utf-8') as efile:
|
||||||
etag = efile.read()
|
etag = efile.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: do_HEAD unable to read ' +
|
print('EX: do_HEAD unable to read ' +
|
||||||
|
@ -18655,7 +18660,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if media_binary:
|
if media_binary:
|
||||||
etag = md5(media_binary).hexdigest() # nosec
|
etag = md5(media_binary).hexdigest() # nosec
|
||||||
try:
|
try:
|
||||||
with open(media_tag_filename, 'w+') as efile:
|
with open(media_tag_filename, 'w+',
|
||||||
|
encoding='utf-8') as efile:
|
||||||
efile.write(etag)
|
efile.write(etag)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: do_HEAD unable to write ' +
|
print('EX: do_HEAD unable to write ' +
|
||||||
|
|
|
@ -615,7 +615,7 @@ def get_this_weeks_events(base_dir: str, nickname: str, domain: str) -> {}:
|
||||||
|
|
||||||
calendar_post_ids = []
|
calendar_post_ids = []
|
||||||
recreate_events_file = False
|
recreate_events_file = False
|
||||||
with open(calendar_filename, 'r') as events_file:
|
with open(calendar_filename, 'r', encoding='utf-8') as events_file:
|
||||||
for post_id in events_file:
|
for post_id in events_file:
|
||||||
post_id = post_id.replace('\n', '').replace('\r', '')
|
post_id = post_id.replace('\n', '').replace('\r', '')
|
||||||
post_filename = locate_post(base_dir, nickname, domain, post_id)
|
post_filename = locate_post(base_dir, nickname, domain, post_id)
|
||||||
|
|
6
inbox.py
6
inbox.py
|
@ -4170,7 +4170,8 @@ def _inbox_after_initial(server, inbox_start_time,
|
||||||
print('MUTE REPLY: ' + destination_filename)
|
print('MUTE REPLY: ' + destination_filename)
|
||||||
destination_filename_muted = destination_filename + '.muted'
|
destination_filename_muted = destination_filename + '.muted'
|
||||||
try:
|
try:
|
||||||
with open(destination_filename_muted, 'w+') as mute_file:
|
with open(destination_filename_muted, 'w+',
|
||||||
|
encoding='utf-8') as mute_file:
|
||||||
mute_file.write('\n')
|
mute_file.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write ' + destination_filename_muted)
|
print('EX: unable to write ' + destination_filename_muted)
|
||||||
|
@ -4592,7 +4593,8 @@ def _check_json_signature(base_dir: str, queue_json: {}) -> (bool, bool):
|
||||||
|
|
||||||
if not already_unknown:
|
if not already_unknown:
|
||||||
try:
|
try:
|
||||||
with open(unknown_signatures_file, 'a+') as unknown_file:
|
with open(unknown_signatures_file, 'a+',
|
||||||
|
encoding='utf-8') as unknown_file:
|
||||||
unknown_file.write(jwebsig_type + '\n')
|
unknown_file.write(jwebsig_type + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to append ' + unknown_signatures_file)
|
print('EX: unable to append ' + unknown_signatures_file)
|
||||||
|
|
|
@ -117,13 +117,15 @@ def _approve_follower_handle(account_dir: str, approve_handle: str) -> None:
|
||||||
if os.path.isfile(approved_filename):
|
if os.path.isfile(approved_filename):
|
||||||
if not text_in_file(approve_handle, approved_filename):
|
if not text_in_file(approve_handle, approved_filename):
|
||||||
try:
|
try:
|
||||||
with open(approved_filename, 'a+') as approved_file:
|
with open(approved_filename, 'a+',
|
||||||
|
encoding='utf-8') as approved_file:
|
||||||
approved_file.write(approve_handle + '\n')
|
approved_file.write(approve_handle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to append ' + approved_filename)
|
print('EX: unable to append ' + approved_filename)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(approved_filename, 'w+') as approved_file:
|
with open(approved_filename, 'w+',
|
||||||
|
encoding='utf-8') as approved_file:
|
||||||
approved_file.write(approve_handle + '\n')
|
approved_file.write(approve_handle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write ' + approved_filename)
|
print('EX: unable to write ' + approved_filename)
|
||||||
|
|
5
media.py
5
media.py
|
@ -318,12 +318,13 @@ def _spoof_meta_data(base_dir: str, nickname: str, domain: str,
|
||||||
decoy_seed_filename = acct_dir(base_dir, nickname, domain) + '/decoyseed'
|
decoy_seed_filename = acct_dir(base_dir, nickname, domain) + '/decoyseed'
|
||||||
decoy_seed = 63725
|
decoy_seed = 63725
|
||||||
if os.path.isfile(decoy_seed_filename):
|
if os.path.isfile(decoy_seed_filename):
|
||||||
with open(decoy_seed_filename, 'r') as fp_seed:
|
with open(decoy_seed_filename, 'r', encoding='utf-8') as fp_seed:
|
||||||
decoy_seed = int(fp_seed.read())
|
decoy_seed = int(fp_seed.read())
|
||||||
else:
|
else:
|
||||||
decoy_seed = randint(10000, 10000000000000000)
|
decoy_seed = randint(10000, 10000000000000000)
|
||||||
try:
|
try:
|
||||||
with open(decoy_seed_filename, 'w+') as fp_seed:
|
with open(decoy_seed_filename, 'w+',
|
||||||
|
encoding='utf-8') as fp_seed:
|
||||||
fp_seed.write(str(decoy_seed))
|
fp_seed.write(str(decoy_seed))
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write ' + decoy_seed_filename)
|
print('EX: unable to write ' + decoy_seed_filename)
|
||||||
|
|
|
@ -522,7 +522,7 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
os.mkdir(base_dir + private_keys_subdir)
|
os.mkdir(base_dir + private_keys_subdir)
|
||||||
filename = base_dir + private_keys_subdir + '/' + handle + '.key'
|
filename = base_dir + private_keys_subdir + '/' + handle + '.key'
|
||||||
try:
|
try:
|
||||||
with open(filename, 'w+') as text_file:
|
with open(filename, 'w+', encoding='utf-8') as text_file:
|
||||||
print(private_key_pem, file=text_file)
|
print(private_key_pem, file=text_file)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to save ' + filename)
|
print('EX: unable to save ' + filename)
|
||||||
|
@ -533,7 +533,7 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
os.mkdir(base_dir + public_keys_subdir)
|
os.mkdir(base_dir + public_keys_subdir)
|
||||||
filename = base_dir + public_keys_subdir + '/' + handle + '.pem'
|
filename = base_dir + public_keys_subdir + '/' + handle + '.pem'
|
||||||
try:
|
try:
|
||||||
with open(filename, 'w+') as text_file:
|
with open(filename, 'w+', encoding='utf-8') as text_file:
|
||||||
print(public_key_pem, file=text_file)
|
print(public_key_pem, file=text_file)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to save 2 ' + filename)
|
print('EX: unable to save 2 ' + filename)
|
||||||
|
|
|
@ -487,7 +487,7 @@ def html_edit_links(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
links_filename = base_dir + '/accounts/links.txt'
|
links_filename = base_dir + '/accounts/links.txt'
|
||||||
links_str = ''
|
links_str = ''
|
||||||
if os.path.isfile(links_filename):
|
if os.path.isfile(links_filename):
|
||||||
with open(links_filename, 'r') as fp_links:
|
with open(links_filename, 'r', encoding='utf-8') as fp_links:
|
||||||
links_str = fp_links.read()
|
links_str = fp_links.read()
|
||||||
|
|
||||||
edit_links_form += \
|
edit_links_form += \
|
||||||
|
@ -512,7 +512,7 @@ def html_edit_links(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
about_filename = base_dir + '/accounts/about.md'
|
about_filename = base_dir + '/accounts/about.md'
|
||||||
about_str = ''
|
about_str = ''
|
||||||
if os.path.isfile(about_filename):
|
if os.path.isfile(about_filename):
|
||||||
with open(about_filename, 'r') as fp_about:
|
with open(about_filename, 'r', encoding='utf-8') as fp_about:
|
||||||
about_str = fp_about.read()
|
about_str = fp_about.read()
|
||||||
|
|
||||||
edit_links_form += \
|
edit_links_form += \
|
||||||
|
@ -531,7 +531,7 @@ def html_edit_links(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
tos_filename = base_dir + '/accounts/tos.md'
|
tos_filename = base_dir + '/accounts/tos.md'
|
||||||
tos_str = ''
|
tos_str = ''
|
||||||
if os.path.isfile(tos_filename):
|
if os.path.isfile(tos_filename):
|
||||||
with open(tos_filename, 'r') as fp_tos:
|
with open(tos_filename, 'r', encoding='utf-8') as fp_tos:
|
||||||
tos_str = fp_tos.read()
|
tos_str = fp_tos.read()
|
||||||
|
|
||||||
edit_links_form += \
|
edit_links_form += \
|
||||||
|
|
Loading…
Reference in New Issue