added verbose and debug to global click options and removed debug from each individual callback

This commit is contained in:
Jakub Trllo 2022-04-22 12:52:11 +02:00
parent 1b3026bdc7
commit e1995e8828
2 changed files with 19 additions and 38 deletions

View file

@ -20,6 +20,10 @@ from .pype_commands import PypeCommands
"to list staging versions.")) "to list staging versions."))
@click.option("--validate-version", expose_value=False, @click.option("--validate-version", expose_value=False,
help="validate given version integrity") help="validate given version integrity")
@click.option("--debug", is_flag=True, expose_value=False,
help=("Enable debug"))
@click.option("--verbose", expose_value=False,
help=("Change OpenPype log level (debug - critical or 0-50)"))
def main(ctx): def main(ctx):
"""Pype is main command serving as entry point to pipeline system. """Pype is main command serving as entry point to pipeline system.
@ -49,18 +53,13 @@ def traypublisher():
@main.command() @main.command()
@click.option("-d", "--debug", def tray():
is_flag=True, help=("Run pype tray in debug mode"))
def tray(debug=False):
"""Launch pype tray. """Launch pype tray.
Default action of pype command is to launch tray widget to control basic Default action of pype command is to launch tray widget to control basic
aspects of pype. See documentation for more information. aspects of pype. See documentation for more information.
Running pype with `--debug` will result in lot of information useful for
debugging to be shown in console.
""" """
PypeCommands().launch_tray(debug) PypeCommands().launch_tray()
@PypeCommands.add_modules @PypeCommands.add_modules
@ -75,7 +74,6 @@ def module(ctx):
@main.command() @main.command()
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("--ftrack-url", envvar="FTRACK_SERVER", @click.option("--ftrack-url", envvar="FTRACK_SERVER",
help="Ftrack server url") help="Ftrack server url")
@click.option("--ftrack-user", envvar="FTRACK_API_USER", @click.option("--ftrack-user", envvar="FTRACK_API_USER",
@ -88,8 +86,7 @@ def module(ctx):
help="Clockify API key.") help="Clockify API key.")
@click.option("--clockify-workspace", envvar="CLOCKIFY_WORKSPACE", @click.option("--clockify-workspace", envvar="CLOCKIFY_WORKSPACE",
help="Clockify workspace") help="Clockify workspace")
def eventserver(debug, def eventserver(ftrack_url,
ftrack_url,
ftrack_user, ftrack_user,
ftrack_api_key, ftrack_api_key,
legacy, legacy,
@ -100,8 +97,6 @@ def eventserver(debug,
This should be ideally used by system service (such us systemd or upstart This should be ideally used by system service (such us systemd or upstart
on linux and window service). on linux and window service).
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands().launch_eventservercli( PypeCommands().launch_eventservercli(
ftrack_url, ftrack_url,
@ -114,12 +109,11 @@ def eventserver(debug,
@main.command() @main.command()
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("-h", "--host", help="Host", default=None) @click.option("-h", "--host", help="Host", default=None)
@click.option("-p", "--port", help="Port", default=None) @click.option("-p", "--port", help="Port", default=None)
@click.option("-e", "--executable", help="Executable") @click.option("-e", "--executable", help="Executable")
@click.option("-u", "--upload_dir", help="Upload dir") @click.option("-u", "--upload_dir", help="Upload dir")
def webpublisherwebserver(debug, executable, upload_dir, host=None, port=None): def webpublisherwebserver(executable, upload_dir, host=None, port=None):
"""Starts webserver for communication with Webpublish FR via command line """Starts webserver for communication with Webpublish FR via command line
OP must be congigured on a machine, eg. OPENPYPE_MONGO filled AND OP must be congigured on a machine, eg. OPENPYPE_MONGO filled AND
@ -127,8 +121,6 @@ def webpublisherwebserver(debug, executable, upload_dir, host=None, port=None):
Expect "pype.club" user created on Ftrack. Expect "pype.club" user created on Ftrack.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands().launch_webpublisher_webservercli( PypeCommands().launch_webpublisher_webservercli(
upload_dir=upload_dir, upload_dir=upload_dir,
@ -164,38 +156,34 @@ def extractenvironments(output_json_path, project, asset, task, app, envgroup):
@main.command() @main.command()
@click.argument("paths", nargs=-1) @click.argument("paths", nargs=-1)
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("-t", "--targets", help="Targets module", default=None, @click.option("-t", "--targets", help="Targets module", default=None,
multiple=True) multiple=True)
@click.option("-g", "--gui", is_flag=True, @click.option("-g", "--gui", is_flag=True,
help="Show Publish UI", default=False) help="Show Publish UI", default=False)
def publish(debug, paths, targets, gui): def publish(paths, targets, gui):
"""Start CLI publishing. """Start CLI publishing.
Publish collects json from paths provided as an argument. Publish collects json from paths provided as an argument.
More than one path is allowed. More than one path is allowed.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands.publish(list(paths), targets, gui) PypeCommands.publish(list(paths), targets, gui)
@main.command() @main.command()
@click.argument("path") @click.argument("path")
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("-h", "--host", help="Host") @click.option("-h", "--host", help="Host")
@click.option("-u", "--user", help="User email address") @click.option("-u", "--user", help="User email address")
@click.option("-p", "--project", help="Project") @click.option("-p", "--project", help="Project")
@click.option("-t", "--targets", help="Targets", default=None, @click.option("-t", "--targets", help="Targets", default=None,
multiple=True) multiple=True)
def remotepublishfromapp(debug, project, path, host, user=None, targets=None): def remotepublishfromapp(project, path, host, user=None, targets=None):
"""Start CLI publishing. """Start CLI publishing.
Publish collects json from paths provided as an argument. Publish collects json from paths provided as an argument.
More than one path is allowed. More than one path is allowed.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands.remotepublishfromapp( PypeCommands.remotepublishfromapp(
project, path, host, user, targets=targets project, path, host, user, targets=targets
) )
@ -203,24 +191,21 @@ def remotepublishfromapp(debug, project, path, host, user=None, targets=None):
@main.command() @main.command()
@click.argument("path") @click.argument("path")
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("-u", "--user", help="User email address") @click.option("-u", "--user", help="User email address")
@click.option("-p", "--project", help="Project") @click.option("-p", "--project", help="Project")
@click.option("-t", "--targets", help="Targets", default=None, @click.option("-t", "--targets", help="Targets", default=None,
multiple=True) multiple=True)
def remotepublish(debug, project, path, user=None, targets=None): def remotepublish(project, path, user=None, targets=None):
"""Start CLI publishing. """Start CLI publishing.
Publish collects json from paths provided as an argument. Publish collects json from paths provided as an argument.
More than one path is allowed. More than one path is allowed.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands.remotepublish(project, path, user, targets=targets) PypeCommands.remotepublish(project, path, user, targets=targets)
@main.command() @main.command()
@click.option("-d", "--debug", is_flag=True, help="Print debug messages")
@click.option("-p", "--project", required=True, @click.option("-p", "--project", required=True,
help="name of project asset is under") help="name of project asset is under")
@click.option("-a", "--asset", required=True, @click.option("-a", "--asset", required=True,
@ -228,7 +213,7 @@ def remotepublish(debug, project, path, user=None, targets=None):
@click.option("--path", required=True, @click.option("--path", required=True,
help="path where textures are found", help="path where textures are found",
type=click.Path(exists=True)) type=click.Path(exists=True))
def texturecopy(debug, project, asset, path): def texturecopy(project, asset, path):
"""Copy specified textures to provided asset path. """Copy specified textures to provided asset path.
It validates if project and asset exists. Then it will use speedcopy to It validates if project and asset exists. Then it will use speedcopy to
@ -239,8 +224,7 @@ def texturecopy(debug, project, asset, path):
Result will be copied without directory structure so it will be flat then. Result will be copied without directory structure so it will be flat then.
Nothing is written to database. Nothing is written to database.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands().texture_copy(project, asset, path) PypeCommands().texture_copy(project, asset, path)
@ -389,11 +373,9 @@ def runtests(folder, mark, pyargs, test_data_folder, persist, app_variant,
@main.command() @main.command()
@click.option("-d", "--debug",
is_flag=True, help=("Run process in debug mode"))
@click.option("-a", "--active_site", required=True, @click.option("-a", "--active_site", required=True,
help="Name of active stie") help="Name of active stie")
def syncserver(debug, active_site): def syncserver(active_site):
"""Run sync site server in background. """Run sync site server in background.
Some Site Sync use cases need to expose site to another one. Some Site Sync use cases need to expose site to another one.
@ -408,8 +390,7 @@ def syncserver(debug, active_site):
Settings (configured by starting OP Tray with env Settings (configured by starting OP Tray with env
var OPENPYPE_LOCAL_ID set to 'active_site'. var OPENPYPE_LOCAL_ID set to 'active_site'.
""" """
if debug:
os.environ["OPENPYPE_DEBUG"] = "1"
PypeCommands().syncserver(active_site) PypeCommands().syncserver(active_site)

View file

@ -25,7 +25,7 @@ class PypeCommands:
Most of its methods are called by :mod:`cli` module. Most of its methods are called by :mod:`cli` module.
""" """
@staticmethod @staticmethod
def launch_tray(debug=False): def launch_tray():
PypeLogger.set_process_name("Tray") PypeLogger.set_process_name("Tray")
from openpype.tools import tray from openpype.tools import tray