forked from tshort/dactyl-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python run script #38
Open
itised
wants to merge
10
commits into
joshreve:master
Choose a base branch
from
itised:python-run-script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
79e0513
added run.py as main entry point
itised 690f3bf
modularized model_builder.py
itised b8da966
WIP: modularizing dactyl_manuform.py
itised 58de8e9
more readable output
itised 458ccb6
lots of find/replace to continue modularization
itised 7b2f7d3
fixed global references
itised bd69551
import cadquery/solid for use in baseplate function
itised e872d8b
added export_file function
itised fb28078
fixed some find/replace errors
itised 2b20f57
ignore 'things' output is subdirectories
itised File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os.path as path | ||
import getopt, sys | ||
import src.argument_parser as parser | ||
|
||
args = parser.parse() | ||
|
||
if len(args['args']) < 1: | ||
print("A command must be specified") | ||
sys.exit(1) | ||
|
||
command = args['args'][0] | ||
if command not in ('help', 'generate', 'configure', 'realease'): | ||
print("Invalid command. Try 'help'") | ||
sys.exit(1) | ||
|
||
def show_usage(): | ||
print("Dactyl-Manuform Keyboard Generator") | ||
print("") | ||
print("Use this tool to configure and generate files for building a keyboard.") | ||
print("") | ||
print("") | ||
print("Usage:") | ||
print(" run.py [-d|--debug] [-u|--update] [--config <configuration-name>] <command>") | ||
print("") | ||
print("Available Commands:") | ||
print(" help Show this help") | ||
print(" release Run model_builder.py") | ||
print(" generate Output the keyboard files to the './things' directory") | ||
print(" configure Generate a configuration file with default values. The config") | ||
print(" file will be saved to configs/<configuration-name>. If the") | ||
print(" --config flag is not set, the default config_name will be used.") | ||
print("") | ||
print("Flags:") | ||
print(" --config Set the configuration file to use, relative to the './configs'") | ||
print(" directory.") | ||
print(" -u|--update Update a config file. This flag must be set if the config file") | ||
print(" already exists.") | ||
print(" -d|--debug Show debug output") | ||
print("") | ||
|
||
if command == 'help': | ||
show_usage() | ||
elif command == 'generate': | ||
import src.dactyl_manuform as command | ||
command.run(args) | ||
elif command == 'configure': | ||
import src.generate_configuration as command | ||
command.save_config(args) | ||
elif command == 'release': | ||
import src.model_builder as command | ||
command.run() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os.path as path | ||
import getopt, sys | ||
|
||
def parse(): | ||
# set defaults | ||
debug = False | ||
update = False | ||
config_name = 'DM' | ||
relative_path = r"."; | ||
file_name = "run_config" | ||
format = 'json' | ||
absolute_path = path.abspath(path.join(__file__, r"..", relative_path, file_name + r"." + format)) | ||
|
||
opts, args = getopt.getopt(sys.argv[1:], "ud", ["config=", "update", "debug"]) | ||
for opt, arg in opts: | ||
if opt in ('--config'): | ||
config_path_parts = arg.split(r'/') | ||
file_parts = config_path_parts.pop().split(r'.') | ||
|
||
file_name = file_parts[0] | ||
if len(file_parts) == 2: | ||
format = file_parts[1] | ||
|
||
config_name = file_name | ||
|
||
if len(config_path_parts) > 0: | ||
relative_path = path.join(*config_path_parts) | ||
|
||
absolute_path = path.abspath(path.join(__file__, r"..", r"..", "configs", relative_path, file_name + r"." + format)) | ||
elif opt in ('-u', "--update"): | ||
update = True | ||
elif opt in ('-d', "--debug"): | ||
debug = True | ||
|
||
|
||
if debug: | ||
print("CONFIG OPTIONS") | ||
print("config.name: " + config_name) | ||
print("config.relative_path: " + relative_path) | ||
print("config.file_name: " + file_name) | ||
print("config.format: " + format) | ||
print("config.absolute_path: " + absolute_path) | ||
print("update: " + str(update)) | ||
print("opts: " + str(opts)) | ||
print("args: " + str(args)) | ||
print("") | ||
|
||
return { | ||
'config': { | ||
'name': config_name, | ||
'relative_path': relative_path, | ||
'file_name': file_name, | ||
'format': format, | ||
'absolute_path': absolute_path | ||
}, | ||
'debug': debug, | ||
'update': update, | ||
'opts': opts, | ||
'args': args | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to ask, but have you considered to use internal python lib argparse instead of re implementing this?