Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rocolibjill
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jillian Pantig
rocolibjill
Commits
6851a957
Commit
6851a957
authored
4 years ago
by
mehtank
Browse files
Options
Downloads
Patches
Plain Diff
more CLI options
parent
cc48280e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rocolib/__main__.py
+44
-7
44 additions, 7 deletions
rocolib/__main__.py
with
44 additions
and
7 deletions
rocolib/__main__.py
+
44
−
7
View file @
6851a957
#!/bin/env python
#!/bin/env python
import
sys
import
logging
import
logging
import
argparse
import
argparse
from
rocolib.library
import
getComponent
from
pprint
import
pprint
from
rocolib.library
import
getComponent
,
getComponentTree
from
rocolib.api.composables.graph.Joint
import
FingerJoint
from
rocolib.api.composables.graph.Joint
import
FingerJoint
...
@@ -26,15 +28,30 @@ if __name__ == '__main__':
...
@@ -26,15 +28,30 @@ if __name__ == '__main__':
DEFAULT_LOG_LEVEL
=
"
WARNING
"
DEFAULT_LOG_LEVEL
=
"
WARNING
"
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
component
"
,
help
=
"
Name of the component you
'
d like to test
"
)
parser
.
add_argument
(
"
--verbose
"
,
"
-v
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=-
1
)
cmd
=
parser
.
add_mutually_exclusive_group
(
required
=
True
)
parser
.
add_argument
(
"
--quiet
"
,
"
-q
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=
1
)
cmd
.
add_argument
(
"
component
"
,
nargs
=
'
?
'
,
parser
.
add_argument
(
"
-t
"
,
type
=
float
,
help
=
"
Thickness if you are making with wood
"
)
help
=
"
Name of the component you
'
d like to test (cannot be used with --list/-l)
"
)
cmd
.
add_argument
(
"
--list
"
,
"
-l
"
,
action
=
'
store_true
'
,
help
=
"
List all known library components (cannot be used with component)
"
)
parser
.
add_argument
(
"
--verbose
"
,
"
-v
"
,
help
=
"
Increase logging level (can be used multiple times)
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=-
1
)
parser
.
add_argument
(
"
--quiet
"
,
"
-q
"
,
help
=
"
Decrease logging level (can be used multiple times)
"
,
dest
=
"
log_level
"
,
action
=
"
append_const
"
,
const
=
1
)
parser
.
add_argument
(
"
-P
"
,
help
=
"
List component parameters (use multiple times for more detail)
"
,
dest
=
"
param_list
"
,
action
=
"
append_const
"
,
const
=
1
)
parser
.
add_argument
(
"
-t
"
,
type
=
float
,
help
=
"
Thickness (i.e. making with wood)
"
)
parser
.
add_argument
(
"
-d
"
,
action
=
'
store_true
'
,
help
=
"
Display 2D drawing
"
)
parser
.
add_argument
(
"
-d
"
,
action
=
'
store_true
'
,
help
=
"
Display 2D drawing
"
)
parser
.
add_argument
(
"
-D
"
,
action
=
'
store_true
'
,
help
=
"
Display 3D drawing
"
)
parser
.
add_argument
(
"
-D
"
,
action
=
'
store_true
'
,
help
=
"
Display 3D drawing
"
)
parser
.
add_argument
(
"
-
P
"
,
nargs
=
2
,
action
=
'
append
'
,
parser
.
add_argument
(
"
-
p
"
,
nargs
=
2
,
action
=
'
append
'
,
metavar
=
(
"
NAME
"
,
"
VALUE
"
),
metavar
=
(
"
NAME
"
,
"
VALUE
"
),
help
=
"
Set component parameter NAME to value VALUE
"
)
help
=
"
Set component parameter NAME to value VALUE
"
)
if
len
(
sys
.
argv
)
==
1
:
parser
.
print_help
(
sys
.
stderr
)
sys
.
exit
(
1
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
log_level
=
LOG_LEVELS
.
index
(
DEFAULT_LOG_LEVEL
)
log_level
=
LOG_LEVELS
.
index
(
DEFAULT_LOG_LEVEL
)
...
@@ -45,4 +62,24 @@ if __name__ == '__main__':
...
@@ -45,4 +62,24 @@ if __name__ == '__main__':
log_level_name
=
LOG_LEVELS
[
log_level
]
log_level_name
=
LOG_LEVELS
[
log_level
]
logging
.
basicConfig
(
level
=
getattr
(
logging
,
log_level_name
))
logging
.
basicConfig
(
level
=
getattr
(
logging
,
log_level_name
))
test
(
args
.
component
,
args
.
P
,
thickness
=
args
.
t
,
display
=
args
.
d
,
display3D
=
args
.
D
)
if
args
.
component
:
if
args
.
param_list
:
f
=
getComponent
(
args
.
component
)
info
=
f
.
getParameterInfo
()
if
len
(
args
.
param_list
)
==
1
:
print
(
"
\n
"
.
join
(
info
.
keys
()))
elif
len
(
args
.
param_list
)
==
2
:
pprint
({
k
:
v
[
'
defaultValue
'
]
for
k
,
v
in
info
.
items
()})
elif
len
(
args
.
param_list
)
==
3
:
pprint
({
k
:
{
x
:
v
[
x
]
for
x
in
(
'
defaultValue
'
,
'
spec
'
)}
for
k
,
v
in
info
.
items
()})
else
:
pprint
(
info
)
if
not
args
.
p
or
args
.
t
or
args
.
d
or
args
.
D
:
exit
(
0
)
test
(
args
.
component
,
args
.
p
,
thickness
=
args
.
t
,
display
=
args
.
d
,
display3D
=
args
.
D
)
elif
args
.
list
:
t
=
getComponentTree
()
for
i
,
cs
in
enumerate
(
t
):
chunks
=
[
cs
[
x
:
x
+
4
]
for
x
in
range
(
0
,
len
(
cs
),
4
)]
print
(
f
"
{
i
:
2
}
:
"
+
"
\n
"
.
join
((
"
"
.
join
(
x
)
for
x
in
chunks
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment