diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..745cc7a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,58 @@ +name: Create Release on QA to Master Merge + +on: + pull_request: + branches: + - main + - master + types: + - closed + +jobs: + create_release: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Read version from package.json + id: get_version + run: echo "VERSION=$(jq -r '.version' package.json)" >> "$GITHUB_OUTPUT" + + - name: Read module name + id: get_name + run: echo "MODULE_NAME=$(jq -r '.name' package.json)" >> "$GITHUB_OUTPUT" + + - name: Extract commit message + id: extract_commit_message + run: echo "MESSAGE=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }})" >> "$GITHUB_OUTPUT" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: Release_${{ steps.get_version.outputs.VERSION }} + release_name: Release ${{ steps.get_version.outputs.VERSION }} + body: ${{ steps.extract_commit_message.outputs.MESSAGE }} + draft: false + prerelease: false + - name: Module Information + uses: fjogeleit/http-request-action@v1 + id: module_info + with: + url: 'https://market-api.rocketbot.com/modules/${{ steps.get_name.outputs.MODULE_NAME }}' + method: 'POST' + + - name: Module ID + id: module_id + run: echo "MODULE_ID=${{ fromJson(steps.module_info.outputs.response).data.id }}" >> "$GITHUB_OUTPUT" + + - name: Update module in Market + uses: fjogeleit/http-request-action@v1 + id: update_module + with: + url: 'https://market-api.rocketbot.com/modules/update/${{ steps.module_id.outputs.MODULE_ID }}' + method: 'POST' \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..745cc7a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Create Release on QA to Master Merge + +on: + pull_request: + branches: + - main + - master + types: + - closed + +jobs: + create_release: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Read version from package.json + id: get_version + run: echo "VERSION=$(jq -r '.version' package.json)" >> "$GITHUB_OUTPUT" + + - name: Read module name + id: get_name + run: echo "MODULE_NAME=$(jq -r '.name' package.json)" >> "$GITHUB_OUTPUT" + + - name: Extract commit message + id: extract_commit_message + run: echo "MESSAGE=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }})" >> "$GITHUB_OUTPUT" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: Release_${{ steps.get_version.outputs.VERSION }} + release_name: Release ${{ steps.get_version.outputs.VERSION }} + body: ${{ steps.extract_commit_message.outputs.MESSAGE }} + draft: false + prerelease: false + - name: Module Information + uses: fjogeleit/http-request-action@v1 + id: module_info + with: + url: 'https://market-api.rocketbot.com/modules/${{ steps.get_name.outputs.MODULE_NAME }}' + method: 'POST' + + - name: Module ID + id: module_id + run: echo "MODULE_ID=${{ fromJson(steps.module_info.outputs.response).data.id }}" >> "$GITHUB_OUTPUT" + + - name: Update module in Market + uses: fjogeleit/http-request-action@v1 + id: update_module + with: + url: 'https://market-api.rocketbot.com/modules/update/${{ steps.module_id.outputs.MODULE_ID }}' + method: 'POST' \ No newline at end of file diff --git a/__init__.py b/__init__.py index 7442e66..d4f820d 100644 --- a/__init__.py +++ b/__init__.py @@ -76,6 +76,7 @@ "moveCursorRight": "moveCursorRight", "moveCursorUp": "moveCursorUp", "moveTo": "moveTo", + "home": "moveToFirstInputField", "tab": "sendTab" } @@ -98,7 +99,7 @@ protocol = GetParams('protocol') show = GetParams('show') config = GetParams('config') - + model = GetParams('model') result = GetParams('result') try: @@ -106,17 +107,21 @@ port = '23' if not config: config = None - + if not model: + model = '3279-2' path = path = BASE_PATH + 'modules' + os.sep + 'Terminal_emulator' + os.sep + 'bin' + os.sep + "3270" + os.sep args = { "hostName": host, "hostPort": port, "configFile": config, - "path": path + "path": path, + "verifyCert": "no", + "modelName": model } if protocol == "tls": args["enableTLS"] = "yes" + args["verifyCert"] = "no" terminal_simulator = create_terminal(terminal_type, **args) terminal_log_path = LOG_PATH + session + ".txt" @@ -127,7 +132,7 @@ } connected = terminal_simulator.connect() - + print("connected: ", connected) if show and show == "True": print([APP_PATH, "-l=" + terminal_log_path]) process = subprocess.Popen([APP_PATH, "-l=" + terminal_log_path], shell=True) @@ -211,18 +216,27 @@ try: # This is for Terminal Type 5250 getattr(terminal_simulator, function)(*number) + except: # This is for Terminal Type 3270 - number = number[0] - if 0 < number < 13: - terminal_simulator.p3270.sendPA(1) - terminal_simulator.p3270.sendPF(number) - elif 12 < number < 25: - terminal_simulator.p3270.sendPA(2) - terminal_simulator.p3270.sendPF(number) + number = number[0] if number else None + if number is not None: + if 0 < number < 13: + terminal_simulator.sendPA(1) + terminal_simulator.sendPF(number) + elif 12 < number < 25: + terminal_simulator.sendPA(2) + terminal_simulator.sendPF(number) + else: + getattr(terminal_simulator, function)() elif params_keys: for key in params_keys: - terminal_simulator.p3270.s3270.do("Key({})".format(key[0])) + try: + # This is for Terminal Type 5250 + terminal_simulator.p3270.s3270.do("Key({})".format(key[0])) + except: + # This is for Terminal Type 3270 + terminal_simulator.s3270.do("Key({})".format(key[0])) if module == "move_cursor": position = GetParams('position') @@ -270,7 +284,12 @@ result = GetParams("result") screen = terminal_simulator.getScreen - cursor = terminal_simulator.p3270.s3270.statusMsg.cursorPosition + try: + # This is for Terminal Type 5250 + cursor = terminal_simulator.p3270.s3270.statusMsg.cursorPosition + except: + # This is for Terminal Type 3270 + cursor = terminal_simulator.s3270.statusMsg.cursorPosition connected = False now = 0 if option == "appears": @@ -286,7 +305,7 @@ while text != cursor() and now - start <= int(wait): sleep(1) now = ProcessTime() - if now - start > int(wait): + if now - start < int(wait): connected = True if result: SetVar(result, connected) @@ -295,6 +314,7 @@ create_log(terminal_simulator, terminal_log_path) except Exception as e: - PrintException() + import traceback + traceback.print_exc() raise e diff --git a/docs/Manual_Terminal_emulator.es.md b/docs/Manual_Terminal_emulator.es.md index 840151a..d220dea 100644 --- a/docs/Manual_Terminal_emulator.es.md +++ b/docs/Manual_Terminal_emulator.es.md @@ -27,6 +27,7 @@ Conecta con una terminal |Host||localhost| |Port||23| |Tipo de terminal||| +|Modelo de terminal||| |Protocolo de seguridad||| |Mostrar terminal|Si se marca, se mostrara una terminal para revisar ejecuciones del robot. Herramienta para desarollo.|| |Archivo de configuración||c:/wc3270/conf.ini| diff --git a/docs/Manual_Terminal_emulator.md b/docs/Manual_Terminal_emulator.md index be28616..9bc2f5f 100644 --- a/docs/Manual_Terminal_emulator.md +++ b/docs/Manual_Terminal_emulator.md @@ -27,6 +27,7 @@ Connect to terminal |Host||localhost| |Port||23| |Terminal type||| +|Terminal Model||| |Safety protocol||| |Show terminal|If checked, a terminal will be displayed to review robot executions. Development tool.|| |Configuration file||c:/wc3270/conf.ino| diff --git a/example/Manual_Terminal_emulator.pdf b/example/Manual_Terminal_emulator.pdf index 94849f6..2077c68 100644 Binary files a/example/Manual_Terminal_emulator.pdf and b/example/Manual_Terminal_emulator.pdf differ diff --git a/libs/p3270/p3270.py b/libs/p3270/p3270.py index e7275bb..b3d980e 100644 --- a/libs/p3270/p3270.py +++ b/libs/p3270/p3270.py @@ -88,9 +88,9 @@ class P3270Client(): configuration file is specified. Default values will be used. """ numOfInstances = 0 - + def __init__(self, luName=None, hostName='localhost', hostPort='23', modelName='3279-2', configFile=None, - verifyCert='yes', enableTLS='no', codePage='cp037', path=None, timeoutInSec=20): + verifyCert='no', enableTLS='no', codePage='cp037', path=None, timeoutInSec=20): self.luName = luName self.hostName = hostName self.hostPort = hostPort @@ -101,7 +101,7 @@ def __init__(self, luName=None, hostName='localhost', hostPort='23', modelName=' self.timeout = timeoutInSec self.path = path self.conf = Config(cfgFile=self.configFile, hostName=self.hostName, - hostPort=self.hostPort, luName=self.luName, modelName=self.modelName, codePage=codePage) + hostPort=self.hostPort, luName=self.luName, modelName=self.modelName, codePage=codePage, enableTLS=self.enableTLS, verifyCert=self.verifyCert) if self.conf.isValid(): self.subpro = None self.makeArgs() @@ -117,7 +117,6 @@ def makeArgs(self): self.args = ['s3270'] if self.path is not None: self.args = [self.path + 's3270'] - if self.conf.isValid(): self.args.append('-model') self.args.append(self.conf.modelName) diff --git a/package.json b/package.json index 062853f..6ebce98 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "pr": "Este módulo permite realizar ações em um emulador de terminal, como conectar, enviar texto, enviar chaves, mover o cursor, etc." }, "disclaimer": "THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.", - "version": "2.2.4", + "version": "2.2.8", "license": "MIT", "homepage": "http://rocketbot.com", "linux": true, @@ -99,6 +99,57 @@ "id": "type", "css": "col-md-4" }, + { + "type": "select", + "options": [ + { + "title": "--Seleccione--", + "value": "" + }, + { + "title": "3278-2 (80x24)", + "value": "3278-2" + }, + { + "title": "3278-3 (80x32)", + "value": "3278-3" + }, + { + "title": "3278-4 (80x43)", + "value": "3278-4" + }, + { + "title": "3278-5 (132x27)", + "value": "3278-5" + }, + { + "title": "3279-2 (80x24)", + "value": "3279-2" + }, + { + "title": "3279-3 (80x32)", + "value": "3279-3" + }, + { + "title": "3279-4 (80x43)", + "value": "3279-4" + }, + { + "title": "3279-5 (132x27)", + "value": "3279-5" + } + ], + "title": { + "es": "Modelo de terminal", + "en": "Terminal Model" + }, + "help": { + "es": "Por defecto 3279-2. El modelo base 3278 es una pantalla 3270 verde sobre negro, mientras que el modelo base 3279 es una pantalla 3270 a color. Los números de modelo se utilizan para especificar la definición de la pantalla (filas y columnas).", + "en": "By default 3279-2. The base model 3278 is a green on black 3270 display, whereas 3279 base model is a color 3270 display. Model numbers are used to specify the screen definition (rows and columns)." + }, + "id": "model", + "css": "col-md-4" + }, { "type": "select", "options": [ @@ -289,6 +340,10 @@ "title": "--Seleccione--", "value": "" }, + { + "title": "Home", + "value": "home" + }, { "title": "BackSpace", "value": "backSpace"