13
13
<key >display_name </key >
14
14
<string >DISPLAY_NAME </string >
15
15
<key >installcheck_script </key >
16
- <string >#!/usr/bin/ python
16
+ <string >#!/usr/local/munki/munki- python
17
17
import subprocess
18
18
import sys
19
19
import shlex
20
20
21
21
printerOptions = { OPTIONS }
22
22
23
23
cmd = ['/usr/bin/lpoptions', '-p', 'PRINTERNAME', '-l']
24
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
24
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True )
25
25
(lpoptLongOut, lpoptErr) = proc.communicate()
26
26
27
27
# lpoptions -p printername -l will still exit 0 even if printername does not exist
@@ -51,6 +51,11 @@ for option in lpoptLongOut.splitlines():
51
51
print("Found mismatch: %s is '%s', should be '%s'" % (myOption, printerOptions[myOption], actualOptionValue))
52
52
sys.exit(0)
53
53
54
+ try:
55
+ lpoptOut = lpoptOut.decode("utf-8")
56
+ except UnicodeDecodeError:
57
+ sys.exit(0)
58
+
54
59
optionDict = {}
55
60
for builtOption in shlex.split(lpoptOut):
56
61
try:
@@ -66,23 +71,24 @@ for keyName in comparisonDict.keys():
66
71
print("Settings mismatch: %s is '%s', should be '%s'" % (keyName, optionDict[keyName], comparisonDict[keyName]))
67
72
sys.exit(0)
68
73
69
- sys.exit(1) </string >
74
+ sys.exit(1)
75
+ </string >
70
76
<key >installer_type </key >
71
77
<string >nopkg </string >
72
78
<key >minimum_os_version </key >
73
79
<string >10.7.0 </string >
74
80
<key >name </key >
75
81
<string >AddPrinter_DISPLAYNAME </string >
76
82
<key >postinstall_script </key >
77
- <string >#!/usr/bin/ python
83
+ <string >#!/usr/local/munki/munki- python
78
84
import subprocess
79
85
import sys
80
86
81
87
# Populate these options if you want to set specific options for the printer. E.g. duplexing installed, etc.
82
88
printerOptions = { OPTIONS }
83
89
84
90
cmd = [ '/usr/sbin/lpadmin', '-x', 'PRINTERNAME' ]
85
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
91
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True )
86
92
(lpadminxOut, lpadminxErr) = proc.communicate()
87
93
88
94
# Install the printer
@@ -100,19 +106,19 @@ for option in printerOptions.keys():
100
106
cmd.append("-o")
101
107
cmd.append(str(option) + "=" + str(printerOptions[option]))
102
108
103
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
109
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True )
104
110
(lpadminOut, lpadminErr) = proc.communicate()
105
111
106
112
if lpadminErr:
107
- if "Printer drivers are deprecated" in lpadminErr:
113
+ if "Printer drivers are deprecated" in lpadminErr or "Reine Wartelisten wurden verworfen" in lpadminErr :
108
114
# work around lpadmin deprecation message
109
- print "Install successful - caught deprecation message; preventing exit 1"
110
- pass
115
+ print("Install successful - caught deprecation message; preventing exit 1")
111
116
else:
112
- print "Error: %s" % lpadminErr
117
+ print( "Error: %s" % lpadminErr)
113
118
sys.exit(1)
114
119
print("Results: %s" % lpadminOut)
115
- sys.exit(0) </string >
120
+ sys.exit(0)
121
+ </string >
116
122
<key >unattended_install </key >
117
123
<true />
118
124
<key >uninstall_method </key >
0 commit comments