Univention Bugzilla – Attachment 9237 Details for
Bug 45478
Cleanup ucsschool-s4-branch-site.py
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Cleanup
diff (text/plain), 4.91 KB, created by
Philipp Hahn
on 2017-10-04 08:50 CEST
(
hide
)
Description:
Cleanup
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2017-10-04 08:50 CEST
Size:
4.91 KB
patch
obsolete
>diff --git a/ucs-school-s4-branch-site/ucsschool-s4-branch-site.py b/ucs-school-s4-branch-site/ucsschool-s4-branch-site.py >index d67c8581..e67ba46d 100644 >--- a/ucs-school-s4-branch-site/ucsschool-s4-branch-site.py >+++ b/ucs-school-s4-branch-site/ucsschool-s4-branch-site.py >@@ -35,21 +35,21 @@ __package__ = '' # workaround for PEP 366 > import listener > import univention.debug as ud > import univention.admin.uexceptions as udm_errors >-import univention.uldap > import univention.config_registry > > # import s4-connector listener module code, but don't generate pyc file > import os > import sys > import ldap >-sys.dont_write_bytecode = True > import imp >-s4_connector_listener_path = '/usr/lib/univention-directory-listener/system/s4-connector.py' >-s4_connector_listener = imp.load_source('s4_connector', s4_connector_listener_path) > from ucsschool.lib.schoolldap import LDAP_Connection, MACHINE_READ, SchoolSearchBase > import traceback > import subprocess > >+sys.dont_write_bytecode = True >+s4_connector_listener_path = '/usr/lib/univention-directory-listener/system/s4-connector.py' >+s4_connector_listener = imp.load_source('s4_connector', s4_connector_listener_path) >+ > # Listener registration data > name = 'ucsschool-s4-branch-site' > description = 'UCS@school S4 branch site module' >@@ -76,7 +76,7 @@ def load_hooks(): > try: > hook = imp.load_source(modulename, file_path) > except Exception as ex: >- ud.debug(ud.LISTENER, ud.ERROR, "Error importing %s as %s:" % (file_path, modulename)) >+ ud.debug(ud.LISTENER, ud.ERROR, "Error importing %s as %s: %s" % (file_path, modulename, ex)) > ud.debug(ud.LISTENER, ud.ERROR, traceback.format_exc()) > hooks.append(hook) > >@@ -84,14 +84,13 @@ def load_hooks(): > > > def run_hooks(fname, *args): >- global _hooks > for hook in _hooks: > if hasattr(hook, fname): > try: > hook_func = getattr(hook, fname) > hook_func(*args) > except Exception as ex: >- ud.debug(ud.LISTENER, ud.ERROR, "Error running %s.%s():" % (hook.__name__, fname)) >+ ud.debug(ud.LISTENER, ud.ERROR, "Error running %s.%s(): %s" % (hook.__name__, fname, ex)) > ud.debug(ud.LISTENER, ud.ERROR, traceback.format_exc()) > # </Hooks handling> ############## > >@@ -107,14 +106,13 @@ _hooks = [] > > @LDAP_Connection(MACHINE_READ) > def on_load(ldap_machine_read=None, ldap_position=None): >- global _ldap_hostdn > global _hooks > _hooks = load_hooks() > > global _ucsschool_service_specialization_filter > try: > res = ldap_machine_read.search(base=_ldap_hostdn, scope='base', attr=('univentionService',)) >- except udm_errors.ldapError, e: >+ except udm_errors.ldapError as e: > ud.debug(ud.LISTENER, ud.ERROR, '%s: Error accessing LDAP: %s' % (name, e)) > return > >@@ -189,7 +187,6 @@ STD_S4_SRV_RECORDS = { > > @LDAP_Connection(MACHINE_READ) > def visible_samba4_school_dcs(excludeDN=None, ldap_machine_read=None, ldap_position=None): >- global filter > _visible_samba4_school_dcs = [] > try: > res = ldap_machine_read.search(base=ldap_position.getDn(), filter=filter, attr=['cn', 'associatedDomain']) >@@ -201,18 +198,14 @@ def visible_samba4_school_dcs(excludeDN=None, ldap_machine_read=None, ldap_posit > else: > domainname = _local_domainname > _visible_samba4_school_dcs.append('.'.join((obj['cn'][0], domainname))) >- except udm_errors.ldapError, e: >+ except udm_errors.ldapError as e: > ud.debug(ud.LISTENER, ud.ERROR, '%s: Error accessing LDAP: %s' % (name, e)) > > return _visible_samba4_school_dcs > > > def update_ucr_overrides(excludeDN=None): >- global STD_S4_SRV_RECORDS >- global _record_type >- global _local_domainname > global _s4_connector_restart >- global _relativeDomainName_trigger_set > > server_fqdn_list = visible_samba4_school_dcs(excludeDN=excludeDN) > server_fqdn_list.sort() >@@ -299,10 +292,6 @@ def update_ucr_overrides(excludeDN=None): > > @LDAP_Connection(MACHINE_READ) > def trigger_sync_ucs_to_s4(ldap_machine_read=None, ldap_position=None): >- global _record_type >- global _local_domainname >- global _relativeDomainName_trigger_set >- > for relativeDomainName in list(_relativeDomainName_trigger_set): > # trigger S4 Connector > ldap_filter = '(&(univentionObjectType=dns/%s)(zoneName=%s)(relativeDomainName=%s))' % (_record_type, _local_domainname, relativeDomainName) >@@ -312,7 +301,7 @@ def trigger_sync_ucs_to_s4(ldap_machine_read=None, ldap_position=None): > for (record_dn, obj) in res: > s4_connector_listener.handler(record_dn, obj, obj, 'm') > _relativeDomainName_trigger_set.remove(relativeDomainName) >- except udm_errors.ldapError, e: >+ except udm_errors.ldapError as e: > ud.debug(ud.LISTENER, ud.ERROR, '%s: Error accessing LDAP: %s' % (name, e)) > > >@@ -369,7 +358,6 @@ def handler(dn, new, old, command): > > def postrun(): > global _s4_connector_restart >- global _relativeDomainName_trigger_set > > if not listener.configRegistry.is_true('connector/s4/autostart', True): > univention.debug.debug(univention.debug.LISTENER, univention.debug.PROCESS, '%s: S4 Connector restart skipped, disabled via connector/s4/autostart.' % (name,))
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 45478
: 9237