|
Lines 38-43
Link Here
|
| 38 |
import univention.admin.config |
38 |
import univention.admin.config |
| 39 |
import univention.admin.uldap |
39 |
import univention.admin.uldap |
| 40 |
|
40 |
|
|
|
41 |
|
| 41 |
class UpdatePrinterModels(object): |
42 |
class UpdatePrinterModels(object): |
| 42 |
|
43 |
|
| 43 |
def __init__(self, options, obsolete): |
44 |
def __init__(self, options, obsolete): |
|
Lines 51-57
def __init__(self, options, obsolete):
Link Here
|
| 51 |
univention.admin.modules.init(self.lo, self.position, self.models) |
52 |
univention.admin.modules.init(self.lo, self.position, self.models) |
| 52 |
|
53 |
|
| 53 |
def ldap_connection(self): |
54 |
def ldap_connection(self): |
| 54 |
self.co = univention.admin.config.config() |
|
|
| 55 |
if self.options.binddn and self.options.bindpwd: |
55 |
if self.options.binddn and self.options.bindpwd: |
| 56 |
self.lo = univention.admin.uldap.access( |
56 |
self.lo = univention.admin.uldap.access( |
| 57 |
host=self.ucr['ldap/master'], |
57 |
host=self.ucr['ldap/master'], |
|
Lines 87-93
def check_duplicates(self):
Link Here
|
| 87 |
ldap_models = attr.get('printerModel', []) |
87 |
ldap_models = attr.get('printerModel', []) |
| 88 |
new_ldap_models = list() |
88 |
new_ldap_models = list() |
| 89 |
ppds = dict() |
89 |
ppds = dict() |
| 90 |
change = False |
|
|
| 91 |
for model in ldap_models: |
90 |
for model in ldap_models: |
| 92 |
ppd = model.split('"')[1] |
91 |
ppd = model.split('"')[1] |
| 93 |
if ppd in ppds: |
92 |
if ppd in ppds: |
|
Lines 96-102
def check_duplicates(self):
Link Here
|
| 96 |
ppds[ppd] = [model] |
95 |
ppds[ppd] = [model] |
| 97 |
for ppd in ppds: |
96 |
for ppd in ppds: |
| 98 |
if len(ppds[ppd]) > 1: |
97 |
if len(ppds[ppd]) > 1: |
| 99 |
_tmp, new_description =self.get_description_from_ppd(ppd) |
98 |
_tmp, new_description = self.get_description_from_ppd(ppd) |
| 100 |
new_ldap_models.append('"%s" "%s"' % (ppd, new_description)) |
99 |
new_ldap_models.append('"%s" "%s"' % (ppd, new_description)) |
| 101 |
else: |
100 |
else: |
| 102 |
new_ldap_models.append(ppds[ppd][0]) |
101 |
new_ldap_models.append(ppds[ppd][0]) |
|
Lines 110-116
def check_duplicates(self):
Link Here
|
| 110 |
self.lo.modify(dn, changes) |
109 |
self.lo.modify(dn, changes) |
| 111 |
|
110 |
|
| 112 |
def mark_as_obsolete(self): |
111 |
def mark_as_obsolete(self): |
| 113 |
obj = self.models.lookup(self.co, self.lo, ldap.filter.filter_format('name=%s', [options.name])) |
112 |
obj = self.models.lookup(None, self.lo, ldap.filter.filter_format('name=%s', [options.name])) |
| 114 |
if obj: |
113 |
if obj: |
| 115 |
obj = obj[0] |
114 |
obj = obj[0] |
| 116 |
obj.open() |
115 |
obj.open() |
|
Lines 134-139
def mark_as_obsolete(self):
Link Here
|
| 134 |
if options.verbose: |
133 |
if options.verbose: |
| 135 |
print 'info: %s modified' % obj.dn |
134 |
print 'info: %s modified' % obj.dn |
| 136 |
|
135 |
|
|
|
136 |
|
| 137 |
if __name__ == '__main__': |
137 |
if __name__ == '__main__': |
| 138 |
usage = '%prog [options] [MODEL, MODEL, ...]' |
138 |
usage = '%prog [options] [MODEL, MODEL, ...]' |
| 139 |
parser = optparse.OptionParser(usage=usage) |
139 |
parser = optparse.OptionParser(usage=usage) |