Changeset d199ced for fedd


Ignore:
Timestamp:
Oct 14, 2008 5:35:15 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
3925b50
Parents:
0b466d1
Message:

upgrade

Location:
fedd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd.py

    r0b466d1 rd199ced  
    2020from threading import *
    2121from signal import signal, pause, SIGINT, SIGTERM
    22 from select import select
     22from select import select, error
    2323from time import sleep
    2424import logging
     
    251251    """
    252252    global servers_active, flog
     253
    253254    servers_active = False
    254255    flog.info("Received signal %d, shutting down" % sig);
     
    267268
    268269    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
    271278
    272279    # Done.  Remove us from the list
     
    356363# Main thread waits for signals
    357364while servers_active:
    358     pause()
     365    sleep(1.0)
    359366
    360367#Once shutdown starts wait for all the servers to terminate.
  • fedd/fedd_experiment_control.py

    r0b466d1 rd199ced  
    344344            f = open(self.state_filename, "r")
    345345            self.state = pickle.load(f)
     346            self.log.debug("[read_state]: Read state from %s" % \
     347                    self.state_filename)
    346348        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))
    349351        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)
    351354
    352355    def scp_file(self, file, user, host, dest=""):
     
    359362        rv = 0
    360363
     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
    361370        self.log.debug("[scp_file]: %s" % " ".join(scp_cmd))
    362371        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)
    364374
    365375        return rv == 0
     
    372382        sh_str = "%s %s@%s %s" % (self.ssh_exec, user, host, cmd)
    373383
     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
    374390        self.log.debug("[ssh_cmd]: %s" % sh_str)
    375391        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)
    377396            return sub.wait() == 0
    378397        else:
  • fedd/fedd_util.py

    r0b466d1 rd199ced  
    286286
    287287
    288 def generate_fedid(subj, bits=2048, log=None, dir=None, trace=None):
     288def generate_fedid(subj, bits=2048, log=None, dir=None, trace=sys.stderr):
    289289    """
    290290    Create a new certificate and derive a fedid from it.
     
    302302                    suffix=".pem")
    303303
    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]
    307308
    308309            if log:
     
    310311
    311312            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")
    313316
    314317            rv = subprocess.call(cmd, stdout=call_out, stderr=call_out)
     318            log.debug("rv = %d" % rv)
    315319            if rv == 0:
    316320                cert = ""
     
    323327                return (fid, cert)
    324328            else:
    325                 return None
     329                return (None, None)
    326330        except IOError, e:
    327331            raise e
Note: See TracChangeset for help on using the changeset viewer.