Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created August 14, 2023 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfmoraes/69cb9186c5478fd842933acf78ad8426 to your computer and use it in GitHub Desktop.
Save tfmoraes/69cb9186c5478fd842933acf78ad8426 to your computer and use it in GitHub Desktop.
diff --git a/invesalius/gui/network/text_panel.py b/invesalius/gui/network/text_panel.py
index ce22c2e0..6c6a5d31 100644
--- a/invesalius/gui/network/text_panel.py
+++ b/invesalius/gui/network/text_panel.py
@@ -5,6 +5,7 @@ from invesalius import inv_paths
import wx.gizmos as gizmos
import wx
import os
+import pathlib
myEVT_SELECT_PATIENT = wx.NewEventType()
EVT_SELECT_PATIENT = wx.PyEventBinder(myEVT_SELECT_PATIENT, 1)
@@ -96,9 +97,9 @@ class TextPanel(wx.Panel):
if self.__session.GetConfig('server_port') \
else 11120
- self.__store_path = self.__session.GetConfig('store_path') \
+ self.__store_path = pathlib.Path(self.__session.GetConfig('store_path')) \
if self.__session.GetConfig('store_path') \
- else str(inv_paths.USER_DICOM_DIR)
+ else inv_paths.USER_DICOM_DIR
def _populate(self, patients):
""" Populate tree. """
@@ -180,35 +181,28 @@ class TextPanel(wx.Panel):
patient_id, series_id = series_data
if self.__selected is None:
-
wx.MessageBox(_("Please select a node"), _("Error"), wx.OK | wx.ICON_ERROR)
return
- dest = f"{self.__store_path}/{patient_id}/{series_id}"
- if not(os.path.exists(dest)):
-
- os.makedirs(dest)
-
- dn = dcm_net.DicomNet()
- dn.SetHost(self.__selected['ipaddress'])
- dn.SetPort(self.__selected['port'])
- dn.SetAETitle(self.__selected['aetitle'])
- dn.SetAETitleCall(self.__server_aetitle)
- dn.SetPortCall(self.__server_port)
- dn.SetIPCall(self.__server_ip)
-
- try:
-
- dn.RunCMove({'patient_id': patient_id, 'serie_id': series_id, 'destination': dest})
-
- except Exception as e:
-
- wx.MessageBox(str(e), _("Error"), wx.OK | wx.ICON_ERROR)
- return
+ dest = self.__store_path.joinpath(patient_id, series_id)
+ dest.mkdir(parents=True, exist_ok=True)
+ dn = dcm_net.DicomNet()
+ dn.SetHost(self.__selected['ipaddress'])
+ dn.SetPort(self.__selected['port'])
+ dn.SetAETitle(self.__selected['aetitle'])
+ dn.SetAETitleCall(self.__server_aetitle)
+ dn.SetPortCall(self.__server_port)
+ dn.SetIPCall(self.__server_ip)
+
+ try:
+ dn.RunCMove({'patient_id': patient_id, 'serie_id': series_id, 'destination': str(dest)})
+ except Exception as e:
+ wx.MessageBox(str(e), _("Error"), wx.OK | wx.ICON_ERROR)
+ return
Publisher.sendMessage("Hide import network panel")
- Publisher.sendMessage('Import directory', directory=dest, use_gui=False)
+ Publisher.sendMessage('Import directory', directory=str(dest), use_gui=False)
def _on_size(self, evt):
- self.__tree.SetSize(self.GetSize())
\ No newline at end of file
+ self.__tree.SetSize(self.GetSize())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment