diff --git a/config.yml b/config.yml index a04918a..6356135 100644 --- a/config.yml +++ b/config.yml @@ -32,13 +32,13 @@ led: ledstart: 288 ledend: 431 mode: rgb - - universe: 1 - ip: 192.168.68.130 + - universe: 4 + ip: 192.168.5.40 ledstart: 432 ledend: 575 mode: rgb - - universe: 4 - ip: 192.168.68.131 + - universe: 1 + ip: 192.168.5.4 ledstart: 576 ledend: 719 mode: rgb diff --git a/get_specs.py b/get_specs.py index 13958f5..6a5c86c 100755 --- a/get_specs.py +++ b/get_specs.py @@ -26,7 +26,7 @@ def check_internet(url='https://belden.com', timeout=5): -def query_search(partnum): +def query_search(partnum, source): """token_url = "https://www.belden.com/coveo/rest/token?t=" + str(int(time.time())) with requests.get(token_url) as r: out = json.loads(r.content) @@ -49,15 +49,50 @@ def query_search(partnum): # Bash script uses some crazy json formatting that I could not figure out # Despite the fact that I wrote it # So I'll just leave it, becuase it works. + if source == "Belden": + command = ["./query-search.sh", partnum] + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if result.returncode != 0: # error + fprint("No results found in search database for " + partnum + ". No hi-res part image available.", result.stderr) + return False + else: + data_out = json.loads(result.stdout) + return data_out + elif source == "Alphawire": + alphaurl = "https://www.alphawire.com//sxa/search/results/?l=en&s={4A774076-6068-460C-9CC6-A2D8E85E407F}&itemid={BF82F58C-EFD9-4D8B-AE3E-097DD12CF7DA}&sig=&autoFireSearch=true&productpartnumber=*" + partnum + "*&v={B22CD56D-AB95-4048-8AA1-5BBDF2F2D17F}&p=10&e=0&o=ProductPartNumber%2CAscending" + r = requests.get(url=alphaurl) + data = r.json() + output = dict() + #print(data) + try: + if data["Count"] > 0: + print(data["Results"][0]["Url"]) + result = data["Results"][0] + if result["Url"].split("/")[-1] == partnum: + #print(partnum) + print(result["Html"]) + try: + imgidx = result["Html"].index(" 1): # Use query - search_result = query_search(partnum.replace(" ", "")) + search_result = query_search(partnum.replace(" ", ""), dstype) # Try to use belden.com search if search_result is not False: # Download high resolution part image if available and needed @@ -190,17 +231,17 @@ def get_multi(partnums): # Download datasheet from provided URL if needed if os.path.exists(path) and os.path.getsize(path) > 1: - __use_cached_datasheet(partnum, path, output_dir) + __use_cached_datasheet(partnum, path, output_dir, dstype) elif _download_datasheet(search_result["datasheet"], output_dir) is not False: - __downloaded_datasheet(partnum, path, output_dir) + __downloaded_datasheet(partnum, path, output_dir, dstype) elif os.path.exists(path) and os.path.getsize(path) > 1: - __use_cached_datasheet(partnum, path, output_dir) + __use_cached_datasheet(partnum, path, output_dir, dstype) # If search fails, and we don't already have the datasheet, guess datasheet URL and skip the hires image download elif _try_download_datasheet(partnum, output_dir) is not False: - __downloaded_datasheet(partnum, path, output_dir) + __downloaded_datasheet(partnum, path, output_dir, dstype) # Failed to download with search or guess :( else: @@ -213,7 +254,7 @@ def get_multi(partnums): # We already have a hi-res image and the datasheet - perfect! else: fprint("Using cached hi-res part image for " + partnum) - __use_cached_datasheet(partnum, path, output_dir) + __use_cached_datasheet(partnum, path, output_dir, dstype) if len(failed) > 0: fprint("Failed to download:") @@ -227,21 +268,22 @@ def get_multi(partnums): if __name__ == "__main__": - partnums = ["7958A", "10GXS12", "RST 5L-RKT 5L-949", -"10GXS13", -"10GXW12", -"10GXW13", -"2412", -"2413", -"OSP6AU", -"FI4D024P9", -"FISD012R9", -"FDSD012A9", -"FSSL024NG", -"FISX006W0", -"FISX00103", -"C6D1100007" + partnums = ["AW3248", "BL7958A", "BL10GXS12", "BLRST 5L-RKT 5L-949", +"BL10GXS13", +"BL10GXW12", +"BL10GXW13", +"BL2412", +"BL2413", +"BLOSP6AU", +"BLFI4D024P9", +"BLFISD012R9", +"BLFDSD012A9", +"BLFSSL024NG", +"BLFISX006W0", +"BLFISX00103", +"BLC6D1100007" ] - get_multi(partnums) + #get_multi(partnums) + query_search("3248", "Alphawire") diff --git a/led_control.py b/led_control.py index b208480..75c7823 100755 --- a/led_control.py +++ b/led_control.py @@ -178,9 +178,9 @@ def init(): sendall(data) #time.sleep(50000) fprint("Running start-up test sequence...") - for y in range(1): + for y in range(100): for x in range(len(leds)): - setpixel(5,5,5,x) + setpixel(0,0,150,x) sendall(data) #time.sleep(2) #alloffsmooth() @@ -290,7 +290,7 @@ def close(): time.sleep(0.5) sender.stop() -def mapimage(image, fps=60): +def mapimage(image, fps=90): global start while uptime() - start < 1/fps: time.sleep(0.00001) diff --git a/map.png b/map.png index 6f73f78..52f3cba 100644 Binary files a/map.png and b/map.png differ diff --git a/read_datasheet.py b/read_datasheet.py index 5bec00c..f19d30f 100755 --- a/read_datasheet.py +++ b/read_datasheet.py @@ -12,7 +12,7 @@ from util import fprint import uuid from util import run_cmd -def parse(filename, output_dir, partnum): +def parse(filename, output_dir, partnum, dstype): # Extract table data @@ -24,6 +24,7 @@ def parse(filename, output_dir, partnum): page = reader.pages[0] table_list = {} for table in tables: + table.df.infer_objects(copy=False) table.df.replace('', np.nan, inplace=True) table.df.dropna(inplace=True, how="all") table.df.dropna(inplace=True, axis="columns", how="all") @@ -139,29 +140,30 @@ def parse(filename, output_dir, partnum): # multi-page table check - if table_name.isdigit() and len(tables) > 1: - fprint(table_name) - fprint(previous_table) - - - - - main_key = previous_table - cont_key = table_name - fprint(tables) - if vertical == False: - main_keys = list(tables[main_key].keys()) - for i, (cont_key, cont_values) in enumerate(tables[cont_key].items()): - if i < len(main_keys): - fprint(tables[main_key][main_keys[i]]) - tables[main_key][main_keys[i]] = (tables[main_key][main_keys[i]] + (cont_key,) + cont_values) - - del tables[table_name] - - else: - for key in tables[cont_key].keys(): - tables[main_key][key] = tables[cont_key][key] - del tables[table_name] + if dstype == "Belden": + if table_name.isdigit() and len(tables) > 1: + fprint(table_name) + fprint(previous_table) + + + + + main_key = previous_table + cont_key = table_name + fprint(tables) + if vertical == False: + main_keys = list(tables[main_key].keys()) + for i, (cont_key, cont_values) in enumerate(tables[cont_key].items()): + if i < len(main_keys): + fprint(tables[main_key][main_keys[i]]) + tables[main_key][main_keys[i]] = (tables[main_key][main_keys[i]] + (cont_key,) + cont_values) + + del tables[table_name] + + else: + for key in tables[cont_key].keys(): + tables[main_key][key] = tables[cont_key][key] + del tables[table_name] previous_table = table_name