8 """ |
8 """ |
9 |
9 |
10 import textwrap |
10 import textwrap |
11 import os |
11 import os |
12 import html.parser |
12 import html.parser |
|
13 import contextlib |
13 |
14 |
14 from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QUrlQuery |
15 from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QUrlQuery |
15 from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest |
16 from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest |
16 from PyQt5.QtWidgets import ( |
17 from PyQt5.QtWidgets import ( |
17 QWidget, QToolButton, QApplication, QHeaderView, QTreeWidgetItem, |
18 QWidget, QToolButton, QApplication, QHeaderView, QTreeWidgetItem, |
1211 self.tr("""No valid configuration path determined.""" |
1212 self.tr("""No valid configuration path determined.""" |
1212 """ Aborting""")) |
1213 """ Aborting""")) |
1213 return |
1214 return |
1214 |
1215 |
1215 if not os.path.exists(cfgFile): |
1216 if not os.path.exists(cfgFile): |
1216 try: |
1217 with contextlib.suppress(OSError), open(cfgFile, "w") as f: |
1217 with open(cfgFile, "w") as f: |
1218 f.write("[global]\n") |
1218 f.write("[global]\n") |
|
1219 except OSError: |
|
1220 # ignore these |
|
1221 pass |
|
1222 |
1219 |
1223 # check, if the destination is writeable |
1220 # check, if the destination is writeable |
1224 if not os.access(cfgFile, os.W_OK): |
1221 if not os.access(cfgFile, os.W_OK): |
1225 E5MessageBox.critical( |
1222 E5MessageBox.critical( |
1226 None, |
1223 None, |