Debian Codegraph @

fax/filters/pstotiff

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env python
2
3 import os
4 import os.path
5 import time
6 import sys
7 import tempfile
8
9 PY3 = sys.version_info[0] == 3
10
11 READ_SIZE = 8192
12
13 total_bytes_read = 0
14 temp_in_file = "-"
15
16 if (len(sys.argv) > 6):
17 temp_in_file = sys.argv[6]
18
19 temp_out_handle, temp_out_fname = tempfile.mkstemp()
20
21 font = "-I/usr/share/cups/fonts"
22 device = "-sDEVICE=tiffg4 -dMaxStripSize=0 -r204x196 -dNOPAUSE -dBATCH -dSAFER -dPARANOIDSAFER -dSHORTERRORS -dWRITESYSTEMDICT -dGHOSTSCRIPT -sstdout=%stderr -sOutputFile=" + temp_out_fname + " " + temp_in_file
23
24 gs_command = "/usr/bin/gs" + " " + font + " " + device
25
26 exit_code = os.system(gs_command)
27
28 file_len = os.stat(temp_out_fname).st_size
29 if (file_len < READ_SIZE):
30 READ_SIZE = file_len
31
32 os.close(temp_out_handle)
33
34 out_handle = open(temp_out_fname, mode='rb')
35 while (total_bytes_read < file_len):
36 data = out_handle.read(READ_SIZE)
37 if PY3:
38 sys.stdout.buffer.write(data)
39 else:
40 sys.stdout.write(data)
41 total_bytes_read += READ_SIZE
42 out_handle.close()
43
44 os.remove(temp_out_fname)
45 sys.exit(0)