1 """GNUmed printing."""
2
3
4
5 __version__ = "$Revision: 1.4 $"
6 __author__ = "K.Hilbert <Karsten.Hilbert@gmx.net>"
7 __license__ = 'GPL (details at http://www.gnu.org)'
8
9
10 import logging, sys
11
12
13 if __name__ == '__main__':
14 sys.path.insert(0, '../../')
15 from Gnumed.pycommon import gmLog2
16 from Gnumed.pycommon import gmI18N
17 gmI18N.activate_locale()
18 gmI18N.install_domain()
19
20
21 from Gnumed.pycommon import gmShellAPI
22
23
24 _log = logging.getLogger('gm.printing')
25 _log.info(__version__)
26
27
28 known_printjob_types = [
29 u'medication_list',
30 u'generic_document'
31 ]
32
33
35
36 _log.debug('printing "%s": [%s]', jobtype, filename)
37
38 if jobtype not in known_printjob_types:
39 print "unregistered print job type <%s>" % jobtype
40 _log.warning('print job type "%s" not registered')
41
42 candidates = [u'gm-print_doc', u'gm-print_doc.bat']
43 args = u' %s %s' % (jobtype, filename)
44
45 success = gmShellAPI.run_first_available_in_shell (
46 binaries = candidates,
47 args = args,
48 blocking = True,
49 run_last_one_anyway = True
50 )
51
52 if success:
53 return True
54
55 _log.error('print command failed')
56 return False
57
58
59
60 if __name__ == '__main__':
61
64
65 if len(sys.argv) > 1 and sys.argv[1] == 'test':
66 print test_print_file()
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85