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