Commit f2da6903 authored by siguhe's avatar siguhe

Removed unused functions. Renamed functions.

parent 73903359
......@@ -6,7 +6,7 @@ import urllib.request
import time
import json
def AJAXsearch(rom,seksjon,hylle,rad,kolonne,dybde): #rom can be 'OV', 'GM' or 'VendingMachine'
def AJAX_search_component_pos(rom,seksjon,hylle,rad,kolonne,dybde): #rom can be 'OV', 'GM' or 'VendingMachine'
try:
url = 'https://omegav.no:8091/ajax/kompsok.php'
data = urllib.parse.urlencode({'rom' : rom,
......@@ -31,7 +31,7 @@ def AJAXsearch(rom,seksjon,hylle,rad,kolonne,dybde): #rom can be 'OV', 'GM' or '
print("Except")
return {'error': "API Error"}
def AJAXsearchID(ID):
def AJAX_search_component_ID(ID):
try:
url = 'https://omegav.no:8091/ajax/kompsok.php'
data = urllib.parse.urlencode({'kompid' : ID})
......@@ -51,22 +51,7 @@ def AJAXsearchID(ID):
print("Except")
return {'error': "API Error"}
def AJAXsearchName(navn):
url = 'https://omegav.no:8091/ajax/kompsok.php'
request = urllib.request.Request(url)
response = urllib.request.urlopen(request).read().decode('utf8')
search_content = json.loads(response)
result= search_content
list_of_results=[]
for ID in range(len(result)-1):
for key in result[str(ID)].keys():
if( navn in result[str(ID)][key]):
list_of_results.append(result[str(ID)]['id'])
return list_of_results #list of IDs, may add items which have antall=0, this has not been checked yet.
def AJAXsearchNameImproved(navn):
def AJAX_search_component_name(navn):
url = 'https://omegav.no:8091/ajax/kompsok.php'
data = urllib.parse.urlencode({'search' : navn})
data = data.encode('utf-8')
......@@ -79,7 +64,7 @@ def AJAXsearchNameImproved(navn):
search_content_list.append(search_content[result]['id'])
return search_content_list #list of IDs, may add items which have antall=0, this has not been checked yet.
def APIbuy(rfid,rom,sek,hylle,row,col,dybde,api_key):
def API_buy(rfid,rom,sek,hylle,row,col,dybde,api_key):
try:
url = 'https://omegav.no:8091/api/komp.php'
data = urllib.parse.urlencode({'handling' : 'kjop',
......@@ -104,15 +89,6 @@ def APIbuy(rfid,rom,sek,hylle,row,col,dybde,api_key):
print("exception")
return False
def APIadd(handlevogn,seksjon,hylle,rad,kolonne,dybde): #handlevogn er ei liste av ordbøker
data=AJAXsearch(seksjon,hylle,rad,kolonne,dybde)
if('error' in data):
print(data)
return handlevogn
else:
handlevogn.append({'seksjon' : seksjon,'hylle' : hylle,'rad' : rad,'kolonne' : kolonne,'dybde' : dybde})
return handlevogn
def API_find_user(rfid,api_key):
url = 'https://omegav.no:8091/api/komp.php'
data = urllib.parse.urlencode({'handling' : 'bruker', 'rfid' : rfid, 'key' : api_key})
......@@ -122,12 +98,4 @@ def API_find_user(rfid,api_key):
return response
#Testing funcrions. Can be removed.
#print(APIbuy('0270245408','OV',8,3,2,0,0,'a'))
#print("namn:",AJAXsearch('OV',8,3,2,0,0)['navn'])
#print("antall:",AJAXsearch('OV',8,3,2,0,0)['antall'])
#print("id:",AJAXsearch('OV',8,3,12,0,0)['id'])
#print("user: ",API_find_user('0270245408','a'))
#ID=AJAXsearchName('arduino')[0]
#print(AJAXsearchID(ID)['navn'])
print(AJAXsearchNameImproved('BC'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment