|
12 | 12 |
|
13 | 13 | try: |
14 | 14 | apikey=open(concore.inpath+'1/concore.apikey',newline=None).readline().rstrip() |
15 | | -except: |
| 15 | +except (OSError, IOError): |
16 | 16 | try: |
17 | 17 | #perhaps this should be removed for security |
18 | 18 | apikey=open('./concore.apikey',newline=None).readline().rstrip() |
19 | | - except: |
| 19 | + except (OSError, IOError): |
20 | 20 | apikey = '' |
21 | 21 |
|
22 | 22 | try: |
23 | 23 | yuyu=open(concore.inpath+'1/concore.yuyu',newline=None).readline().rstrip() |
24 | | -except: |
| 24 | +except (OSError, IOError): |
25 | 25 | try: |
26 | 26 | yuyu=open('./concore.yuyu',newline=None).readline().rstrip() |
27 | | - except: |
| 27 | + except (OSError, IOError): |
28 | 28 | yuyu = 'yuyu' |
29 | 29 |
|
30 | 30 | try: |
31 | 31 | name1=open(concore.inpath+'1/concore.name1',newline=None).readline().rstrip() |
32 | | -except: |
| 32 | +except (OSError, IOError): |
33 | 33 | try: |
34 | 34 | name1=open('./concore.name1',newline=None).readline().rstrip() |
35 | | - except: |
| 35 | + except (OSError, IOError): |
36 | 36 | name1 = 'u' |
37 | 37 |
|
38 | 38 | try: |
39 | 39 | name2=open(concore.inpath+'1/concore.name2',newline=None).readline().rstrip() |
40 | | -except: |
| 40 | +except (OSError, IOError): |
41 | 41 | try: |
42 | 42 | name2=open('./concore.name2',newline=None).readline().rstrip() |
43 | | - except: |
| 43 | + except (OSError, IOError): |
44 | 44 | name2 = 'ym' |
45 | 45 |
|
46 | 46 | try: |
47 | 47 | init_simtime_u = open(concore.inpath+'1/concore.init1',newline=None).readline().rstrip() |
48 | | -except: |
| 48 | +except (OSError, IOError): |
49 | 49 | try: |
50 | 50 | init_simtime_u = open('./concore.init1',newline=None).readline().rstrip() |
51 | | - except: |
| 51 | + except (OSError, IOError): |
52 | 52 | init_simtime_u = "[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]" |
53 | 53 |
|
54 | 54 | try: |
55 | 55 | init_simtime_ym = open(concore.inpath+'1/concore.init2',newline=None).readline().rstrip() |
56 | | -except: |
| 56 | +except (OSError, IOError): |
57 | 57 | try: |
58 | 58 | init_simtime_ym = open('./concore.init2',newline=None).readline().rstrip() |
59 | | - except: |
| 59 | + except (OSError, IOError): |
60 | 60 | init_simtime_ym = "[0.0, 0.0, 0.0]" |
61 | 61 |
|
62 | 62 | logging.debug(f"API Key: {apikey}") |
|
92 | 92 | if len(r.text)!=0: |
93 | 93 | try: |
94 | 94 | t=literal_eval(r.text)[0] |
95 | | - except: |
| 95 | + except Exception: |
96 | 96 | logging.error(f"bad eval {r.text}") |
97 | 97 | timeout_count = 0 |
98 | 98 | t1 = time.perf_counter() |
|
104 | 104 | f = {'file1': open(concore.inpath+'1/'+name1, 'rb')} |
105 | 105 | try: |
106 | 106 | r = requests.post('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2, files=f,timeout=timeout_max) |
107 | | - except: |
| 107 | + except Exception: |
108 | 108 | logging.error("CW: bad request") |
109 | 109 | timeout_count += 1 |
110 | 110 | if r.status_code!=200 or time.perf_counter()-t1 > 1.1*timeout_max: #timeout_count>100: |
|
113 | 113 | if len(r.text)!=0: |
114 | 114 | try: |
115 | 115 | t=literal_eval(r.text)[0] |
116 | | - except: |
| 116 | + except Exception: |
117 | 117 | logging.error(f"bad eval {r.text}") |
118 | 118 | oldt = t |
119 | 119 | oldym = r.text |
|
0 commit comments