Skip to content

Commit 14f0222

Browse files
committed
bug fixes in convert-script
1 parent b4bdebd commit 14f0222

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

miscellaneous/convert_to_acmev2.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import sys
55
import json
6+
import uuid
67
import configparser
78

89
from pathlib import Path
@@ -122,12 +123,23 @@ def convert_stored_certs(self):
122123

123124
loaded["cert"] = cert
124125

125-
path.write_text(json.dumps(loaded, indent=4, sort_keys=True))
126+
try:
127+
path.write_text(json.dumps(loaded, indent=4, sort_keys=True))
128+
except IOError as error:
129+
if error.errno == 13:
130+
# It may be owned by another user,
131+
# try to recreate it.
132+
temp_path = Path(str(uuid.uuid1()))
133+
path.rename(temp_path)
134+
path.write_text(json.dumps(loaded, indent=4, sort_keys=True))
135+
temp_path.unlink()
136+
else:
137+
raise
126138

127139
def get_new_config(self):
128140
configtp = namedtuple("Config", ["ca", "ca_proxy", "cm_account"])
129141
if self.config.getboolean("Certificate Authority", "use proxy"):
130-
ca_proxy = config.get("Certificate Authority", "proxy")
142+
ca_proxy = self.config.get("Certificate Authority", "proxy")
131143
else:
132144
ca_proxy = False
133145

0 commit comments

Comments
 (0)