Changeset 213:206190c8a76e
- Timestamp:
- 05/31/12 17:33:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/pyuipc_sim.py
r212 r213 781 781 #------------------------------------------------------------------------------ 782 782 783 def prepare_data(pattern, forRead = True ):783 def prepare_data(pattern, forRead = True, checkOpened = True): 784 784 """Prepare the given pattern for reading and/or writing.""" 785 if opened:785 if not checkOpened or opened: 786 786 return pattern 787 787 else: 788 raise FSUIPCException(ERR_ OPEN)789 790 #------------------------------------------------------------------------------ 791 792 def read(data ):788 raise FSUIPCException(ERR_NOTOPEN) 789 790 #------------------------------------------------------------------------------ 791 792 def read(data, checkOpened = True): 793 793 """Read the given data.""" 794 if opened:794 if not checkOpened or opened: 795 795 return [values.read(offset, type) for (offset, type) in data] 796 796 else: 797 raise FSUIPCException(ERR_ OPEN)797 raise FSUIPCException(ERR_NOTOPEN) 798 798 799 799 #------------------------------------------------------------------------------ 800 800 801 def write(data ):801 def write(data, checkOpened = True): 802 802 """Write the given data.""" 803 if opened:803 if not checkOpened or opened: 804 804 for (offset, type, value) in data: 805 805 values.write(offset, value, type) 806 806 else: 807 raise FSUIPCException(ERR_ OPEN)807 raise FSUIPCException(ERR_NOTOPEN) 808 808 809 809 #------------------------------------------------------------------------------ … … 863 863 try: 864 864 if call==CALL_READ: 865 result = read(args[0] )865 result = read(args[0], checkOpened = False) 866 866 elif call==CALL_WRITE: 867 result = write(args[0] )867 result = write(args[0], checkOpened = False) 868 868 elif call==CALL_SETVERSION: 869 869 global fs_version … … 886 886 data = cPickle.dumps((RESULT_RETURNED, result)) 887 887 else: 888 data = cPickle.dumps((RESULT_EXCEPTION, exception))888 data = cPickle.dumps((RESULT_EXCEPTION, str(exception))) 889 889 clientSocket.send(struct.pack("I", len(data)) + data) 890 890 except Exception, e: … … 944 944 return result 945 945 else: 946 raise result946 raise Exception(result) 947 947 948 948 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.