Пример #1
0
	def _on_clear_directory_button_pressed(self, event):
		event.Skip()
		path = self._LBL_directory.Label.strip().rstrip(os.sep).rstrip('/')
		if not os.path.isdir(path):
			return
		delete_data = gmGuiHelpers.gm_show_question (
			title = _('Clearing out a directory'),
			question = _(
				'Do you really want to delete all existing data\n'
				'from the following directory ?\n'
				'\n'
				' %s\n'
				'\n'
				'Note, this can NOT be reversed without backups.'
			) % path,
			cancel_button = False
		)
		if delete_data:
			gmTools.rm_dir_content(path)
			self.__update_ui_state()
Пример #2
0
    def _on_save_items_button_pressed(self, event):
        event.Skip()

        items = self._LCTRL_items.get_selected_item_data(only_one=False)
        if len(items) == 0:
            items = self._LCTRL_items.get_item_data()

        if len(items) == 0:
            return

        pat = gmPerson.gmCurrentPatient()
        dlg = cCreatePatientMediaDlg(self,
                                     -1,
                                     burn2cd=False,
                                     patient=pat,
                                     item_count=len(items))
        print("calling dlg.ShowModal()")
        choice = dlg.ShowModal()
        print("after returning from dlg.ShowModal()")
        if choice != wx.ID_SAVE:
            dlg.Destroy()
            return

        use_subdir = dlg._CHBOX_use_subdirectory.IsChecked()
        path = dlg._LBL_directory.Label.strip()
        remove_existing_data = dlg._RBTN_remove_data.Value is True
        generate_metadata = dlg._CHBOX_generate_metadata.IsChecked()
        dlg.Destroy()
        if use_subdir:
            path = gmTools.mk_sandbox_dir(prefix='%s-' % pat.subdir_name,
                                          base_dir=path)
        else:
            if remove_existing_data is True:
                if gmTools.rm_dir_content(path) is False:
                    gmGuiHelpers.gm_show_error(
                        title=_('Creating patient media'),
                        error=_('Cannot remove content from\n [%s]') % path)
                    return False

        exp_area = pat.export_area
        if generate_metadata:
            export_dir = exp_area.export(base_dir=path, items=items)
        else:
            export_dir = exp_area.dump_items_to_disk(base_dir=path,
                                                     items=items)

        self.save_soap_note(
            soap=_('Saved to [%s]:\n - %s') %
            (export_dir, '\n - '.join([i['description'] for i in items])))

        msg = _('Saved documents into directory:\n\n %s') % export_dir
        browse_index = gmGuiHelpers.gm_show_question(
            title=_('Creating patient media'),
            question=msg + '\n\n' + _('Browse patient data pack ?'),
            cancel_button=False)
        if browse_index:
            if generate_metadata:
                gmNetworkTools.open_url_in_browser(
                    url='file://%s' % os.path.join(export_dir, 'index.html'))
            else:
                gmMimeLib.call_viewer_on_file(export_dir, block=False)

        return True