Skip to content

Commit

Permalink
Merge pull request #116 from evil-mad/3_1
Browse files Browse the repository at this point in the history
AxiDraw software 3.1
  • Loading branch information
oskay authored Jan 19, 2022
2 parents fc63c3b + 715b1c9 commit 3fc7991
Show file tree
Hide file tree
Showing 22 changed files with 562 additions and 691 deletions.
33 changes: 20 additions & 13 deletions cli/axicli/axidraw_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -73,7 +73,7 @@
from plotink.plot_utils_import import from_dependency_import # plotink
exit_status = from_dependency_import("ink_extensions_utils.exit_status")

cli_version = "AxiDraw Command Line Interface 3.0.2"
cli_version = "AxiDraw Command Line Interface 3.1.0"

quick_help = '''
Basic syntax to plot a file: axicli svg_in [OPTIONS]
Expand All @@ -84,7 +84,7 @@
For full user guide, please see: https://axidraw.com/doc/cli_api/
(c) 2021 Evil Mad Scientist Laboratories
(c) 2022 Evil Mad Scientist Laboratories
'''

def axidraw_CLI(dev = False):
Expand Down Expand Up @@ -185,7 +185,7 @@ def axidraw_CLI(dev = False):
+ "1: Pen-down movement. 2: Pen-up movement. 3: All movement.")

parser.add_argument("-G","--reordering", \
metavar='REORDERING', type=int, \
metavar='VALUE', type=int, \
help="SVG reordering option (0-2)."\
+ " 0: None; Preserve order of objects given in SVG file."\
+ " 1: Reorder objects, preserving path orientation."\
Expand Down Expand Up @@ -216,6 +216,21 @@ def axidraw_CLI(dev = False):
metavar='FILE', \
help="Optional SVG output file name")

parser.add_argument("-O","--digest",\
metavar='VALUE', type=int,\
help="Plot digest output option (0-2)."\
+ " 0: No change to behavior or output (Default)."\
+ " 1: Output 'plob' digest, not full SVG, when saving file."\
+ " 2: Disable plots and previews; generate digest only.")

parser.add_argument("-W","--webhook", \
action="store_const", const='True', \
help='Enable webhook alerts')

parser.add_argument("-U","--webhook_url",\
metavar='URL', type=str,\
help="URL for webhook alerts")

parser.add_argument("--version",
action='store_const', const='True',
help="Output the version of axicli")
Expand Down Expand Up @@ -314,17 +329,9 @@ def axidraw_CLI(dev = False):
"pen_rate_lower", "pen_rate_raise", "pen_delay_down", "pen_delay_up",
"random_start", "reordering", "no_rotate", "const_speed", "report_time",
"manual_cmd", "walk_dist", "layer", "copies", "page_delay", "preview",
"rendering", "model", "port", "port_config"]
"rendering", "model", "port", "port_config", 'digest', 'webhook', 'webhook_url',]
utils.assign_option_values(adc.options, args, [config_dict], option_names)

# The following options are deprecated and should not be used.
# adc.options.setup_type = args.setup_type # Legacy input; not needed
# adc.options.smoothness = args.smoothness # Legacy input; not needed
# adc.options.cornering = args.cornering # Legacy input; not needed
# adc.options.resolution = args.resolution # Legacy input; not needed
# adc.options.resume_type = args.resume_type # Legacy input; not needed
# adc.options.auto_rotate = args.auto_rotate # Legacy input; not needed

exit_status.run(adc.effect) # Plot the document
if utils.has_output(adc) and not use_trivial_file:
utils.output_result(args.output_file, adc.outdoc)
Expand Down
48 changes: 27 additions & 21 deletions cli/axicli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,37 @@ def load_configs(config_list):


def load_config(config):
try:
if config is None:
config_dict = {}
elif len(config) > 3 and config[-3:] == ".py":
config_dict = runpy.run_path(config)
if config is None:
return {}

config_dict = None
try: # try assuming config is a filename
config_dict = runpy.run_path(config)
except SyntaxError as se:
print('Config file {} contains a syntax error on line {}:'.format(se.filename, se.lineno))
print(' {}'.format(se.text))
print('The config file should be a python file (e.g., a file that ends in ".py").')
sys.exit(1)
except IOError as ose:
if len(config) > 3 and config[-3:] == ".py" and ose.errno == errno.ENOENT:
# if config is a filename ending in ".py" but it doesn't appear to exist
print("Could not find any file named {}.".format(config))
print("Check the spelling and/or location.")
sys.exit(1)
else:
# Either config is a config file that doesn't have a .py AND it doesn't exist
# or config is a module
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# since technically this is importing "axidrawinternal.axidraw_conf" twice, it would generate a warning, but we can ignore it
config_dict = runpy.run_module(config)

return { key: value for key, value in config_dict.items() if key[0] != "_" }

except IOError as ose:
if ose.errno == errno.ENOENT: # no such file or directory
print('Could not find any file named {}.'.format(config))
print('Check the spelling and/or location.')
sys.exit(1)
else:
raise
except SyntaxError as e:
print('Config file {} contains a syntax error on line {}:'.format(e.filename, e.lineno))
print(' {}'.format(e.text))
print('The config file should be a python file (*.py).')
sys.exit(1)
try: # assume config is a module
config_dict = runpy.run_module(config)
except ImportError as ie: # oops, no module named that
# config may be a config file that doesn't have a .py AND doesn't exist
print("Could not find any file or module named {}.".format(config))
sys.exit(1)

return { key: value for key, value in config_dict.items() if key[0] != "_" }

def assign_option_values(options_obj, command_line, configs, option_names):
""" `configs` is a list of dicts containing values for the options, in order of priority.
Expand Down
16 changes: 4 additions & 12 deletions cli/examples_python/estimate_time.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -#-
from __future__ import print_function

'''
estimate_time.py
Expand All @@ -10,13 +9,8 @@
Run this demo by calling: python estimate_time.py
To save the time estimate to a file, you may be able to use a command similar to:
python estimate_time.py > file.txt
AxiDraw python API documentation is hosted at: https://axidraw.com/doc/py_api/
'''

'''
Expand All @@ -40,7 +34,7 @@
Copyright 2020 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -103,12 +97,10 @@
ad.plot_setup("AxiDraw_trivial.svg")
'''



ad.options.preview = True
ad.options.report_time = True # Enable time estimates

ad.plot_run() # plot the document

# print("Estimated print time: {0} ms".format(ad.pt_estimate))
print("{0}".format(ad.pt_estimate))
print_time_seconds = ad.time_estimate
print("Estimated print time: {0} s".format(print_time_seconds))

46 changes: 46 additions & 0 deletions cli/examples_python/interactive_penheights.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,52 @@
'''


'''
About this software:
The AxiDraw writing and drawing machine is a product of Evil Mad Scientist
Laboratories. https://axidraw.com https://shop.evilmadscientist.com
This open source software is written and maintained by Evil Mad Scientist
to support AxiDraw users across a wide range of applications. Please help
support Evil Mad Scientist and open source software development by purchasing
genuine AxiDraw hardware.
AxiDraw software development is hosted at https://github.com/evil-mad/axidraw
Additional AxiDraw documentation is available at http://axidraw.com/docs
AxiDraw owners may request technical support for this software through our
github issues page, support forums, or by contacting us directly at:
https://shop.evilmadscientist.com/contact
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''

import sys
import time

Expand Down
46 changes: 45 additions & 1 deletion cli/examples_python/interactive_usb_com.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -#-
from __future__ import print_function

'''
interactive_usb_com.py
Expand Down Expand Up @@ -33,6 +32,51 @@
'''

'''
About this software:
The AxiDraw writing and drawing machine is a product of Evil Mad Scientist
Laboratories. https://axidraw.com https://shop.evilmadscientist.com
This open source software is written and maintained by Evil Mad Scientist
to support AxiDraw users across a wide range of applications. Please help
support Evil Mad Scientist and open source software development by purchasing
genuine AxiDraw hardware.
AxiDraw software development is hosted at https://github.com/evil-mad/axidraw
Additional AxiDraw documentation is available at http://axidraw.com/docs
AxiDraw owners may request technical support for this software through our
github issues page, support forums, or by contacting us directly at:
https://shop.evilmadscientist.com/contact
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''

import sys
import time

Expand Down
3 changes: 1 addition & 2 deletions cli/examples_python/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -#-
from __future__ import print_function

'''
plot.py
Expand Down Expand Up @@ -48,7 +47,7 @@
Copyright 2020 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down
4 changes: 2 additions & 2 deletions cli/examples_python/plot_inline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -#-
from __future__ import print_function

'''
plot_inline.py
Expand Down Expand Up @@ -48,7 +47,7 @@
Copyright 2020 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -166,3 +165,4 @@
'''

ad.plot_run() # plot the document

2 changes: 1 addition & 1 deletion cli/examples_python/toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Copyright 2020 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2021 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down
19 changes: 10 additions & 9 deletions cli/requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
axidrawinternal @ git+https://${AXIDRAWINTERNAL_DEPLOY_USER}:${AXIDRAWINTERNAL_DEPLOY_PASS}@gitlab.com/evil-mad/AxiDraw-Internal@master
certifi==2021.5.30
chardet==3.0.4
certifi==2021.10.8
chardet==4.0.0
charset-normalizer==2.0.7
future==0.18.2
idna==2.10
ink-extensions>=1.1.0
lxml>=4.6.2
plotink>=1.3.1
pyserial>=3.5
requests==2.25.1
urllib3==1.26.5
idna==3.3
ink-extensions==1.1.0
lxml==4.6.4
plotink==1.4.0
pyserial==3.5
requests==2.26.0
urllib3==1.26.7
Loading

0 comments on commit 3fc7991

Please sign in to comment.