Hi
I'm working on hooking into the publish, loader and workfiles apps to transfer files to and from our amazon s3 account as needed. My idea was to create a new framework that would be used by other apps to handle the connection and transfer. That would in turn use the tk-framework-login to handle the credentials. I was hoping to do most (if not all) of the work using hooks of existing apps, such as the copy_file hook for tk-multi-publish.
Now to the question at hand, what is the best way to use a framework from inside a hook? I've added my framework to the environment but I can't use the usual tank.platform.import_framework() inside a hook.
Right now I'm doing the following ugly hack:
frameworks_to_load = [{"name": "mg-framework-aws", "version": "v0.0.1"}] frameworks = dict() def _load_frameworks(): engine = tank.platform.engine.current_engine() # This will fail if tank.platform.validation.validate_and_return_frameworks # calls something else of descriptor than get_required_frameworks descriptor = type("descriptorhack", (object,),{"get_required_frameworks": (lambda x: frameworks_to_load)}) env = engine.get_env() load_frameworks = tank.platform.validation.validate_and_return_frameworks(descriptor(), env) for load_framework in load_frameworks: framework = tank.platform.framework.load_framework(engine, env, load_framework) frameworks[framework.name] = framework _load_frameworks() login = frameworks["mg-framework-aws"].import_module("login")