Skip to content
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

add a --version flag to otiopluginfo + otioconvert #880

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/py-opentimelineio/opentimelineio/console/otioconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

import opentimelineio as otio

# on some python interpreters, pkg_resources is not available
try:
import pkg_resources
except ImportError:
pkg_resources = None

__doc__ = """ Python wrapper around OTIO to convert timeline files between \
formats.

Expand All @@ -47,14 +53,14 @@ def _parsed_args():
'-i',
'--input',
type=str,
required=True,
required=False,
help='path to input file',
)
parser.add_argument(
'-o',
'--output',
type=str,
required=True,
required=False,
help='path to output file',
)
parser.add_argument(
Expand Down Expand Up @@ -130,6 +136,16 @@ def _parsed_args():
'key=value. Values are strings, numbers or Python literals: True, '
'False, etc. Can be used multiple times: -A burrito="bar" -A taco=12.'
)
parser.add_argument(
'--version',
default=False,
action="store_true",
help=(
"Print the otio and pkg_resource installed plugin version "
"information to the commandline and then exit."
),
)

trim_args = parser.add_argument_group(
title="Trim Arguments",
description="Arguments that allow you to trim the OTIO file."
Expand Down Expand Up @@ -157,6 +173,27 @@ def _parsed_args():

result = parser.parse_args()

# print version information to the shell
if result.version:
print("OpenTimelineIO version: {}".format(otio.__version__))

if pkg_resources:
pkg_resource_plugins = list(
pkg_resources.iter_entry_points("opentimelineio.plugins")
)
if pkg_resource_plugins:
print("Plugins from pkg_resources:")
for plugin in pkg_resource_plugins:
print(" {}".format(plugin.dist))
else:
print("No pkg_resource plugins installed.")
parser.exit()

if not result.input:
parser.error("-i/--input is a required argument")
if not result.output:
parser.error("-o/--output is a required argument")

if result.begin is not None and result.end is None:
parser.error("--begin requires --end.")
if result.end is not None and result.begin is None:
Expand Down
29 changes: 29 additions & 0 deletions src/py-opentimelineio/opentimelineio/console/otiopluginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
import textwrap
import opentimelineio as otio

# on some python interpreters, pkg_resources is not available
try:
import pkg_resources
except ImportError:
pkg_resources = None

OTIO_PLUGIN_TYPES = ['all'] + otio.plugins.manifest.OTIO_PLUGIN_TYPES

Expand Down Expand Up @@ -78,6 +83,15 @@ def _parsed_args():
nargs='?',
help='Only print information about plugins that match this glob.'
)
parser.add_argument(
'--version',
default=False,
action="store_true",
help=(
"Print the otio and pkg_resource installed plugin version "
"information to the commandline."
),
)

return parser.parse_args()

Expand Down Expand Up @@ -185,6 +199,21 @@ def main():
# load all the otio plugins
active_plugin_manifest = otio.plugins.ActiveManifest()

# print version information to the shell
if args.version:
print("OpenTimelineIO version: {}".format(otio.__version__))

if pkg_resources:
pkg_resource_plugins = list(
pkg_resources.iter_entry_points("opentimelineio.plugins")
)
if pkg_resource_plugins:
print("Plugins from pkg_resources:")
for plugin in pkg_resource_plugins:
print(" {}".format(plugin.dist))
else:
print("No pkg_resource plugins installed.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intent to not exit after printing version info and continue printing the usual info?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The thought was that this program is just dumping information about the installation anyway, so --version is an additive option and doesn't prevent printing everything else. Happy to change that if you think its too much of a break from expected behavior though.


# list the loaded manifests
print("Manifests loaded:")
for mf in active_plugin_manifest.source_files:
Expand Down