comparison py/receive.py @ 230:185621f47040

run 2to3
author Matt Johnston <matt@ucc.asn.au>
date Fri, 10 Apr 2015 23:59:16 +0800
parents e27075b1e088
children
comparison
equal deleted inserted replaced
229:99255c501e02 230:185621f47040
26 i = sys.stdin.read() 26 i = sys.stdin.read()
27 new_params = json.loads(i) 27 new_params = json.loads(i)
28 28
29 def_params = params.Params() 29 def_params = params.Params()
30 30
31 if def_params.viewkeys() != new_params.viewkeys(): 31 if def_params.keys() != new_params.keys():
32 diff = def_params.viewkeys() ^ new_params.viewkeys() 32 diff = def_params.keys() ^ new_params.keys()
33 return "Mismatching params, %s" % str(diff) 33 return "Mismatching params, %s" % str(diff)
34 34
35 for k, v in new_params.items(): 35 for k, v in new_params.items():
36 if not same_type(v, def_params[k]): 36 if not same_type(v, def_params[k]):
37 return "Bad type for %s" % k 37 return "Bad type for %s" % k
46 t.write(json.dumps(new_params, sort_keys=True, indent=4)+'\n') 46 t.write(json.dumps(new_params, sort_keys=True, indent=4)+'\n')
47 name = t.name 47 name = t.name
48 t.close() 48 t.close()
49 49
50 os.rename(name, config.PARAMS_FILE) 50 os.rename(name, config.PARAMS_FILE)
51 except Exception, e: 51 except Exception as e:
52 return "Problem: %s" % e 52 return "Problem: %s" % e
53 53
54 try: 54 try:
55 pid = int(open('%s/tempserver.pid' % dir, 'r').read()) 55 pid = int(open('%s/tempserver.pid' % dir, 'r').read())
56 if pid < 2: 56 if pid < 2:
57 return "Bad pid %d" % pid 57 return "Bad pid %d" % pid
58 os.kill(pid, signal.SIGHUP) 58 os.kill(pid, signal.SIGHUP)
59 except Exception, e: 59 except Exception as e:
60 return "HUP problem: %s" % e 60 return "HUP problem: %s" % e
61 61
62 return 'Good Update' 62 return 'Good Update'
63 63
64 if __name__ == '__main__': 64 if __name__ == '__main__':
65 print main() 65 print(main())
66 66