mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-08 04:41:49 +08:00
Creating an argparser early and add a "debug" option
Makes sure we don't log anything at the moment, when debug is passed. Otherwise early errors are not displayed and passed to log files.
This commit is contained in:
parent
61b6831e62
commit
ab6508657d
@ -628,13 +628,14 @@ class CuraApplication(QtApplication):
|
|||||||
# This should be called directly before creating an instance of CuraApplication.
|
# This should be called directly before creating an instance of CuraApplication.
|
||||||
# \returns \type{bool} True if the whole Cura app should continue running.
|
# \returns \type{bool} True if the whole Cura app should continue running.
|
||||||
@classmethod
|
@classmethod
|
||||||
def preStartUp(cls):
|
def preStartUp(cls, parser = None, parsed_command_line = {}):
|
||||||
# Peek the arguments and look for the 'single-instance' flag.
|
# Peek the arguments and look for the 'single-instance' flag.
|
||||||
|
if not parser:
|
||||||
parser = argparse.ArgumentParser(prog = "cura", add_help = False) # pylint: disable=bad-whitespace
|
parser = argparse.ArgumentParser(prog = "cura", add_help = False) # pylint: disable=bad-whitespace
|
||||||
CuraApplication.addCommandLineOptions(parser)
|
CuraApplication.addCommandLineOptions(parser)
|
||||||
# Important: It is important to keep this line here!
|
# Important: It is important to keep this line here!
|
||||||
# In Uranium we allow to pass unknown arguments to the final executable or script.
|
# In Uranium we allow to pass unknown arguments to the final executable or script.
|
||||||
parsed_command_line = vars(parser.parse_known_args()[0])
|
parsed_command_line.update(vars(parser.parse_known_args()[0]))
|
||||||
|
|
||||||
if parsed_command_line["single_instance"]:
|
if parsed_command_line["single_instance"]:
|
||||||
Logger.log("i", "Checking for the presence of an ready running Cura instance.")
|
Logger.log("i", "Checking for the presence of an ready running Cura instance.")
|
||||||
|
15
cura_app.py
15
cura_app.py
@ -3,10 +3,21 @@
|
|||||||
# Copyright (c) 2015 Ultimaker B.V.
|
# Copyright (c) 2015 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from UM.Platform import Platform
|
from UM.Platform import Platform
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--debug',
|
||||||
|
action='store_true',
|
||||||
|
default = False
|
||||||
|
)
|
||||||
|
known_args, unknown_args = parser.parse_known_args()
|
||||||
|
known_args = vars(known_args)
|
||||||
|
|
||||||
|
if known_args["debug"]:
|
||||||
def get_cura_dir_path():
|
def get_cura_dir_path():
|
||||||
if Platform.isWindows():
|
if Platform.isWindows():
|
||||||
return os.path.expanduser("~/AppData/Roaming/cura/")
|
return os.path.expanduser("~/AppData/Roaming/cura/")
|
||||||
@ -78,8 +89,8 @@ faulthandler.enable()
|
|||||||
cura.Settings.CuraContainerRegistry.CuraContainerRegistry.getInstance()
|
cura.Settings.CuraContainerRegistry.CuraContainerRegistry.getInstance()
|
||||||
|
|
||||||
# This pre-start up check is needed to determine if we should start the application at all.
|
# This pre-start up check is needed to determine if we should start the application at all.
|
||||||
if not cura.CuraApplication.CuraApplication.preStartUp():
|
if not cura.CuraApplication.CuraApplication.preStartUp(parser = parser, parsed_command_line = known_args):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
app = cura.CuraApplication.CuraApplication.getInstance()
|
app = cura.CuraApplication.CuraApplication.getInstance(parser = parser, parsed_command_line = known_args)
|
||||||
app.run()
|
app.run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user