- fixed the --shellvar and --shellfile FlatCAM arguments to work together but the --shellvar has precedence over --shellfile as it is most likely that whatever variable set by --shellvar will be used in the script file run by --shellfile

This commit is contained in:
Marius Stanciu
2019-09-17 20:24:34 +03:00
committed by Marius
parent 97cf8f8174
commit 6723f9496c
2 changed files with 38 additions and 33 deletions

View File

@@ -2392,27 +2392,27 @@ class App(QtCore.QObject):
# ###############################################################################
App.log.debug("END of constructor. Releasing control.")
# #####################################################################################
# ########################## SHOW GUI #################################################
# #####################################################################################
# finish the splash
self.splash.finish(self.ui)
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("maximized_gui"):
maximized_ui = settings.value('maximized_gui', type=bool)
if maximized_ui is True:
self.ui.showMaximized()
else:
self.ui.show()
# #####################################################################################
# ########################## START-UP ARGUMENTS #######################################
# #####################################################################################
# test if the program was started with a script as parameter
if self.cmd_line_shellfile:
try:
with open(self.cmd_line_shellfile, "r") as myfile:
if show_splash:
self.splash.showMessage('%s: %ssec\n%s' % (
_("Canvas initialization started.\n"
"Canvas initialization finished in"), '%.2f' % self.used_time,
_("Executing Tcl Script ...")),
alignment=Qt.AlignBottom | Qt.AlignLeft,
color=QtGui.QColor("gray"))
cmd_line_shellfile_text = myfile.read()
self.shell._sysShell.exec_command(cmd_line_shellfile_text)
except Exception as ext:
print("ERROR: ", ext)
sys.exit(2)
elif self.cmd_line_shellvar:
if self.cmd_line_shellvar:
try:
cnt = 0
command_tcl = 0
@@ -2434,26 +2434,30 @@ class App(QtCore.QObject):
print("ERROR: ", ext)
sys.exit(2)
# accept some type file as command line parameter: FlatCAM project, FlatCAM preferences or scripts
# the path/file_name must be enclosed in quotes if it contain spaces
if self.cmd_line_shellfile:
try:
if self.ui.shell_dock.isHidden():
self.ui.shell_dock.show()
with open(self.cmd_line_shellfile, "r") as myfile:
if show_splash:
self.splash.showMessage('%s: %ssec\n%s' % (
_("Canvas initialization started.\n"
"Canvas initialization finished in"), '%.2f' % self.used_time,
_("Executing Tcl Script ...")),
alignment=Qt.AlignBottom | Qt.AlignLeft,
color=QtGui.QColor("gray"))
cmd_line_shellfile_text = myfile.read()
self.shell._sysShell.exec_command(cmd_line_shellfile_text)
except Exception as ext:
print("ERROR: ", ext)
sys.exit(2)
# accept some type file as command line parameter: FlatCAM project, FlatCAM preferences or scripts
# the path/file_name must be enclosed in quotes if it contain spaces
if App.args:
self.args_at_startup.emit(App.args)
# finish the splash
self.splash.finish(self.ui)
# #####################################################################################
# ########################## SHOW GUI #################################################
# #####################################################################################
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("maximized_gui"):
maximized_ui = settings.value('maximized_gui', type=bool)
if maximized_ui is True:
self.ui.showMaximized()
else:
self.ui.show()
@staticmethod
def copy_and_overwrite(from_path, to_path):
"""

View File

@@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing.
- added a new command line parameter for FlatCAM named '--shellvars' which can load a text file with variables for Tcl Shell in the format: one variable assignment per line and looking like: 'a=3' without quotes
- made --shellvars into --shellvar and make it only one list of commands passed to the Tcl. The list is separated by comma but without spaces. The variables are accessed in Tcl with the names shellvar_x where x is the index in the list of command comma separated values
- fixed an issue in the TclShell that generated an exception IndexError which crashed the software
- fixed the --shellvar and --shellfile FlatCAM arguments to work together but the --shellvar has precedence over --shellfile as it is most likely that whatever variable set by --shellvar will be used in the script file run by --shellfile
16.09.2019