Ejemplo n.º 1
0
 def __init__(self):
     self.U2_ORDERS = u2py.File("U2_ORDERS")
     self.U2_BOOKS = u2py.File("U2_BOOKS")
     self.clientBooks = {}
     self.bookClients = {}
     self.pairs = {}
     self.debugFile = open('debug.log', 'a')
Ejemplo n.º 2
0
def consultantDetials():
	#pdb.set_trace()
	transactionId="999888"
	transactionFile=u2py.File("TRANSACTION")
	transNo=list(transactionFile.readv(transactionId,1))[0][0]
	phoneNo=list(transactionFile.readv(transactionId,2))[0][0]
	emFile=u2py.File("EM")
	consultantDetails={}
	data=[]
	businessName=list(emFile.readv(phoneNo,27))[0][0]
	firstName=list(emFile.readv(phoneNo,2))[0][0]
	lastName=list(emFile.readv(phoneNo,1))[0][0]	
	shortName=list(emFile.readv(phoneNo,17))[0][0]
        ####checks the businessName if present it replaces the firstname
	if(businessName!=''):
		operator=str(businessName)
	else:
		operator=str(firstName)
	operator=operator+" "+str(lastName)
	if(len(operator)+len(shortName)<23):
		operator=operator+" ("+str(shortName)+")"
	consultantDetails["operator"]=operator
	####they only want length till 23(used for extra precaution)
	operator=str(operator[0:23])
	tempType=list(transactionFile.readv(transactionId,246))[0][0]
	if tempType =='':
		tempType="SLS CONSULT"
	else:
		tempType=tempType.split("*")
		tempType=str(tempType[2])
	employeeId=list(transactionFile.readv(transactionId,244))[0][0]
	if(checkExistingRecord("EM",employeeId)==True):
	####sets name to Noconsultant if record not found
		emFirstName=list(emFile.readv(employeeId,2))[0][0]
		emLastName=list(emFile.readv(employeeId,1))[0][0]
		emShortName=list(emFile.readv(employeeId,17))[0][0]
		consultantDetails[tempType]=str(emFirstName)+" "+str(emLastName)+" ("+str(emShortName)+")"
	else:
		consultantDetails[tempType]="No consultant"
	fitterId=list(transactionFile.readv(transactionId,248))[0][0]
        ####add name from em file where recordId is we get from record<248> of transaction
	if(fitterId!=""):
		fitterFirstName=list(emFile.readv(fitterId,2))[0][0]
		fitterLastName=list(emFile.readv(fitterId,1))[0][0]
		fitterShortName=list(emFile.readv(fitterId,17))[0][0]
		fitterName=str(fitterFirstName)+" "+str(fitterLastName)+" ("+str(fitterShortName)+")"
	else:
		fitterName=fitterId
	if(fitterId!=""):
	####only adds if there is a fitterId(doubt why they set its value null)
		consultantDetails["SRC ASSOC"]=fitterName
	data.append(consultantDetails)
	return Response(
		json.dumps(data),
		status=200,
		mimetype="application/json"
		)
Ejemplo n.º 3
0
def checkExistingRecord(filename, recordID):
    fileObject = u2py.File(filename)
    try:
        recordObject = fileObject.read(recordID)
        return True
    except u2py.U2Error as e:
        return False
Ejemplo n.º 4
0
 def createRemotes(self, fileName):
     tempFL = u2py.File(fileName)
     slist = u2py.List(0, tempFL)
     for id in slist:
         rec = u2py.DynArray()
         rec.replace(1, 'R')
         rec.replace(2, fileName)
         rec.replace(3, str(id))
         self.VOC_FILE.write(str(id), rec)
Ejemplo n.º 5
0
def writeToExcel():
    excel_file = "/usr/uv/PANDA/experiment.xlsx"
    f = u2py.File("EXCELPANDA")
    r = f.read("NAME")
    print(type(r))
    print(r)
    df = pd.DataFrame({'NAME': r})
    writer = ExcelWriter(excel_file, engine='xlsxwriter')
    df.to_excel(writer, sheet_name='Sheet 1')
    writer.save()
    return "Successfully written to excel file from UniVerse"
Ejemplo n.º 6
0
def vendorDetailU2(vendorDetails,itemsId,recordID):
	vendorArray=u2py.DynArray()
	item=bytes("","utf-8")
	vendorFile=u2py.File('PO.VENDOR.MST')
	vendorArray.insert(1,0,0,vendorDetails['Company'])
	vendorArray.insert(2,0,0,vendorDetails['Contact'])
	vendorArray.insert(3,0,0,bytes(vendorDetails['Street'],"utf-8")+u2py.VM+bytes(vendorDetails['City'],"utf-8")+u2py.VM+bytes(vendorDetails['State'],"utf-8")+u2py.VM+bytes(vendorDetails['Zip'],"utf-8"))
	vendorArray.insert(4,0,0,vendorDetails['Phone'])
	for items in itemsId:
		item=item+bytes(items['items'],"utf-8")+u2py.VM
	vendorArray.insert(5,0,0,item[:-1])
	vendorFile.write(recordID,vendorArray)
Ejemplo n.º 7
0
 def setupDataFiles(self):
     self.createFilePointer('books.tables', 'books.tables.safe')
     u2py.run('MAKETABLE books.tables.safe * /NOINCLUDES')
     tempFL = u2py.File('books.tables.safe')
     slist = u2py.List(1, tempFL)
     for id in slist:
         fileName = str(id)
         if not fileName == 'DEFAULT':
             if not self.loadAssets(fileName):
                 self.createFilePointer(fileName, fileName + '.safe')
                 cmd = 'COPYI FROM ' + fileName + '.safe TO ' + fileName + ' ALL OVERWRITING'
                 u2py.run(cmd)
Ejemplo n.º 8
0
def helloworld():
	loc = ("/usr/uv/PANDA/Employees.xlsx")
	wb = xlrd.open_workbook(loc) 
	sheet = wb.sheet_by_index(0) 
	sheet.cell_value(0, 0) 
	length=(sheet.nrows)
	for i in range(1,length):
		f=u2py.File("UBER")
		b=str;	
		b=(sheet.cell_value(i,1));
		f.write("NAME",b)
		print(b)
	f.close()
Ejemplo n.º 9
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}
Ejemplo n.º 10
0
def readFromExcel():
    for i in range(1, 4):
        loc = ("/usr/uv/PANDA/Employees.xlsx")
        b = str
        wb = xlrd.open_workbook(loc)
        sheet = wb.sheet_by_index(0)
        sheet.cell_value(0, 0)
        f = u2py.File("EXCELPANDA")
        b = (sheet.cell_value(i, 1))
        f.write("NAME", b)
        #f.read("ONE")
        #print(sheet)
        print(b)
        #print(i)
    return "Data inserted into UniVerse from Excel File"
Ejemplo n.º 11
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
Ejemplo n.º 12
0
def readFromU2():
    data = []
    filename = request.args.get('filename')
    record = request.args.get('recordname')
    try:
        f = u2py.File(filename)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': "File Not Found"}
    theArray = u2py.DynArray()
    try:
        data = f.read(record)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': "Record Not Found"}
    data = tuple(data)
    print(theArray)
    return {"data": data}, 201
Ejemplo n.º 13
0
def u2WritePyDict(theFile, itemId, theDictItem):
    if type(theFile).__name__ == 'File':
        myFile = theFile
    else:
        myFile = u2py.File(theFile)

    if type(theDictItem).__name__ == 'dict':
        fieldNames, fieldValues = zip(*theDictItem.items())
        fieldNames = u2py.DynArray(list(fieldNames))
        fieldValues = u2py.DynArray(list(fieldValues))
    else:
        raise ValueError("Expecting Python dict item for theDictItem")
        return null

    myFile.writenamedfields(itemId, fieldNames, fieldValues)
    return
Ejemplo n.º 14
0
 def setupWebserver(self):
     cmd = self.makePath(self.python_path, self.pythonexe)
     cmd = cmd + ' ' + self.makePath(self.home,
                                     'server\\books.pysrc\\webserver.py')
     cmd = cmd + ' --rootdir ' + self.home + '\\web'
     cmd = cmd.replace('\\', self.delim)
     with open('start_webserver.bat', 'w') as f:
         f.write(cmd)
     f.close()
     VOC = u2py.File("VOC")
     rec = u2py.DynArray()
     rec.replace(1, "PA")
     rec.replace(2, "DISPLAY Start personal web server")
     rec.replace(3, "DISPLAY Connect to http://localhost:8080")
     rec.replace(4, "DISPLAY To quit go to http://localhost:8080/stop")
     rec.replace(5, "DOS /c start_webserver.bat")
     VOC.write('start_webserver', rec)
Ejemplo n.º 15
0
def saveInvoice(orderNo,invoiceDetails,invoiceNo,invoiceDate,invoiceAmount,status):
	invoiceData=u2py.DynArray()
	invoiceFile= u2py.File("PO.INVOICE.MST")
	itemNo=description=quantityOrdered=quantityPending=quantityReceived=bytes("","utf-8")
	invoiceData.insert(1,0,0,invoiceDate)
	invoiceData.insert(6,0,0,orderNo)
	invoiceData.insert(7,0,0,status)
	for i in range(len(invoiceDetails)):
		itemNo=itemNo+bytes(invoiceDetails[i]['itemNo'],"utf-8")+u2py.VM
		quantityOrdered=quantityOrdered+bytes(invoiceDetails[i]['quantityOrdered'],"utf-8")+u2py.VM
		quantityPending=quantityPending+bytes(str(invoiceDetails[i]['quantityPending']),"utf-8")+u2py.VM
		quantityReceived=quantityReceived+bytes(invoiceDetails[i]['quantityReceived'],"utf-8")+u2py.VM
	invoiceData.insert(2,0,0,itemNo[:-1])
	invoiceData.insert(3,0,0,quantityOrdered[:-1])
	invoiceData.insert(4,0,0,quantityPending[:-1])
	invoiceData.insert(5,0,0,quantityReceived[:-1])
	invoiceFile.write(invoiceNo,	invoiceData)
Ejemplo n.º 16
0
def readmember(formdata, uvfields, formfields):
    # get the UniVerse imports
    import os
    os.chdir("C:\\U2\\XDEMO\\pythonbetarocket")
    import u2py

    member_id = formdata.get('member_id')
    # read the file and get the details
    file = u2py.File("MEMBERS")
    field_names = u2py.DynArray()
    for pos, dictname in uvfields.items():
        field_names.replace(pos, dictname)
    member_data = file.readnamedfields(member_id, field_names)
    formdata['member_id'] = member_id
    for pos, dictname in formfields.items():
        formdata[dictname] = member_data.extract(pos)
    return formdata
Ejemplo n.º 17
0
def U2READ(theFile, itemId, defaultItem):
    if type(theFile).__name__ == 'File':
        myFile = theFile
    else:
        myFile = u2py.File(theFile)

    notFound = 0
    try:
        rec = myFile.read(itemId)

    except u2py.U2Error:
        if type(defaultItem) == u2py.DynArray:
            rec = defaultItem
        else:
            rec = u2py._DynArray(defaultItem)

    return rec
Ejemplo n.º 18
0
    def initAccount(self):
        print('Initializing account')
        self.VOC_FILE = u2py.File('VOC')
        rec = u2py.DynArray()
        rec.replace(1, 'PA')
        rec.replace(2, 'PTERM CASE NOINVERT')
        self.VOC_FILE.write('LOGIN', rec)

        u2py.run('PTERM CASE NOINVERT', capture=False)
        u2py.run('LONGNAMES ON', capture=False)
        u2py.run('TERM ,9999', capture=False)

        self.setupUtilityPrograms()
        self.setupSourceFiles()
        self.setupDataFiles()
        self.setupPythonPath()
        self.setupPip()
        self.setupPackages()
        self.setupWebserver()
Ejemplo n.º 19
0
def customerDetails():
	customerId="0001"
	customerFile=orderFile = u2py.File("CUSTOMERS")
	#cmd=u2py.Command("LIST PHONE.NO F.NAME L.NAME ADDRESS CITY ZIP.CODE PHONE.LONG PFID DATA CUSTOMERS TOJSON").run(capture=True)
	#cmd = cmd[1:-1]
	data=[]
	customerDetails={}
	customerDetails['phoneNo']=list(customerFile.readv(customerId,1))[0][0]
	customerDetails['firstName']=list(customerFile.readv(customerId,2))[0][0]
	customerDetails['lastName']=list(customerFile.readv(customerId,3))[0][0]
	customerDetails['address']=list(customerFile.readv(customerId,4))[0][0]
	customerDetails['city']=list(customerFile.readv(customerId,5))[0][0]
	customerDetails['state']=list(customerFile.readv(customerId,6))[0][0]
	customerDetails['zip']=list(customerFile.readv(customerId,7))[0][0]
	customerDetails['altPhoneNo']=list(customerFile.readv(customerId,12))[0][0]
	customerDetails['pfid']=list(customerFile.readv(customerId,33))[0][0]
	data.append(customerDetails)
	return Response(
	json.dumps(data),
	status=200,
	mimetype='application/json')
Ejemplo n.º 20
0
def writemember(formdata, uvfields, formfields):
    # get the UniVerse imports
    import os
    os.chdir("C:\\U2\\XDEMO\\pythonbetarocket")
    import u2py

    # open the file, read the latest version and write the details away
    file = u2py.File("MEMBERS")
    member_id = formdata.get('member_id')
    field_names = u2py.DynArray()
    for pos, dictname in uvfields.items():
        field_names.replace(pos, dictname)
    member_data = u2py.DynArray()
    if member_id == "NEW":
        # need to generate a new key
        member_id = genuniquekey("MEMBERS", 4)
    for pos, dictname in formfields.items():
        member_data.replace(pos, formdata.get(dictname))
    file.writenamedfields(member_id, field_names, member_data)
    # set the return key
    formdata['member_id'] = member_id
Ejemplo n.º 21
0
    def loadAssets(self, fileName):
        tempFL = u2py.File(fileName)
        filePath = self.makePath(self.asset_path, fileName.lower()) + '.tab'
        if not os.path.exists(filePath):
            return False
        print('Loading assets for ' + fileName)
        ct = 0
        with open(filePath, 'rU') as f:
            for line in f:
                da = bytearray(line.rstrip('\n'), 'utf-8')
                for i in range(len(da)):
                    if da[i] == 9: da[i] = 254  # tab to field mark
                    elif da[i] == 124: da[i] = 253  # pipe to value mark

                rec = u2py.DynArray(da)
                recId = str(rec.extract(1))
                rec.delete(1)
                tempFL.write(recId, rec)
                ct += 1
        print(str(ct) + ' records loaded')
        return True
Ejemplo n.º 22
0
def savedata():
    theArray = u2py.DynArray()
    excel_file = request.files['file']
    filePath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            excel_file.filename)
    recordname = request.form['recordname']
    filename = request.form['filename']
    try:
        f = u2py.File(filename)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': 'File not found'}
    data = tuple(f.read(recordname))
    if (len(data) != 0):
        val = len(data) + 1
    else:
        val = len(data)
    for i, j in data.iterrows():
        theArray.insert(val, 0, 0, j['empname'])
        val += 1
    f.write(recordname, theArray)
    f.close()
    return {'status': 200, 'msg': 'Data saved successfully'}
Ejemplo n.º 23
0
def u2ReadPyDict(theFile, itemId, fieldList):
    if type(theFile).__name__ == 'File':
        myFile = theFile
    else:
        myFile = u2py.File(theFile)

    if type(fieldList).__name__ == 'list':
        fieldDynArray = u2py.DynArray(fieldList)
    else:
        raise ValueError("Expecting Python list of field names")
        return null

    notFound = 0
    try:
        rec = myFile.readnamedfields(itemId, fieldDynArray)
        rec_list = rec.to_list()
        my_dict = dict(zip(fieldList, rec_list))
    except u2py.U2Error as e:
        print("item " + str(itemId) + " was not read from the file")
        print(str(e))

    return my_dict
Ejemplo n.º 24
0
def writePurchaseOrder(purchaseOrderDetails,itemOrderDetails,recordID,submitStatus):
    itemID = quantity = cost = bytes("","utf-8")
    orderFile = u2py.File("PO.ORDER.MST")
    orderData = u2py.DynArray()
    orderData.insert(1,0,0,purchaseOrderDetails['orderDate'])
    orderData.insert(2,0,0,submitStatus)
    orderData.insert(7,0,0,purchaseOrderDetails['companyName'])
    orderData.insert(8,0,0,purchaseOrderDetails['contactName'])
    orderData.insert(9,0,0,bytes(purchaseOrderDetails['street'],"utf-8") + 
                u2py.VM + bytes(purchaseOrderDetails['city'],"utf-8") + 
                u2py.VM + bytes(purchaseOrderDetails['state'],"utf-8") + 
                u2py.VM+bytes(str(purchaseOrderDetails['zipCode']),"utf-8"))
    orderData.insert(10,0,0,str(purchaseOrderDetails['phoneNumber']))

    for item in itemOrderDetails:
        itemID = itemID + bytes(item['itemID'],"utf-8")+u2py.VM
        quantity = quantity + bytes(str(item['quantity']),"utf-8")+u2py.VM
        cost = cost + bytes(str(item['unitCost']),"utf-8")+u2py.VM
    
    orderData.insert(11,0,0,itemID[:-1])
    orderData.insert(12,0,0,quantity[:-1])
    orderData.insert(13,0,0,cost[:-1])
    orderData.insert(14,0,0,purchaseOrderDetails['vendorName'])
    orderFile.write(recordID,orderData)
Ejemplo n.º 25
0
#!/bin/python3
#Program: u2_physician.py
#Purpose: Compare UDT Locate vs Python Dictionary

import sys
import u2py
import time

start = time.time(); 

try:
    u2file=u2py.File("PHYSICIAN")
    mcmd = u2py.Command("SELECT PHYSICIAN")
    mcmd.run()
    U2List=u2py.List(0)
except Exception as e:
    print(str(e))

KEY={};
for id in U2List:
    rec=u2file.read(id)
    gender=rec.extract(8,0,0)
    specialty=rec.extract(12,0,0)
    year=rec.extract(11,0,0)
    school=rec.extract(10,0,0)
    city=rec.extract(25,0,0)
    state=rec.extract(26,0,0)
    key=str(state)
    if key in KEY:
        KEY[key] +=1
    else:
Ejemplo n.º 26
0
majorText = StringVar()
minorText = StringVar()
advisorText = StringVar()
semesterText = StringVar()
classType = ""
i = 1
#Semester tracker
k = 1
#Class tracker
R = u2py.DynArray()
#Empty dynamic array

########################
# Access UniData files #
########################
F = u2py.File("STUDENT")
F2 = u2py.File("COURSES")
T = u2py.DynArray("TEACHERS")


############
# Exit GUI #
############
def quitgui():
    root.destroy()


#################
# Search button #
#################
def search():
myabstract = p(Abstract)
head_info = [mytitle, myname, mysite, mymail, abstract_title, myabstract]
Elements.extend(head_info)

yearly_title = header("Revenue from FUR_REV by Product Category")
yearly_explain = p("This shows Revenue By Product Category")

prod_catnames = []
data = []
values = []

cmd = u2py.Command(
    'SQL SELECT PROD_CAT,SUM(REVENUE) FROM FUR_REV GROUP BY PROD_CAT TOXML ELEMENTS TO "FUR_REV";'
)
cmd.run()
file = u2py.File('_XML_')
xml = str(file.read('FUR_REV.xml'))
p1 = xml.find('<ROOT>')
xml = xml[p1:]
print("xml->" + xml)
prod_cat = ''
tree = ET.fromstring(xml)
for child in tree:
    #print(child.tag + "->" + child.text)
    if child.tag == "FUR_REV":
        for plocation in child:
            if plocation.tag == "PROD_CAT":
                prod_cat = plocation.text
            else:
                if plocation.tag == "SUM_Revenue_":
                    value = float(plocation.text)
Ejemplo n.º 28
0
yearly_explain = p("This shows Revenue By Product Category")

prod_catnames = []
data = []
values = []

#simulate an EXECUTE
cmd = u2py.Command('COMO ON XML')
cmd.run()
cmd = u2py.Command(
    'SQL SELECT PROD_CAT,SUM(REVENUE) FROM FUR_REV GROUP BY PROD_CAT TOXML ELEMENTS;'
)
cmd.run()
cmd = u2py.Command('COMO OFF')
cmd.run()
file = u2py.File('_PH_')
xml = str(file.read('O_XML'))
p1 = xml.find('<ROOT>')
xml = xml[p1:]
p1 = xml.find('</ROOT>')
xml = xml[0:p1 + 7]
#print("xml->" + xml)
prod_cat = ''
tree = ET.fromstring(xml)
for child in tree:
    #print(child.tag + "->" + child.text)
    if child.tag == "FUR_REV":
        for plocation in child:
            if plocation.tag == "PROD_CAT":
                prod_cat = plocation.text
            else:
Ejemplo n.º 29
0
        # Check if we are done
        done = True
        for job in jobs:
            if job.priority == 0:
                done = False


# Graph information
nodes = []
jobs = []
num_our_locs = 0

print("Starting priority calculation program")

jobs_file = u2py.File("JOBS")
loc_file = u2py.File("LOCATIONS")

u2py.List(0).clear()
num_our_locs = get_our_locations(nodes, loc_file)

# Create a select list with all the active jobs
cmd = u2py.Command("SELECT JOBS")
cmd.run()
id_list = u2py.List(0)
next_id = str(id_list.next())
while next_id != "":
    # Read jobs
    rec = jobs_file.read(next_id)
    new_job = Job()
    new_job.id = str(next_id)
Ejemplo n.º 30
0
def postcode_to_latlong(postcode):
    coords = []
    postcode.replace(" ", "")  # Remove all  whitespace
    # Retrieve the info from the api.postcodes.io free service
    resp = urllib.request.urlopen("http://api.postcodes.io/postcodes/%s" %
                                  (postcode))
    # Parse JSON
    decoded = resp.read().decode(resp.info().get_param('charset') or 'utf-8')
    postcode_data = json.loads(decoded)
    coords.append(postcode_data['result']['latitude'])
    coords.append(postcode_data['result']['longitude'])
    return coords


# Find the changed locations
loc_file = u2py.File("LOCATIONS")
u2py.List(0).clear()
cmd = u2py.Command("SELECT LOCATIONS")
cmd.run()
id_list = u2py.List(0)
next_id = str(id_list.next())
while next_id != "":
    rec = loc_file.read(next_id)
    if int(rec.extract(7)) == 1:
        # Write the postcode
        coords = postcode_to_latlong(str(rec.extract(5)))
        rec.replace(1, coords[0])
        rec.replace(2, coords[1])
        rec.replace(7, 0)
        loc_file.write(next_id, rec)
    next_id = str(id_list.next())