예제 #1
0
def test_5250():
    cmd = 'WRKACTJOB'
    key = 'lljqezl'

    element = ET.fromstring(iCmd5250(key, cmd).xml_in())
    assert(element.tag == 'sh')

    assert('error' in element.attrib)
    assert(element.attrib['error'] == 'fast')

    assert('var' in element.attrib)
    assert(element.attrib['var'] == key)

    assert(element.text == to5250(cmd))
예제 #2
0
def test_5250_row_off():
    cmd = 'WRKACTJOB'
    key = 'lkjwernm'
    row = 'off'

    element = ET.fromstring(iCmd5250(key, cmd, {'row': row}).xml_in())
    assert(element.tag == 'sh')

    assert('row' in element.attrib)
    assert(element.attrib['row'] == row)

    assert('var' in element.attrib)
    assert(element.attrib['var'] == key)

    assert(element.text == to5250(cmd))
예제 #3
0
def test_5250_error_off():
    cmd = 'WRKACTJOB'
    key = 'lkjwernm'
    error = 'off'

    element = ET.fromstring(iCmd5250(key, cmd, {'error': error}).xml_in())
    assert(element.tag == 'sh')

    assert('error' in element.attrib)
    assert(element.attrib['error'] == error)

    assert('var' in element.attrib)
    assert(element.attrib['var'] == key)

    assert(element.text == to5250(cmd))
예제 #4
0
def test_5250_space():
    cmd = 'WRKACTJOB SBS(*QINTER)'
    key = 'lknwqekrn'

    element = ET.fromstring(iCmd5250(key, cmd).xml_in())
    assert (element.tag == 'sh')

    assert ('error' in element.attrib)
    assert (element.attrib['error'] == 'fast')

    assert ('var' in element.attrib)
    assert (element.attrib['var'] == key)

    assert (
        element.text == "/QOpenSys/usr/bin/system 'WRKACTJOB SBS(*QINTER)'")
예제 #5
0
def test_5250_row_on():
    cmd = 'WRKACTJOB'
    key = 'rtoiu1nqew'
    row = 'on'

    element = ET.fromstring(iCmd5250(key, cmd, {'row': row}).xml_in())
    assert (element.tag == 'sh')

    assert ('row' in element.attrib)
    assert (element.attrib['row'] == row)

    assert ('var' in element.attrib)
    assert (element.attrib['var'] == key)

    assert (element.text == "/QOpenSys/usr/bin/system WRKACTJOB")
예제 #6
0
def test_5250_error_on():
    cmd = 'WRKACTJOB'
    key = 'rtoiu1nqew'
    error = 'on'

    element = ET.fromstring(iCmd5250(key, cmd, {'error': error}).xml_in())
    assert (element.tag == 'sh')

    assert ('error' in element.attrib)
    assert (element.attrib['error'] == error)

    assert ('var' in element.attrib)
    assert (element.attrib['var'] == key)

    assert (element.text == "/QOpenSys/usr/bin/system WRKACTJOB")
예제 #7
0
def test_5250_inner_string():
    cmd = "wrklnk '/test/file'"
    key = 'znxvlkja'

    element = ET.fromstring(iCmd5250(key, cmd).xml_in())
    assert (element.tag == 'sh')

    assert ('error' in element.attrib)
    assert (element.attrib['error'] == 'fast')

    assert ('var' in element.attrib)
    assert (element.attrib['var'] == key)

    assert (element.text ==
            """/QOpenSys/usr/bin/system 'wrklnk '"'"'/test/file'"'"''""")
예제 #8
0
    def itoolkit_run_command5250(self, command):
        '''IBM i XMLSERVICE call 5250 *CMD returning *OUTPUT'''
        itool = iToolKit()
        itransport = DatabaseTransport(self.conn)
        if command:
            command = command.upper().replace('OUTPUT(*)', '')
        itool.add(iCmd5250('command', command))
        itool.call(itransport)
        command_output = itool.dict_out('command')
        ibmi_util.log_debug("command_output " + str(command_output), sys._getframe().f_code.co_name)

        out = ''
        err = ''

        if 'error' in command_output:
            rc = ibmi_util.IBMi_COMMAND_RC_ERROR
            err = str(command_output)
        else:
            rc = ibmi_util.IBMi_COMMAND_RC_SUCCESS
            out = str(command_output['command'])
        return rc, out, err