Bridges
Bridges allow you to load collection documents into external applications. It uses python snippets that are loaded dynamically.
Create
-
Access the "Bridges" Tab: Right-click anywhere inside.
-
Open the Actions Context Menu: Click on the actions context menu and select New
Update
-
The Module Path: Is the root to the location of the module this will always start from the DRIVE/ORGANIZATION/projects/
-
The Module Name: Is the name of the python module minus .py
-
Access Additional Parameters: For other parameters, click the item and go to the "Parameters" tab. Here, you can assign members to the item and make more detailed updates.
Modules
Are written in python and all require a main entry point that accepts one parameter data which will be a dictionary of the data for the loaded item.
def main(data):
print(data)
User side this is loaded in any application with
import sys
import os
try:
from importlib import reload
except Exception as e:
print(e)
# NOTE adjust depending on install
append_path = os.path.join("C:\\", "development", "cinestron", "bridge")
sys.path.append(append_path)
append_path = os.path.join("C:\\", "Program Files (x86)", "taskforger", "bridge")
sys.path.append(append_path)
import bridge as bridge
reload(bridge)
bridge.main()
The bridge.py handled connecting and fetching the data from the bridge queue and uses only built in python modules to ensure compatibility with any application that has a python api'
If you want to have a more controlled way of loading data this can be customized and pick from another deployment of code. Basically not using the module_path and module_name. But you can still leverage the user selected loading from within Taskforger.
...
def get_bridge(self, in_dict):
result = {}
status_code = 200
if self.token == "":
print("no token")
return result
try:
req = session.Request(
f"{self.local_server_address}/api/post/bridge_data",
method="POST",
data=json.dumps(in_dict).encode("utf-8"),
headers=self.headers,
)
with session.urlopen(req) as r:
status_code = r.getcode()
if status_code == 200:
result = json.loads(r.read().decode("utf-8"))
elif status_code == 403:
print("error", status_code)
result = {}
else:
print("error", status_code)
result = {}
except urllib.error.URLError as e:
print(e)
return result
def load(self):
result = self.get_bridge({"value": "get_pop_queue"})
if result != {}:
bridge = result.get("bridge")
if bridge == None:
print("No bridge data", result)
return
module_root = result.get("module_root", "")
module_path = os.path.join(module_root, bridge.get("module_path", ""))
module_name = bridge.get("module_name", "")
print(module_path, module_name)
if module_path not in sys.path:
sys.path.append(module_path)
try:
# Use import_module to dynamically import the module
your_module = importlib.import_module(module_name)
reload(your_module)
# Now you can use the functions, classes, etc., from your dynamically loaded module
your_module.main(result)
except ImportError:
print(f"Error: Module {module_name} not found.")
# recurse
self.load()
else:
print("Nothing to load, check app")
...