|
32 |
# <http://www.gnu.org/licenses/>. |
32 |
# <http://www.gnu.org/licenses/>. |
33 |
|
33 |
|
34 |
__package__='' # workaround for PEP 366 |
34 |
__package__='' # workaround for PEP 366 |
35 |
import listener, cPickle, time, os |
35 |
import listener |
|
|
36 |
import cPickle |
37 |
import time |
38 |
import os |
39 |
import shutil |
36 |
import univention.debug |
40 |
import univention.debug |
37 |
|
41 |
|
38 |
name='ad-connector' |
42 |
name='ad-connector' |
Lines 87-115
def _dump_changes_to_file_and_check_file(directory, dn, new, old, old_dn):
|
Link Here
|
---|
|
87 |
|
91 |
|
88 |
ob=(dn, new, old, old_dn) |
92 |
ob=(dn, new, old, old_dn) |
89 |
|
93 |
|
90 |
filename=os.path.join(directory,"%f"%time.time()) |
94 |
tmpdir = os.path.join(directory, 'tmp') |
|
|
95 |
filename = "%f" % time.time() |
96 |
filepath = os.path.join(tmpdir, filename) |
91 |
|
97 |
|
92 |
_dump_object_to_file(filename, ob) |
98 |
_dump_object_to_file(filepath, ob) |
93 |
|
99 |
|
94 |
tmp_array = [] |
100 |
tmp_array = [] |
95 |
f=open(filename, 'r') |
101 |
with open(filepath, 'r') as fd: |
96 |
tmp_array = cPickle.load(f) |
102 |
tmp_array = cPickle.load(fd) |
97 |
f.close() |
|
|
98 |
|
103 |
|
99 |
tmp_array_len = len(tmp_array) |
104 |
tmp_array_len = len(tmp_array) |
100 |
if tmp_array_len != 4: |
105 |
if tmp_array_len != 4: |
101 |
univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filename, tmp_array_len)) |
106 |
univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filename, tmp_array_len)) |
102 |
_dump_object_to_file(filename, ob) |
107 |
_dump_object_to_file(filepath, ob) |
103 |
|
108 |
|
104 |
tmp_array = [] |
109 |
tmp_array = [] |
105 |
f=open(filename, 'r') |
110 |
with open(filepath, 'r') as fd: |
106 |
tmp_array = cPickle.load(f) |
111 |
tmp_array = cPickle.load(fd) |
107 |
f.close() |
|
|
108 |
|
112 |
|
109 |
tmp_array_len = len(tmp_array) |
113 |
tmp_array_len = len(tmp_array) |
110 |
if tmp_array_len != 4: |
114 |
if tmp_array_len != 4: |
111 |
univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filename, tmp_array_len)) |
115 |
univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filename, tmp_array_len)) |
112 |
|
116 |
|
|
|
117 |
shutil.move(filepath, os.path.join(directory, filename)) |
118 |
|
113 |
def handler(dn, new, old, command): |
119 |
def handler(dn, new, old, command): |
114 |
|
120 |
|
115 |
global group_objects |
121 |
global group_objects |