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:
parent
b9e07f8c1c
commit
7f02ee3914
|
@ -3,16 +3,27 @@ import sys, ldap
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
class LdapTester:
|
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):
|
def __init__(self):
|
||||||
# Get params from shell args.
|
# Get params from shell args.
|
||||||
if len(sys.argv) != 5:
|
if len(sys.argv) != 7:
|
||||||
print LdapTester.__doc__
|
print LdapTester.__doc__
|
||||||
sys.exit(0)
|
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.tentatives = 5
|
||||||
self.timeout = 5
|
self.timeout = 5
|
||||||
self.attrList = ['uid']
|
self.attrList = ['cfwbV2cn', 'logindisabled']
|
||||||
self.ssl = False
|
self.ssl = False
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
|
@ -28,9 +39,9 @@ class LdapTester:
|
||||||
try:
|
try:
|
||||||
print 'Done. Performing a simple query on %s...' % self.base
|
print 'Done. Performing a simple query on %s...' % self.base
|
||||||
res = server.search_st(
|
res = server.search_st(
|
||||||
self.base, ldap.SCOPE_ONELEVEL, attrlist=self.attrList,
|
self.base, ldap.SCOPE_ONELEVEL, filterstr=self.filter,
|
||||||
timeout=5)
|
attrlist=self.attrs, timeout=5)
|
||||||
print 'Got res', res
|
print 'Got %d entries' % len(res)
|
||||||
break
|
break
|
||||||
except ldap.TIMEOUT:
|
except ldap.TIMEOUT:
|
||||||
print 'Got timeout.'
|
print 'Got timeout.'
|
||||||
|
@ -40,4 +51,5 @@ class LdapTester:
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
LdapTester().test()
|
LdapTester().test()
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.6.6
|
0.6.7
|
||||||
|
|
|
@ -21,7 +21,7 @@ import zipfile, shutil, xml.sax, os, os.path, re, mimetypes, time
|
||||||
|
|
||||||
from UserDict import UserDict
|
from UserDict import UserDict
|
||||||
|
|
||||||
import appy.pod
|
import appy.pod, time
|
||||||
from appy.pod import PodError
|
from appy.pod import PodError
|
||||||
from appy.shared import mimeTypesExts
|
from appy.shared import mimeTypesExts
|
||||||
from appy.shared.xml_parser import XmlElement
|
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.'
|
BAD_CONTEXT = 'Context must be either a dict, a UserDict or an instance.'
|
||||||
RESULT_FILE_EXISTS = 'Result file "%s" exists.'
|
RESULT_FILE_EXISTS = 'Result file "%s" exists.'
|
||||||
CANT_WRITE_RESULT = 'I cannot write result file "%s". %s'
|
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'
|
CANT_WRITE_TEMP_FOLDER = 'I cannot create temp folder "%s". %s'
|
||||||
NO_PY_PATH = 'Extension of result file is "%s". In order to perform ' \
|
NO_PY_PATH = 'Extension of result file is "%s". In order to perform ' \
|
||||||
'conversion from ODT to this format we need to call OpenOffice. ' \
|
'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))
|
raise PodError(CANT_WRITE_RESULT % (self.result, ie))
|
||||||
self.result = os.path.abspath(self.result)
|
self.result = os.path.abspath(self.result)
|
||||||
os.remove(self.result)
|
os.remove(self.result)
|
||||||
# Check that temp folder does not exist
|
# Create a temp folder for storing temporary files
|
||||||
self.tempFolder = os.path.abspath(self.result) + '.temp'
|
absResult = os.path.abspath(self.result)
|
||||||
if os.path.exists(self.tempFolder):
|
self.tempFolder = '%s.%f' % (absResult, time.time())
|
||||||
raise PodError(TEMP_FOLDER_EXISTS % self.tempFolder)
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(self.tempFolder)
|
os.mkdir(self.tempFolder)
|
||||||
except OSError, oe:
|
except OSError, oe:
|
||||||
|
|
Loading…
Reference in a new issue