Changeset 11544:989ba559a51d in orange


Ignore:
Timestamp:
05/23/13 17:35:03 (11 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added error checking in 'check_can_save'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/application/canvasmain.py

    r11543 r11544  
    10171017        """ 
    10181018        Check if saving the document to `path` would prevent it from 
    1019         being read by the version 1.0 of scheme parser. 
     1019        being read by the version 1.0 of scheme parser. Return ``True`` 
     1020        if the existing scheme is version 1.0 else show a message box and 
     1021        return ``False`` 
     1022 
     1023        .. note:: 
     1024            In case of an error (opening, parsing), this method will return 
     1025            ``True``, so the 
    10201026 
    10211027        """ 
    10221028        if path and os.path.exists(path): 
    1023             version = sniff_version(open(path, "rb")) 
     1029            try: 
     1030                version = sniff_version(open(path, "rb")) 
     1031            except (IOError, OSError): 
     1032                log.error("Error opening '%s'", path, exc_info=True) 
     1033                # The client should fail attempting to write. 
     1034                return True 
     1035            except Exception: 
     1036                log.error("Error sniffing scheme version in '%s'", path, 
     1037                          exc_info=True) 
     1038                # Malformed .ows file, ... 
     1039                return True 
     1040 
    10241041            if version == "1.0": 
     1042                # TODO: Ask for overwrite confirmation instead 
    10251043                message_information( 
    10261044                    self.tr("Can not overwrite a version 1.0 ows file. " 
Note: See TracChangeset for help on using the changeset viewer.