-
Notifications
You must be signed in to change notification settings - Fork 31
Standardize loggings in the tools #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import time | ||
| from ast import literal_eval | ||
| import os | ||
| import logging | ||
|
|
||
| #time.sleep(7) | ||
| timeout_max = 20 | ||
|
|
@@ -58,10 +59,10 @@ | |
| except: | ||
| init_simtime_ym = "[0.0, 0.0, 0.0]" | ||
|
|
||
| print(apikey) | ||
| print(yuyu) | ||
| print(name1+'='+init_simtime_u) | ||
| print(name2+'='+init_simtime_ym) | ||
| logging.info(f"API Key: {apikey}") | ||
|
||
| logging.info(f"Yuyu: {yuyu}") | ||
| logging.info(f"{name1}={init_simtime_u}") | ||
| logging.info(f"{name2}={init_simtime_ym}") | ||
|
|
||
| while not os.path.exists(concore.inpath+'1/'+name1): | ||
| time.sleep(concore.delay) | ||
|
|
@@ -78,47 +79,45 @@ | |
|
|
||
|
|
||
| while(concore.simtime<concore.maxtime): | ||
| print("CW outer loop") | ||
| logging.debug("CW outer loop") | ||
| while concore.unchanged(): | ||
| u = concore.read(1,name1,init_simtime_u) | ||
| f = {'file1': open(concore.inpath+'1/'+name1, 'rb')} | ||
| print("CW: before post u="+str(u)) | ||
| print('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2) | ||
| logging.debug(f"CW: before post u={u}") | ||
| logging.debug(f'http://www.controlcore.org/pm/{yuyu}{apikey}&fetch={name2}') | ||
| r = requests.post('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2, files=f,timeout=timeout_max) | ||
| if r.status_code!=200: | ||
| print("bad POST request "+str(r.status_code)) | ||
| logging.error(f"bad POST request {r.status_code}") | ||
| quit() | ||
| if len(r.text)!=0: | ||
| try: | ||
| t=literal_eval(r.text)[0] | ||
| except: | ||
| print("bad eval "+r.text) | ||
| logging.error(f"bad eval {r.text}") | ||
| timeout_count = 0 | ||
| t1 = time.perf_counter() | ||
| print("CW: after post status="+str(r.status_code)+" r.content="+str(r.content)+" t="+str(t)) | ||
| logging.debug(f"CW: after post status={r.status_code} r.content={r.content} t={t}") | ||
| #while r.text==oldym or len(r.content)==0: | ||
| while oldt==t or len(r.content)==0: | ||
| time.sleep(concore.delay) | ||
| print("CW waiting status="+str(r.status_code)+" content="+ r.content.decode('utf-8')+" t="+str(t)) | ||
| logging.debug(f"CW waiting status={r.status_code} content={r.content.decode('utf-8')} t={t}") | ||
| f = {'file1': open(concore.inpath+'1/'+name1, 'rb')} | ||
| try: | ||
| r = requests.post('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2, files=f,timeout=timeout_max) | ||
| except: | ||
| print("CW: bad request") | ||
| logging.error("CW: bad request") | ||
| timeout_count += 1 | ||
| if r.status_code!=200 or time.perf_counter()-t1 > 1.1*timeout_max: #timeout_count>100: | ||
| print("timeout or bad POST request "+str(r.status_code)) | ||
| logging.error(f"timeout or bad POST request {r.status_code}") | ||
| quit() | ||
| if len(r.text)!=0: | ||
| try: | ||
| t=literal_eval(r.text)[0] | ||
| except: | ||
| print("bad eval "+r.text) | ||
| logging.error(f"bad eval {r.text}") | ||
| oldt = t | ||
| oldym = r.text | ||
| print("CW: oldym="+oldym+" t="+str(concore.simtime)) | ||
| logging.debug(f"CW: oldym={oldym} t={concore.simtime}") | ||
| concore.write(1,name2,oldym) | ||
| #concore.write(1,"ym",init_simtime_ym) | ||
| print("retry="+str(concore.retrycount)) | ||
|
|
||
|
|
||
| logging.info(f"retry={concore.retrycount}") | ||
Uh oh!
There was an error while loading. Please reload this page.