Don't fail if we can't create startup file

Fixes https://gitlab.com/kicad/code/kicad/issues/9205
This commit is contained in:
Seth Hillbrand 2021-09-21 14:21:40 -07:00
parent 73401932f7
commit 38cdc362a0
1 changed files with 18 additions and 15 deletions

View File

@ -49,21 +49,24 @@ class KiCadPyShell(KiCadEditorNotebookFrame):
# Check if startup script exists
if not os.path.isfile(self.startup_file):
# Not, so create a default.
default_startup = open(self.startup_file, 'w')
# provide the content for the default startup file.
default_startup.write(
"### DEFAULT STARTUP FILE FOR KiCad Python Shell\n" +
"# Enter any Python code you would like to execute when" +
" the PCBNEW python shell first runs.\n" +
"\n" +
"# For example, uncomment the following lines to import the current board\n" +
"\n" +
"# import pcbnew\n" +
"# import eeschema\n" +
"# board = pcbnew.GetBoard()\n" +
"# sch = eeschema.GetSchematic()\n")
default_startup.close()
# Not, so try to create a default.
try:
default_startup = open(self.startup_file, 'w')
# provide the content for the default startup file.
default_startup.write(
"### DEFAULT STARTUP FILE FOR KiCad Python Shell\n" +
"# Enter any Python code you would like to execute when" +
" the PCBNEW python shell first runs.\n" +
"\n" +
"# For example, uncomment the following lines to import the current board\n" +
"\n" +
"# import pcbnew\n" +
"# import eeschema\n" +
"# board = pcbnew.GetBoard()\n" +
"# sch = eeschema.GetSchematic()\n")
default_startup.close()
except:
pass
def _setup(self):
"""