implement TclCommand.TclCommandSignaled as proof of concept (not usefull)
bypass using threads  within obj.generatecncjob(use_thread = False, **args)
reimplement some more shell commands  to  OOP style
This commit is contained in:
Kamil Sopko
2016-03-19 15:13:07 +01:00
parent 0f463a1fc2
commit 980638630d
10 changed files with 427 additions and 162 deletions

View File

@@ -1,5 +1,4 @@
import pkgutil
import inspect
import sys
# allowed command modules
@@ -7,9 +6,10 @@ import tclCommands.TclCommandExteriors
import tclCommands.TclCommandInteriors
import tclCommands.TclCommandAddPolygon
import tclCommands.TclCommandAddPolyline
import tclCommands.TclCommandExportGcode
import tclCommands.TclCommandCncjob
__all__=[]
__all__ = []
for loader, name, is_pkg in pkgutil.walk_packages(__path__):
module = loader.find_module(name).load_module(name)
@@ -25,8 +25,8 @@ def register_all_commands(app, commands):
we need import all modules in top section:
import tclCommands.TclCommandExteriors
at this stage we can include only wanted commands with this, autoloading may be implemented in future
I have no enought knowledge about python's anatomy. Would be nice to include all classes which are descendant etc.
at this stage we can include only wanted commands with this, auto loading may be implemented in future
I have no enough knowledge about python's anatomy. Would be nice to include all classes which are descendant etc.
:param app: FlatCAMApp
:param commands: array of commands which should be modified
@@ -35,14 +35,14 @@ def register_all_commands(app, commands):
tcl_modules = {k: v for k, v in sys.modules.items() if k.startswith('tclCommands.TclCommand')}
for key, module in tcl_modules.items():
for key, mod in tcl_modules.items():
if key != 'tclCommands.TclCommand':
classname = key.split('.')[1]
class_ = getattr(module, classname)
commandInstance=class_(app)
class_name = key.split('.')[1]
class_type = getattr(mod, class_name)
command_instance = class_type(app)
for alias in commandInstance.aliases:
commands[alias]={
'fcn': commandInstance.execute_wrapper,
'help': commandInstance.get_decorated_help()
}
for alias in command_instance.aliases:
commands[alias] = {
'fcn': command_instance.execute_wrapper,
'help': command_instance.get_decorated_help()
}