def searchmember(formdata, uvfields, formfields): # get the UniVerse imports import os os.chdir("C:\\U2\\XDEMO\\pythonbetarocket") import u2py thecmd = "SELECT MEMBERS WITH" loopcntr = 0 # loop through the fields and build the select list for pos, dictname in formfields.items(): if formdata[dictname] != "": loopcntr += 1 if loopcntr > 1: thecmd += " OR" thecmd += ' ' + str(uvfields.get(pos)) + ' = "' + str( formdata.get(dictname)) + '"' command = u2py.Command("CLEARSELECT") command = u2py.Command(thecmd) command.run() rtnlist = [] print(thecmd) try: thelist = u2py.List(0) thedynlist = thelist.readlist() print(str(thedynlist)) except u2py.U2Error as e: return rtnlist
def get_our_locations(nodes, loc_file): cmd = u2py.Command('SELECT LOCATIONS WITH OUR_FACILITY="y"') cmd.run() id_list = u2py.List(0) num = 0 next_id = str(id_list.next()) while next_id != "": rec = loc_file.read(next_id) our_loc = MSTNode() our_loc.id = next_id our_loc.latitude = float(rec.extract(1)) our_loc.longitude = float(rec.extract(2)) our_loc.our_loc = str(rec.extract(4)) our_loc.description = str(rec.extract(6)) next_id = str(id_list.next()) num += 1 nodes.append(our_loc) id_list.clear() return num
# 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) new_job.location = str(rec.extract(1)) new_job.date_filed = int(rec.extract(2)) new_job.description = str(rec.extract(11)) start_date = rec.extract(9) if str(start_date) != "": new_job.start_date = int(start_date)
mysite = header(URL, sep=0.1, style=ParaStyle) mymail = header(email, sep=0.1, style=ParaStyle) abstract_title = header("ABSTRACT") 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 = [] #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 = ''
#!/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:
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()) id_list.clear()
mysite = header(URL, sep=0.1, style=ParaStyle) mymail = header(email, sep=0.1, style=ParaStyle) abstract_title = header("ABSTRACT") myabstract = p(Abstract) head_info = [mytitle, myname, mysite, mymail, abstract_title, myabstract] Elements.extend(head_info) yearly_title = header("Sales from PLOCATION by STATE") yearly_explain = p("""This shows Sales By State""") statenames = [] data = [] values = [] #simulate an EXECUTE cmd = u2py.Command('COMO ON XML') cmd.run() cmd = u2py.Command('SQL SELECT STATE,SUM(SALES) FROM PLOCATION GROUP BY STATE 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) STATE = '' tree = ET.fromstring(xml) for child in tree:
mysite = header(URL, sep=0.1, style=ParaStyle) mymail = header(email, sep=0.1, style=ParaStyle) abstract_title = header("ABSTRACT") 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
theFile.lock(clientkey) clrec.replace(1, jsondata["Name"]) clrec.replace(2, 1, jsondata["AddressLine1"]) clrec.replace(2, 2, jsondata["AddressLine2"]) clrec.replace(2, 3, jsondata["AddressLine3"]) clrec.replace(3, jsondata["ZipCode"]) theFile.write(clientkey, clrec) theFile.unlock(clientkey) if funcmode == 'cl_getdetails': client_key = sys.argv[2] client_key = str(client_key) clientrec = theFile.read(client_key) py_array = {} py_array["Name"] = str(clientrec.extract(1)) py_array["AddressLine1"] = str(clientrec.extract(2, 1)) py_array["AddressLine2"] = str(clientrec.extract(2, 2)) py_array["AddressLine3"] = str(clientrec.extract(2, 3)) py_array["ZipCode"] = str(clientrec.extract(3)) print(json.dumps(py_array)) if funcmode == 'cl_list': cmd = u2py.Command("HUSH.SELECT.CLIENT.BY.LNAME") cmd.run() list = u2py.List(0) DynList = list.readlist() for eachArg in DynList: recKey = str(eachArg[0]) clientrec = theFile.read(recKey) imgsrc = clientrec.extract(4, 1, 1) clientlist = str(recKey) + '\t' + str(imgsrc) print(clientlist)