Univention Bugzilla – Attachment 8054 Details for
Bug 42507
Traceback when reading pickle files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
42507.patch (text/plain), 1.78 KB, created by
Florian Best
on 2016-09-29 15:33 CEST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Florian Best
Created:
2016-09-29 15:33 CEST
Size:
1.78 KB
patch
obsolete
>diff --git a/services/univention-ad-connector/ad-connector.py b/services/univention-ad-connector/ad-connector.py >index d97a884..c768cc9 100644 >--- a/services/univention-ad-connector/ad-connector.py >+++ b/services/univention-ad-connector/ad-connector.py >@@ -32,7 +32,11 @@ > # <http://www.gnu.org/licenses/>. > > __package__='' # workaround for PEP 366 >-import listener, cPickle, time, os >+import listener >+import cPickle >+import time >+import os >+import shutil > import univention.debug > > name='ad-connector' >@@ -87,29 +91,31 @@ def _dump_changes_to_file_and_check_file(directory, dn, new, old, old_dn): > > ob=(dn, new, old, old_dn) > >- filename=os.path.join(directory,"%f"%time.time()) >+ tmpdir = os.path.join(directory, 'tmp') >+ filename = "%f" % time.time() >+ filepath = os.path.join(tmpdir, filename) > >- _dump_object_to_file(filename, ob) >+ _dump_object_to_file(filepath, ob) > > tmp_array = [] >- f=open(filename, 'r') >- tmp_array = cPickle.load(f) >- f.close() >+ with open(filepath, 'r') as fd: >+ tmp_array = cPickle.load(fd) > > tmp_array_len = len(tmp_array) > if tmp_array_len != 4: > univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'replacing broken cPickle in %s (len=%s) with plain pickle' % (filename, tmp_array_len)) >- _dump_object_to_file(filename, ob) >+ _dump_object_to_file(filepath, ob) > > tmp_array = [] >- f=open(filename, 'r') >- tmp_array = cPickle.load(f) >- f.close() >+ with open(filepath, 'r') as fd: >+ tmp_array = cPickle.load(fd) > > tmp_array_len = len(tmp_array) > if tmp_array_len != 4: > univention.debug.debug(univention.debug.LDAP, univention.debug.ERROR, 'pickle in %s (len=%s) seems to be broken' % (filename, tmp_array_len)) > >+ shutil.move(filepath, os.path.join(directory, filename)) >+ > def handler(dn, new, old, command): > > global group_objects
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 42507
:
8042
| 8054 |
8096
|
8311