- Timestamp:
- Oct 14, 2008 5:35:15 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 3925b50
- Parents:
- 0b466d1
- Location:
- fedd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd.py
r0b466d1 rd199ced 20 20 from threading import * 21 21 from signal import signal, pause, SIGINT, SIGTERM 22 from select import select 22 from select import select, error 23 23 from time import sleep 24 24 import logging … … 251 251 """ 252 252 global servers_active, flog 253 253 254 servers_active = False 254 255 flog.info("Received signal %d, shutting down" % sig); … … 267 268 268 269 while servers_active: 269 i, o, e = select((s,), (), (), 5.0) 270 if s in i: s.handle_request() 270 try: 271 i, o, e = select((s,), (), (), 1.0) 272 if s in i: s.handle_request() 273 except error: 274 # The select call seems to get interrupted by signals as well as 275 # the main thread. This essentially ignores signals in this 276 # thread. 277 pass 271 278 272 279 # Done. Remove us from the list … … 356 363 # Main thread waits for signals 357 364 while servers_active: 358 pause()365 sleep(1.0) 359 366 360 367 #Once shutdown starts wait for all the servers to terminate. -
fedd/fedd_experiment_control.py
r0b466d1 rd199ced 344 344 f = open(self.state_filename, "r") 345 345 self.state = pickle.load(f) 346 self.log.debug("[read_state]: Read state from %s" % \ 347 self.state_filename) 346 348 except IOError, e: 347 self.log.warning(" No saved state: Can't open %s: %s" %\348 (self.state_filename, e))349 self.log.warning("[read_state]: No saved state: Can't open %s: %s"\ 350 % (self.state_filename, e)) 349 351 except pickle.UnpicklingError, e: 350 self.log.warning("No saved state: Unpickling failed: %s" % e) 352 self.log.warning(("[read_state]: No saved state: " + \ 353 "Unpickling failed: %s") % e) 351 354 352 355 def scp_file(self, file, user, host, dest=""): … … 359 362 rv = 0 360 363 364 try: 365 dnull = open("/dev/null", "r") 366 except IOError: 367 self.log.debug("[ssh_file]: failed to open /dev/null for redirect") 368 dnull = Null 369 361 370 self.log.debug("[scp_file]: %s" % " ".join(scp_cmd)) 362 371 if not self.debug: 363 rv = call(scp_cmd, stdout=trace, stderr=trace) 372 if dnull: rv = call(scp_cmd, stdout=dnull, stderr=dnull) 373 else: rv = call(scp_cmd) 364 374 365 375 return rv == 0 … … 372 382 sh_str = "%s %s@%s %s" % (self.ssh_exec, user, host, cmd) 373 383 384 try: 385 dnull = open("/dev/null", "r") 386 except IOError: 387 self.log.debug("[ssh_cmd]: failed to open /dev/null for redirect") 388 dnull = Null 389 374 390 self.log.debug("[ssh_cmd]: %s" % sh_str) 375 391 if not self.debug: 376 sub = Popen(sh_str, shell=True, stdout=trace, stderr=trace) 392 if dnull: 393 sub = Popen(sh_str, shell=True, stdout=dnull, stderr=dnull) 394 else: 395 sub = Popen(sh_str, shell=True) 377 396 return sub.wait() == 0 378 397 else: -
fedd/fedd_util.py
r0b466d1 rd199ced 286 286 287 287 288 def generate_fedid(subj, bits=2048, log=None, dir=None, trace= None):288 def generate_fedid(subj, bits=2048, log=None, dir=None, trace=sys.stderr): 289 289 """ 290 290 Create a new certificate and derive a fedid from it. … … 302 302 suffix=".pem") 303 303 304 cmd = ["openssl", "req", "-text", "-newkey", "rsa:%d" % bits, 305 "-keyout", keypath, "-nodes", "-subj", "/CN=%s" % subj, 306 "-x509", "-days", "30", "-out", certpath] 304 cmd = ["/usr/bin/openssl", "req", "-text", "-newkey", 305 "rsa:%d" % bits, "-keyout", keypath, "-nodes", 306 "-subj", "/CN=%s" % subj, "-x509", "-days", "30", 307 "-out", certpath] 307 308 308 309 if log: … … 310 311 311 312 if trace: call_out = trace 312 else: call_out = open("/dev/null", "w") 313 else: 314 log.debug("set to dev/null") 315 call_out = open("/dev/null", "w") 313 316 314 317 rv = subprocess.call(cmd, stdout=call_out, stderr=call_out) 318 log.debug("rv = %d" % rv) 315 319 if rv == 0: 316 320 cert = "" … … 323 327 return (fid, cert) 324 328 else: 325 return None329 return (None, None) 326 330 except IOError, e: 327 331 raise e
Note: See TracChangeset
for help on using the changeset viewer.