Correctly parse results from get_specs
This commit is contained in:
parent
ad216f21fa
commit
19ce328596
@ -344,9 +344,13 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True, bar=None):
|
||||
fprint("Using cached hi-res part image for " + partnum)
|
||||
out = __use_cached_datasheet(partnum, path, output_dir, dstype)
|
||||
returnval = [partnum, dstype, False, out]
|
||||
actualpartnums.append(returnval)
|
||||
return True
|
||||
|
||||
for fullpartnum in partnums:
|
||||
if fullpartnum is False:
|
||||
actualpartnums.append(False)
|
||||
continue
|
||||
if fullpartnum[0:2] == "BL": # catalog.belden.com entry
|
||||
partnum = fullpartnum[2:]
|
||||
dstype = "Belden"
|
||||
|
59
run.py
59
run.py
@ -182,13 +182,13 @@ def start_server_socket():
|
||||
print(data)
|
||||
if "part_number" in data:
|
||||
for part in data["part_number"]:
|
||||
print(part)
|
||||
print(jbs.get_partnum(part))
|
||||
#print(part)
|
||||
#print(jbs.get_partnum(part))
|
||||
dataout["cables"].append(jbs.get_partnum(part)["fullspecs"])
|
||||
if "position" in data:
|
||||
for pos in data["position"]:
|
||||
print(pos)
|
||||
print(jbs.get_position(str(pos)))
|
||||
#print(pos)
|
||||
#print(jbs.get_position(str(pos)))
|
||||
dataout["cables"].append(jbs.get_position(str(pos))["fullspecs"])
|
||||
send_data(decoded["type"], "send", dataout, client_id)
|
||||
|
||||
@ -354,9 +354,12 @@ def mainloop_server(pool):
|
||||
elif camera_ready:
|
||||
fprint("Adding cable to list...")
|
||||
global scan_value
|
||||
if scan_value.find("bldn.app/") > -1:
|
||||
if scan_value is False:
|
||||
cable_list.append(scan_value)
|
||||
elif scan_value.find("bldn.app/") > -1:
|
||||
scan_value = scan_value[scan_value.find("bldn.app/")+9:]
|
||||
cable_list.append((counter, scan_value))
|
||||
else:
|
||||
cable_list.append(scan_value)
|
||||
fprint(scan_value)
|
||||
#pool.apply_async(arm.return cable, callback=arm_start_callback)
|
||||
arm_state = "RETURN"
|
||||
@ -370,19 +373,8 @@ def mainloop_server(pool):
|
||||
pass
|
||||
else:
|
||||
# scanned everything
|
||||
tmp = list()
|
||||
for cable in cable_list:
|
||||
tmp.append(cable[1])
|
||||
|
||||
tmp = [
|
||||
# Actual cables in Jukebox
|
||||
|
||||
"AW86104CY",
|
||||
"AW3050",
|
||||
"AW6714",
|
||||
"AW1172C",
|
||||
"AWFIT-221-1_4",
|
||||
|
||||
"BLTF-1LF-006-RS5",
|
||||
"BLTF-SD9-006-RI5",
|
||||
"BLTT-SLG-024-HTN",
|
||||
@ -404,9 +396,16 @@ def mainloop_server(pool):
|
||||
"BL8760",
|
||||
"BL6300UE",
|
||||
"BL6300FE",
|
||||
"BLRA500P"
|
||||
"BLRA500P",
|
||||
"AW86104CY",
|
||||
"AW3050",
|
||||
"AW6714",
|
||||
"AW1172C",
|
||||
"AWFIT-221-1_4"
|
||||
]
|
||||
cable_list = tmp
|
||||
while len(tmp) < 54:
|
||||
tmp.append(False) # must have 54 entries
|
||||
cable_list = tmp # remove for real demo
|
||||
pool.apply_async(get_specs.get_multi, (tmp, 0.3), callback=cable_search_callback)
|
||||
mode = "Parsing"
|
||||
fprint("All cables scanned. Finding & parsing datasheets...")
|
||||
@ -419,25 +418,27 @@ def mainloop_server(pool):
|
||||
# done
|
||||
global parse_res
|
||||
success, partnums = parse_res
|
||||
#partnums = list()
|
||||
# debug
|
||||
#success = True
|
||||
for idx in range(len(partnums)):
|
||||
if partnums[idx] is not False:
|
||||
cable_list[idx] = partnums[idx][0].replace("/", "_")
|
||||
else:
|
||||
cable_list[idx] = False
|
||||
|
||||
#cable_list = list(range(len(partnums)))
|
||||
print(partnums)
|
||||
if success:
|
||||
# easy mode
|
||||
fprint("All cables inventoried and parsed.")
|
||||
for x in range(len(cable_list)):
|
||||
#cable_list[x] = (cable_list[x][0], partnums[x])
|
||||
cable_list[x] = (x, cable_list[x])
|
||||
fprint("Adding to database...")
|
||||
for idx,partnum in cable_list:
|
||||
with open("cables/" + partnum[2:] + "/search.json", "rb") as f:
|
||||
for idx in range(len(cable_list)):
|
||||
partnum = cable_list[idx]
|
||||
if partnum is not False:
|
||||
with open("cables/" + partnum + "/search.json", "rb") as f:
|
||||
searchdata = json.load(f)
|
||||
searchdata["position"] = idx
|
||||
with open("cables/" + partnum[2:] + "/specs.json", "rb") as f:
|
||||
with open("cables/" + partnum + "/specs.json", "rb") as f:
|
||||
specs = json.load(f)
|
||||
searchdata["fullspecs"] = specs
|
||||
searchdata["fullspecs"]["position"] = idx
|
||||
jbs.add_document(searchdata)
|
||||
#sleep(0.5)
|
||||
#print(jbs.get_position("1"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user