Tangram
语言
  • What is Tangram?
  • overview
    • Capabilities
    • Architecture
  • Install
    • Start with Kubernetes
  • quick start
    • Create a flow
    • Create a tool
  • Flow
    • Nodes
      • IF
      • SWITCH
      • Format
      • Count
      • Subflow
      • Conversion
      • Execution
      • Variable
      • Note
      • Error
      • Response
    • Datasources
      • Node
      • Form
      • Variable
      • Webhooks
      • Inputs(Subflow)
      • Base
  • triggers
    • Forms
      • Text
      • Textarea
      • Number
      • Date
      • Radio
      • Checkbox
      • Single Selection
      • Multi Selection
      • File
      • Title and Content
    • Webhooks
    • Crons
  • APP Development
    • template
    • info.json
    • core.py
    • test.py
    • Upload and Debugging
Powered by GitBook
On this page
  1. APP Development

core.py

App module developed based on Django 3.

AppBase is the root class for the app.

Programming

from utils.appbase import AppBase
import os, sys

'''
Install the required dependency packages for the application under libs in the application folder. (install the dependency packages in the actual running environment)
Hot updates can be achieved through system upload after packaging.
'''

basedir = os.path.dirname(os.path.abspath(__file__))
libdir = os.path.join(basedir, "libs")
sys.path.insert(0, libdir)

from jira import JIRA

class Jira(AppBase):
    def __init__(self, params):
        super(Jira, self).__init__(params)
        self.__server = params.get("server")
        self.__email = params.get("email")
        self.__api_token = params.get("api_token")
        if self.__email and self.__api_token:
            self.__client = JIRA(server=self.__server, basic_auth=(self.__email, self.__api_token))
        else:
            self.__client = JIRA(server=self.__server, token_auth=self.__api_token)

    def _test(self, params):
        return self.__client.session().name

    def _get_projects(self, params):
        return list(map(lambda x: x.raw, self.__client.projects()))

    def _get_project(self, params):
        '''
        1) Params is the action parameters configured in info.json.
        2) The actual call will verify the parameter type and whether it is required.
        3) Directly input the returned results, and the AppBase class uniformly handles the return format and exceptions.
        '''
        return self.__client.project(params.get("key")).raw
Previousinfo.jsonNexttest.py

Last updated 10 months ago