Changeset 213:206190c8a76e for src/mlx


Ignore:
Timestamp:
05/31/12 17:33:47 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Fixed some minor problems with the PyUIPC simulator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/pyuipc_sim.py

    r212 r213  
    781781#------------------------------------------------------------------------------
    782782
    783 def prepare_data(pattern, forRead = True):
     783def prepare_data(pattern, forRead = True, checkOpened = True):
    784784    """Prepare the given pattern for reading and/or writing."""
    785     if opened:
     785    if not checkOpened or opened:
    786786        return pattern
    787787    else:
    788         raise FSUIPCException(ERR_OPEN)
    789        
    790 #------------------------------------------------------------------------------
    791 
    792 def read(data):
     788        raise FSUIPCException(ERR_NOTOPEN)
     789       
     790#------------------------------------------------------------------------------
     791
     792def read(data, checkOpened = True):
    793793    """Read the given data."""
    794     if opened:
     794    if not checkOpened or opened:
    795795        return [values.read(offset, type) for (offset, type) in data]
    796796    else:
    797         raise FSUIPCException(ERR_OPEN)
     797        raise FSUIPCException(ERR_NOTOPEN)
    798798           
    799799#------------------------------------------------------------------------------
    800800
    801 def write(data):
     801def write(data, checkOpened = True):
    802802    """Write the given data."""
    803     if opened:
     803    if not checkOpened or opened:
    804804        for (offset, type, value) in data:
    805805            values.write(offset, value, type)
    806806    else:
    807         raise FSUIPCException(ERR_OPEN)
     807        raise FSUIPCException(ERR_NOTOPEN)
    808808           
    809809#------------------------------------------------------------------------------
     
    863863                try:
    864864                    if call==CALL_READ:
    865                         result = read(args[0])
     865                        result = read(args[0], checkOpened = False)
    866866                    elif call==CALL_WRITE:
    867                         result = write(args[0])
     867                        result = write(args[0], checkOpened = False)
    868868                    elif call==CALL_SETVERSION:
    869869                        global fs_version
     
    886886                    data = cPickle.dumps((RESULT_RETURNED, result))
    887887                else:
    888                     data = cPickle.dumps((RESULT_EXCEPTION, exception))
     888                    data = cPickle.dumps((RESULT_EXCEPTION, str(exception)))
    889889                clientSocket.send(struct.pack("I", len(data)) + data)
    890890        except Exception, e:
     
    944944            return result
    945945        else:
    946             raise result       
     946            raise Exception(result)
    947947
    948948#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.