Beispiel #1
0
 def cleanup(self, shutdown = False):
     if self.__ready:
         superClass.cleanup(self, shutdown)
         LOG("Cleanup standalone CFG interface")
         REGISTRY['SIM'].cleanup()
         REGISTRY.remove('SIM')
         self.__ready = False
Beispiel #2
0
 def _doAction(self, action):
     """
     DESCRIPTION:
         Execute the desired action implementation.
         WARNING: no exception handling is done here. If a new action is
         implemented and it is possible that this action raise an exception,
         it should be handled here.
         
     ARGUMENTS:
         action      The action code identifying the method to be executed.
         
     RETURNS:
         Tuple containing [ Repeat, Object ] where Repeat must be boolean.
         If Repeat is true, the operation is repeated. Object is used
         when returning data after the operation is required.
         
     RAISES:
         Nothing
     """
     
     self._selectedAction = action
     LOG("Performing action: " + repr(action), level = LOG_LANG )
     if action == ACTION_ABORT:
         self._write("Execution aborted by user", {Severity:WARNING} )
         if REGISTRY.exists('EXEC'):
             REGISTRY['EXEC'].abort()
         return [False,False]
     elif action == ACTION_RESEND:
         self._notifyOpStatus( NOTIF_STATUS_PR, OPERATION_REPEAT )
         return self._doResend()
     elif action == ACTION_REPEAT:
         self._notifyOpStatus( NOTIF_STATUS_PR, OPERATION_REPEAT )
         return self._doRepeat()
     elif action == ACTION_RECHECK:
         self._notifyOpStatus( NOTIF_STATUS_PR, OPERATION_REPEAT )
         return self._doRecheck()
     elif action == ACTION_SKIP:
         self._notifyOpStatus( NOTIF_STATUS_SP, OPERATION_SKIPPED )
         return self._doSkip()       
     elif action == ACTION_NOACTION:
         return [False,True]       
     elif action == ACTION_CANCEL:
         self._notifyOpStatus( NOTIF_STATUS_CL, OPERATION_CANCELLED )
         return self._doCancel()       
     elif action == ACTION_HANDLE:
         self._notifyOpStatus( NOTIF_STATUS_SP, OPERATION_HANDLED )
         handle = Handle( code = self._failureCode, type = self._failureType, item = self._failureItem)
         raise handle       
     else:
         self._write("Unknown action: " + repr(action), {Severity:ERROR})
         if REGISTRY.exists('EXEC'):
             REGISTRY['EXEC'].abort()
         return [False,False]
Beispiel #3
0
def Cleanup():
    import __main__
    from spell.lib.drivermgr import DriverManager
    from spell.lib.registry import REGISTRY
    from server.ui.cmdline import ClientIF
    DriverManager.instance().cleanup(shutdown=True)
    for ifc in REGISTRY.interfaces():
        REGISTRY.remove(ifc)
        if __main__.__dict__.has_key(ifc):
            __main__.__dict__.pop(ifc)
    if 'CIF' in REGISTRY.interfaces():
        ClientIF.cleanup()
Beispiel #4
0
def Cleanup():
    import __main__
    from spell.lib.drivermgr import DriverManager
    from spell.lib.registry import REGISTRY
    from server.ui.cmdline import ClientIF

    DriverManager.instance().cleanup(shutdown=True)
    for ifc in REGISTRY.interfaces():
        REGISTRY.remove(ifc)
        if __main__.__dict__.has_key(ifc):
            __main__.__dict__.pop(ifc)
    if "CIF" in REGISTRY.interfaces():
        ClientIF.cleanup()
Beispiel #5
0
    def _doAction(self, action):
        """
        DESCRIPTION:
            Execute the desired action implementation.
            WARNING: no exception handling is done here. If a new action is
            implemented and it is possible that this action raise an exception,
            it should be handled here.
            
        ARGUMENTS:
            action      The action code identifying the method to be executed.
            
        RETURNS:
            Tuple containing [ Repeat, Object ] where Repeat must be boolean.
            If Repeat is true, the operation is repeated. Object is used
            when returning data after the operation is required.
            
        RAISES:
            Nothing
        """

        self._selectedAction = action
        LOG("Performing action: " + repr(action), level=LOG_LANG)
        if action == ACTION_ABORT:
            self._write("Execution aborted by user", {Severity: WARNING})
            if REGISTRY.exists('EXEC'):
                REGISTRY['EXEC'].abort()
            return [False, False]
        elif action == ACTION_RESEND:
            self._notifyOpStatus(NOTIF_STATUS_PR, OPERATION_REPEAT)
            return self._doResend()
        elif action == ACTION_REPEAT:
            self._notifyOpStatus(NOTIF_STATUS_PR, OPERATION_REPEAT)
            return self._doRepeat()
        elif action == ACTION_RECHECK:
            self._notifyOpStatus(NOTIF_STATUS_PR, OPERATION_REPEAT)
            return self._doRecheck()
        elif action == ACTION_SKIP:
            self._notifyOpStatus(NOTIF_STATUS_SP, OPERATION_SKIPPED)
            return self._doSkip()
        elif action == ACTION_NOACTION:
            return [False, True]
        elif action == ACTION_CANCEL:
            self._notifyOpStatus(NOTIF_STATUS_CL, OPERATION_CANCELLED)
            return self._doCancel()
        else:
            self._write("Unknown action: " + repr(action), {Severity: ERROR})
            if REGISTRY.exists('EXEC'):
                REGISTRY['EXEC'].abort()
            return [False, False]
Beispiel #6
0
    import __main__
    from spell.lib.drivermgr import DriverManager
    from spell.lib.registry import REGISTRY
    from server.ui.cmdline import ClientIF
    from spell.config.reader import Config

    try:
        DriverManager.instance().setup(ctxName)
    except SpellException, ex:
        print "Unable to setup driver: ", ex.message, ex.reason
        DriverManager.instance().cleanup(force=True)
        return False

    FakeExecutor().setup()

    for ifc in REGISTRY.interfaces():
        __main__.__dict__[ifc] = REGISTRY[ifc]

    ClientIF.setup(ctxName)

    # Get builtin databases
    __main__.__dict__['SCDB'] = REGISTRY['DBMGR']['SCDB']
    __main__.__dict__['GDB'] = REGISTRY['DBMGR']['GDB']

    if showProgress:
        print
        print
        print "Importing interfaces"

    g_ctx = globals()
Beispiel #7
0
    import __main__
    from spell.lib.drivermgr import DriverManager
    from spell.lib.registry import REGISTRY
    from server.ui.cmdline import ClientIF
    from spell.config.reader import Config

    try:
        DriverManager.instance().setup(ctxName)
    except SpellException, ex:
        print "Unable to setup driver: ", ex.message, ex.reason
        DriverManager.instance().cleanup(force=True)
        return False

    FakeExecutor().setup()

    for ifc in REGISTRY.interfaces():
        __main__.__dict__[ifc] = REGISTRY[ifc]

    ClientIF.setup(ctxName)

    # Get builtin databases
    __main__.__dict__["SCDB"] = REGISTRY["DBMGR"]["SCDB"]
    __main__.__dict__["GDB"] = REGISTRY["DBMGR"]["GDB"]

    if showProgress:
        print
        print
        print "Importing interfaces"

    g_ctx = globals()
Beispiel #8
0
    def cnv(self, timestamp):
        
        mydt = datetime.datetime(1,1,1)
        evaluated = False
        datefmtlist = [ 
            '%Y.%j.%H.%M.%S',    '%Y.%j.%H.%M',    '%Y.%j',
            '%d-%b-%Y %H:%M:%S', '%d-%b-%Y %H:%M', '%d-%b-%Y',
            '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', '%Y-%m-%d',
            '%Y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M', '%Y/%m/%d',
            '%d/%m/%Y %H:%M:%S', '%d/%m/%Y %H:%M', '%d/%m/%Y',
            '%d-%m-%Y %H:%M:%S', '%d-%m-%Y %H:%M', '%d-%m-%Y',
            '%d-%b-%Y:%H:%M:%S', '%d-%b-%Y:%H:%M', '%d-%b-%Y',
            '%Y-%m-%d:%H:%M:%S', '%Y-%m-%d:%H:%M', '%Y-%m-%d',
            '%Y/%m/%d:%H:%M:%S', '%Y/%m/%d:%H:%M', '%Y/%m/%d',
            '%d/%m/%Y:%H:%M:%S', '%d/%m/%Y:%H:%M', '%d/%m/%Y',
            '%d-%m-%Y:%H:%M:%S', '%d-%m-%Y:%H:%M', '%d-%m-%Y',
        ]
        
        abshourfmtlist = [
            '%H.%M.%S', '%H:%M:%S', '%H:%M:%S', '%H:%M',
        ]

        # Split timestamp and microseconds

        ms = 0
        
        if isinstance(timestamp, float):
            ms = (timestamp - int(timestamp)) * 1000000
        
        elif isinstance(timestamp, str):
            # Check if the seconds are in mm:ss format. Otherwise dont check for microsecods
            if not timestamp.find(':') == -1:
                items = timestamp.split('.')
                timestamp = items[0]
                if len(items) > 1: ms = int(items[1].ljust(6, '0'))

        # - ISO, European or OpenVMS date formats
        for fmt in datefmtlist:
            if not evaluated:
                try:
                    val = mydt.strptime(timestamp, fmt)
                    val = val.replace(microsecond = ms)
                    self.__fmt = fmt;
                    evaluated = True
                except:
                    pass
        
        # - <int> or <float>
                
        if not evaluated and (isinstance(timestamp, int) or isinstance(timestamp, float) or isinstance(timestamp, long)):
            dd = int(timestamp / (3600 * 24)) 
            hh = int(timestamp / 3600) % 24
            mm = int(timestamp / 60) % 60 
            ss = int(timestamp) % 60

            val = datetime.timedelta(days = dd, hours=hh, minutes=mm, seconds=ss, microseconds=ms)
            
            evaluated = True     
            
        # +|-[dd] hh:mm[:ss]
                
        if not evaluated:
            try:
                tmp = timestamp
                if tmp[0] in ('+', '-'):
                    # Capture the sign ('+' in '+dd hh:mm:ss') and remove it
                    sign = 1
                    if tmp[0] == '-':
                        sign = -1
                    tmp = tmp[1:]
                    
                    # Capture the day ('dd' in 'dd hh:mm:ss' if 'dd' exists)
                    items = tmp.split(' ')                    
                    mytime = items[0]
                    dd = 0
                    
                    # In case we have '+hh:mm:ss' days = 0 and we go on with the time)
                    if len(items) == 2:
                        dd = eval(items[0].lstrip('0') or '0')
                        mytime = items[1]
                        
                    # Capture the time ('hh' 'mm' and 'ss' in 'hh:mm:ss')
                    items = mytime.split(':')
                    hh = eval(items[0].lstrip('0') or '0')
                    mm = eval(items[1].lstrip('0') or '0')
                    ss = int(eval(items[2].lstrip('0') or '0'))
                    
                    # Normalize in case we have hours > 23
                    # E.g. +2 26:00:00 becomes +3 02:00:00
                    dd = dd + hh // 24
                    hh = hh % 24

                    # Apply the sign
                    dd = dd * sign
                    hh = hh * sign
                    mm = mm * sign
                    ss = ss * sign
                    ms = ms * sign
                    
                    val = datetime.timedelta(days = dd, hours=hh, minutes=mm, seconds=ss, microseconds=ms)
                    
                    evaluated = True
            except:
                pass


        # Evaluated TODAY, NOW, YESTERDAY and TOMORROW
        
        if not evaluated:
            evaluated = True
            if REGISTRY.exists('TIME'):
                val = REGISTRY['TIME'].getUTC()
            else:
                val = datetime.datetime.utcnow()
            if timestamp != NOW_STR:
                val = val.replace(hour=0, minute=0, second=0, microsecond=0)
                if timestamp == YESTERDAY_STR:
                    val = val - datetime.timedelta(days = 1)
                elif timestamp == TOMORROW_STR:
                    val = val + datetime.timedelta(days = 1)
                elif timestamp != TODAY_STR:
                    evaluated = False
                            
        # - hh:mm[:ss] is TODAY at hh:mm[:ss]

        for fmt in abshourfmtlist:
            if not evaluated:
                try:
                    mydt = mydt.strptime(timestamp, fmt)
                    val = REGISTRY['TIME'].getUTC()
                    val = val.replace(hour=mydt.hour, minute=mydt.minute, 
                                      second=mydt.second, microsecond=ms)
                    evaluated = True
                except:
                    pass
        
        if evaluated:
            return val

        return None
Beispiel #9
0
from spell.lib.registry import REGISTRY

try:
    print REGISTRY.interfaces()
    print dir(REGISTRY['EXEC'])
except BaseException, ex:
    print "TEST FAILED", str(ex)
Beispiel #10
0
from spell.lib.registry import REGISTRY
    
try:
    print REGISTRY.interfaces()
    print dir(REGISTRY['EXEC'])
except BaseException,ex:
    print "TEST FAILED",str(ex)