mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
General: Small code cleanups (#5034)
* make sure the message type is set and unset correctly * Update dummy data in readme * remove debug message from main thread callbacks * removed unused import * cleanup code in muster addon * simplified 'get_publish_instance_label' function * even better json file handling Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com> --------- Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
This commit is contained in:
parent
5f98c27836
commit
6843ae8532
6 changed files with 20 additions and 39 deletions
|
|
@ -1,5 +1,3 @@
|
|||
import os
|
||||
|
||||
import requests
|
||||
from qtpy import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
import json
|
||||
|
||||
import appdirs
|
||||
import requests
|
||||
|
||||
from openpype.modules import OpenPypeModule, ITrayModule
|
||||
|
||||
|
||||
|
|
@ -110,16 +112,10 @@ class MusterModule(OpenPypeModule, ITrayModule):
|
|||
self.save_credentials(token)
|
||||
|
||||
def save_credentials(self, token):
|
||||
"""
|
||||
Save credentials to JSON file
|
||||
"""
|
||||
data = {
|
||||
'token': token
|
||||
}
|
||||
"""Save credentials to JSON file."""
|
||||
|
||||
file = open(self.cred_path, 'w')
|
||||
file.write(json.dumps(data))
|
||||
file.close()
|
||||
with open(self.cred_path, "w") as f:
|
||||
json.dump({'token': token}, f)
|
||||
|
||||
def show_login(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ from .contants import (
|
|||
TRANSIENT_DIR_TEMPLATE
|
||||
)
|
||||
|
||||
_ARG_PLACEHOLDER = object()
|
||||
|
||||
|
||||
def get_template_name_profiles(
|
||||
project_name, project_settings=None, logger=None
|
||||
|
|
@ -885,31 +883,24 @@ def add_repre_files_for_cleanup(instance, repre):
|
|||
instance.context.data["cleanupFullPaths"].append(expected_file)
|
||||
|
||||
|
||||
def get_publish_instance_label(instance, default=_ARG_PLACEHOLDER):
|
||||
def get_publish_instance_label(instance):
|
||||
"""Try to get label from pyblish instance.
|
||||
|
||||
First are checked 'label' and 'name' keys in instance data. If are not set
|
||||
a default value is returned. Instance object is converted to string
|
||||
if default value is not specific.
|
||||
First are used values in instance data under 'label' and 'name' keys. Then
|
||||
is used string conversion of instance object -> 'instance._name'.
|
||||
|
||||
Todos:
|
||||
Maybe 'subset' key could be used too.
|
||||
|
||||
Args:
|
||||
instance (pyblish.api.Instance): Pyblish instance.
|
||||
default (Optional[Any]): Default value to return if any
|
||||
|
||||
Returns:
|
||||
Union[Any]: Instance label or default label.
|
||||
str: Instance label.
|
||||
"""
|
||||
|
||||
label = (
|
||||
return (
|
||||
instance.data.get("label")
|
||||
or instance.data.get("name")
|
||||
or str(instance)
|
||||
)
|
||||
if label:
|
||||
return label
|
||||
|
||||
if default is _ARG_PLACEHOLDER:
|
||||
return str(instance)
|
||||
return default
|
||||
|
|
|
|||
|
|
@ -872,7 +872,6 @@ class WrappedCallbackItem:
|
|||
self.log.warning("- item is already processed")
|
||||
return
|
||||
|
||||
self.log.debug("Running callback: {}".format(str(self._callback)))
|
||||
try:
|
||||
result = self._callback(*self._args, **self._kwargs)
|
||||
self._result = result
|
||||
|
|
|
|||
|
|
@ -127,8 +127,7 @@ class OverlayMessageWidget(QtWidgets.QFrame):
|
|||
if timeout:
|
||||
self._timeout_timer.setInterval(timeout)
|
||||
|
||||
if message_type:
|
||||
set_style_property(self, "type", message_type)
|
||||
set_style_property(self, "type", message_type)
|
||||
|
||||
self._timeout_timer.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ Structure:
|
|||
- openpype/modules/MODULE_NAME - structure follow directory structure in code base
|
||||
- fixture - sample data `(MongoDB dumps, test files etc.)`
|
||||
- `tests.py` - single or more pytest files for MODULE_NAME
|
||||
- unit - quick unit test
|
||||
- MODULE_NAME
|
||||
- unit - quick unit test
|
||||
- MODULE_NAME
|
||||
- fixture
|
||||
- `tests.py`
|
||||
|
||||
|
||||
How to run:
|
||||
----------
|
||||
- use Openpype command 'runtests' from command line (`.venv` in ${OPENPYPE_ROOT} must be activated to use configured Python!)
|
||||
-- `python ${OPENPYPE_ROOT}/start.py runtests`
|
||||
|
||||
|
||||
By default, this command will run all tests in ${OPENPYPE_ROOT}/tests.
|
||||
|
||||
Specific location could be provided to this command as an argument, either as absolute path, or relative path to ${OPENPYPE_ROOT}.
|
||||
|
|
@ -41,17 +41,15 @@ In some cases your tests might be so localized, that you don't care about all en
|
|||
In that case you might add this dummy configuration BEFORE any imports in your test file
|
||||
```
|
||||
import os
|
||||
os.environ["AVALON_MONGO"] = "mongodb://localhost:27017"
|
||||
os.environ["OPENPYPE_DEBUG"] = "1"
|
||||
os.environ["OPENPYPE_MONGO"] = "mongodb://localhost:27017"
|
||||
os.environ["AVALON_DB"] = "avalon"
|
||||
os.environ["OPENPYPE_DATABASE_NAME"] = "openpype"
|
||||
os.environ["AVALON_TIMEOUT"] = '3000'
|
||||
os.environ["OPENPYPE_DEBUG"] = "3"
|
||||
os.environ["AVALON_CONFIG"] = "pype"
|
||||
os.environ["AVALON_DB"] = "avalon"
|
||||
os.environ["AVALON_TIMEOUT"] = "3000"
|
||||
os.environ["AVALON_ASSET"] = "Asset"
|
||||
os.environ["AVALON_PROJECT"] = "test_project"
|
||||
```
|
||||
(AVALON_ASSET and AVALON_PROJECT values should exist in your environment)
|
||||
|
||||
This might be enough to run your test file separately. Do not commit this skeleton though.
|
||||
Use only when you know what you are doing!
|
||||
Use only when you know what you are doing!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue