appy.bin: improvements in ldapchecker.py; appy.pod: solved bug https://bugs.launchpad.net/appy/+bug/740290 (concurrent work on the same POD template), also tied to question https://answers.launchpad.net/appy/+question/149443.

This commit is contained in:
Gaetan Delannay 2011-06-02 12:20:15 +02:00
parent b9e07f8c1c
commit 7f02ee3914
3 changed files with 24 additions and 15 deletions

View file

@ -3,16 +3,27 @@ import sys, ldap
# ------------------------------------------------------------------------------
class LdapTester:
'''Usage: python checkldap.py ldapUri login password base.'''
'''Usage: python checkldap.py ldapUri login password base attrs filter
ldapUri is, for example, "ldap://127.0.0.1:389"
login is the login user DN, ie: "cn=gdy,o=geezteem"
password is the password for this login
base is the base DN where to perform the search, ie "ou=hr,o=GeezTeem"
attrs is a comma-separated list of attrs we will retrieve in the LDAP,
ie "uid,login"
filter is the query filter, ie "(&(attr1=Geez*)(status=OK))"
'''
def __init__(self):
# Get params from shell args.
if len(sys.argv) != 5:
if len(sys.argv) != 7:
print LdapTester.__doc__
sys.exit(0)
self.uri, self.login, self.password, self.base = sys.argv[1:]
s = self
s.uri, s.login, s.password, s.base, s.attrs, s.filter = sys.argv[1:]
self.attrs = self.attrs.split(',')
self.tentatives = 5
self.timeout = 5
self.attrList = ['uid']
self.attrList = ['cfwbV2cn', 'logindisabled']
self.ssl = False
def test(self):
@ -28,9 +39,9 @@ class LdapTester:
try:
print 'Done. Performing a simple query on %s...' % self.base
res = server.search_st(
self.base, ldap.SCOPE_ONELEVEL, attrlist=self.attrList,
timeout=5)
print 'Got res', res
self.base, ldap.SCOPE_ONELEVEL, filterstr=self.filter,
attrlist=self.attrs, timeout=5)
print 'Got %d entries' % len(res)
break
except ldap.TIMEOUT:
print 'Got timeout.'
@ -40,4 +51,5 @@ class LdapTester:
# ------------------------------------------------------------------------------
if __name__ == '__main__':
LdapTester().test()
# ------------------------------------------------------------------------------

View file

@ -1 +1 @@
0.6.6
0.6.7

View file

@ -21,7 +21,7 @@ import zipfile, shutil, xml.sax, os, os.path, re, mimetypes, time
from UserDict import UserDict
import appy.pod
import appy.pod, time
from appy.pod import PodError
from appy.shared import mimeTypesExts
from appy.shared.xml_parser import XmlElement
@ -37,8 +37,6 @@ from appy.pod.styles_manager import StylesManager
BAD_CONTEXT = 'Context must be either a dict, a UserDict or an instance.'
RESULT_FILE_EXISTS = 'Result file "%s" exists.'
CANT_WRITE_RESULT = 'I cannot write result file "%s". %s'
TEMP_FOLDER_EXISTS = 'I need to use a temp folder "%s" but this folder ' \
'already exists.'
CANT_WRITE_TEMP_FOLDER = 'I cannot create temp folder "%s". %s'
NO_PY_PATH = 'Extension of result file is "%s". In order to perform ' \
'conversion from ODT to this format we need to call OpenOffice. ' \
@ -311,10 +309,9 @@ class Renderer:
raise PodError(CANT_WRITE_RESULT % (self.result, ie))
self.result = os.path.abspath(self.result)
os.remove(self.result)
# Check that temp folder does not exist
self.tempFolder = os.path.abspath(self.result) + '.temp'
if os.path.exists(self.tempFolder):
raise PodError(TEMP_FOLDER_EXISTS % self.tempFolder)
# Create a temp folder for storing temporary files
absResult = os.path.abspath(self.result)
self.tempFolder = '%s.%f' % (absResult, time.time())
try:
os.mkdir(self.tempFolder)
except OSError, oe: