示例#1
0
def readFromU2():
	filename = request.args.get('filename')
	print(filename)
	try:
		f=u2py.File(filename)
	except u2py.U2Error as e:
		return {'status':404,'msg':"File Not Found"}
	sub=u2py.Subroutine("TEST2",4)
	sub.args[0]=""
	sub.args[1]=filename
	sub.args[2]=""
	sub.args[3]=""
	sub.call()
	fieldData=sub.args
	return{"table":fieldData[0].to_list()},200
示例#2
0
def genuniquekey(filename, mask):
    # get the UniVerse imports
    import os
    os.chdir("C:\\U2\\XDEMO\\pythonbetarocket")
    import u2py

    sub = u2py.Subroutine("GEN.UNIQUE.KEY", 5)
    sub.args[0] = filename
    sub.args[1] = mask
    sub.call()
    if str(sub.args[3]) != "0":
        print("Error!!!! " + str(sub.args[4]))
    else:
        newkey = str(sub.args[2])
        return newkey
示例#3
0
    def run(self, args):
        orderId = ''

        if 'client' in args:
            U2_BOOKS = u2py.File("U2_BOOKS")
            U2_SHIPPING = u2py.File("U2_SHIPPING")
            order = u2py.DynArray()
            order.replace(1, args['client'])
            order.replace(2, 'NEW')  # order status
            if 'deliv_addr' in args:
                order.replace(3, args['deliv_addr'])
            order.replace(4, 'WEB')  # origin
            if 'ship_id' in args:
                shipId = args['ship_id']
            else:
                shipId = 'FREE'

            order.replace(5, shipId)  # shipping type
            shipRec = U2_SHIPPING.read(shipId)
            order.replace(6, str(shipRec.extract(2)))  # shipping cost
            ct = 0
            for id in args['books']:
                ct = ct + 1
                order.replace(10, ct, id)  # book key
                bookRec = U2_BOOKS.read(id)
                order.replace(11, ct, '1')  # qty
                order.replace(12, ct, str(bookRec.extract(8)))  # price
                order.replace(13, ct, str(bookRec.extract(12)))  # tax code
            sub = u2py.Subroutine("u2_setSalesOrder", 3)
            sub.args[0] = ''
            sub.args[1] = order
            sub.call()
            orderId = str(sub.args[0])
            errText = str(sub.args[2])
        else:
            errText = 'Missing cart details'

        return {'order': orderId, 'error': errText}
示例#4
0
def CALL_BASIC(routine, *args):
    '''
    routine - is the cataloged subroutine name.
    *args   - arguments to pass to the subroutine.

    Note this function returns a tuple with the same number of elements
    as arguments passed in for *args.
    '''
    the_subroutine = u2py.Subroutine(routine, len(args))
    cnt = 0
    #    type_list = []
    for each in args:
        #        type_list[cnt] = type(args[cnt])
        the_subroutine.args[cnt] = args[cnt]
        cnt += 1

    the_subroutine.call()
    out_args = []
    for out_var in range(0, cnt):
        thisDyn = the_subroutine.args[out_var]
        try:
            outValue = int(thisDyn)
        except ValueError:
            try:
                outValue = float(thisDyn)
            except ValueError:
                delim = thisDyn.count(u2py.FM) + thisDyn.count(
                    u2py.VM) + thisDyn.count(u2py.SM)
                if delim == 0:
                    try:
                        outValue = str(thisDyn)
                    except ValueError:
                        outValue = thisDyn
                else:
                    outValue = thisDyn
        out_args.append(outValue)
    #
    return out_args
示例#5
0
 def run(self, args):
     results = {}
     if "id" in args:
         id = args["id"][0]
         sub = u2py.Subroutine("u2_getBookDataEx", 4)
         sub.args[0] = id
         sub.args[1] = '0'
         sub.call()
         bookData = sub.args[2]
         errText = sub.args[3]
         results = {
             'id': id,
             'title': str(bookData.extract(1)),
             'author': str(bookData.extract(3)),
             'isbn': str(bookData.extract(4)),
             'dept': str(bookData.extract(5)),
             'genre': str(bookData.extract(6)),
             'media': str(bookData.extract(7)),
             'publisher': str(bookData.extract(9)),
             'price': str(bookData.extract(10)),
             'tax_rate': str(bookData.extract(16)),
             'description': str(bookData.extract(20))
         }
     return results
示例#6
0
def validateid(check_id):
    sub = u2py.Subroutine('VALIDATE_MEMBERS_ID', 4)
    sub.args[0] = check_id
    sub.call()
    if str(sub.args[2]) != '0':
        raise forms.ValidationError('Error! ' + str(sub.args[3]))
示例#7
0
####################################################
# Copyright (C) Rocket Software 1993-2015
# This Python program imports a U2 module, calls a catalogued
# U2 Basic subroutine GET_MEMBERS_RECORD to receive a specific
# record from the MEMBERS file in XML format. It then uses an
# xml.etree.ElementTree module to parse the received XML string.
# Note, the XML version of the U2 record is in the
# element-centric mode.
# Parameters: first(in) - record ID; second(out) - XML string;
# third(out) - error code from subroutine; fourth(out) - error msg

import xml.etree.ElementTree as ET
import u2py
s = u2py.Subroutine("GET_MEMBERS_RECORD", 4) 
s.args[0] = "0965"
s.call()
if str(s.args[2]) != '0':
    print("Error from the subroutine:", s.args[3])
else:
    xmlstring = s.args[1] 
    print("xmlstring=", xmlstring)
    # Parse XML from the string into element 
    tree = ET.fromstring(xmlstring)
    for child in tree:
        if child.tag != 'ADDRESS_MV': 
            print(child.tag, child.text)
        else:
            print('STREET_ADDRESS', child.find('ADDRESS').text)

####################################################
示例#8
0
def print_at(param):
    this_routine = u2py.Subroutine("PRINT_AT", 1)
    this_routine.args[0] = u2py.DynArray(param)
    this_routine.call()
    return