Skip to content

Cancel save of SWC file triggers a file not found error #13

Description

@cudmore

While this does not cause problems, we should fix it. When user cancels the saving of a swc file, a file not found error is trigger. Should be simple to fix.

Here is the error trace

   INFO _widget.py save_tracing() line:678 - Saving tracing...
2023-07-14 09:56:50.864 napari[3353:32372405] +[CATransaction synchronize] called within transaction
   INFO _widget.py save_tracing() line:687 - Saving file as 
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
File ~/opt/miniconda3/envs/bright-env/lib/python3.9/site-packages/napari_tracing/_widget.py:692, in TracerWidget.save_tracing(self=<napari_tracing._widget.TracerWidget object>)
    690 segments = self.traced_segments[active_layer_id]
    691 trace_saver = TraceSaver(fileName[0], segments)
--> 692 trace_saver.save_trace()
        trace_saver = <napari_tracing._trace_saver.TraceSaver object at 0x7fc628b6d910>

File ~/opt/miniconda3/envs/bright-env/lib/python3.9/site-packages/napari_tracing/_trace_saver.py:13, in TraceSaver.save_trace(self=<napari_tracing._trace_saver.TraceSaver object>)
     12 def save_trace(self):
---> 13     with open(self.filename, "w") as f:
        self.filename = ''
        self = <napari_tracing._trace_saver.TraceSaver object at 0x7fc628b6d910>
     14         writer = csv.writer(f)
     15         column_headers = ["idx", "x", "y", "z", "prevIdx"]

FileNotFoundError: [Errno 2] No such file or directory: ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions