ucsschool.lib package

Submodules

ucsschool.lib.consistency module

ucsschool.lib.create_ou module

ucsschool.lib.i18n module

ucsschool.lib.i18n.ucs_school_name_i18n(name, lang='de')[source]

i18n function for localization of UCS@school standard names

ucsschool.lib.info module

class ucsschool.lib.info.MembershipFlags(is_edu_school_member, is_admin_school_member)

Bases: tuple

Create new instance of MembershipFlags(is_edu_school_member, is_admin_school_member)

property is_admin_school_member

Alias for field number 1

property is_edu_school_member

Alias for field number 0

ucsschool.lib.info.get_school_membership_type(lo, dn)[source]

Returns a named tuple, that states if the given computer object specified by dn is an educational school Replica Directory Node/Managed Node or administrative Replica Directory Node/Managed Node.

Parameters
Returns

a named tuple that contains flags for educational and administrative membership

Return type

namedtuple(is_edu_school_member, is_admin_school_member)

ucsschool.lib.info.is_central_computer(lo, dn)[source]

Checks if the given computer object specified by dn is a central system or located at a specific school.

Parameters
Returns

is the computer a central system?

Return type

bool

ucsschool.lib.info.is_school_slave(lo, dn)[source]

Checks if the given domaincontroller_slave object (specified by dn) is a school Replica Node.

Parameters
Returns

is the computer a school Replica Directory Node?

Return type

bool

Raises

ValueError – computer DN does not refer to a computers/domaincontroller_slave object

ucsschool.lib.internetrules module

class ucsschool.lib.internetrules.Rule(name, type=0, priority=0, wlan=False, domains=[], userRule=False)[source]

Bases: object

property domains

Return list of all domains, the order respects the indeces. Show only the entries that match the current filter type.

addDomain(domain, idx=- 1, listType=None)[source]

add a new domain with an optional fixed index and list type

save()[source]

Save the current rule as UCR variables. If the rule already exists, only the changed properties will be saved. In case the rules are similar, no changes will be done.

ucsschool.lib.internetrules.findUCRVariables(filterName=None, userRule=False)[source]

Returns a dict of all UCR variables or all variables matching the specified rule name.

ucsschool.lib.internetrules.remove(name, userRule=False)[source]

Removes the UCR variables corresponding to the specified rule.

ucsschool.lib.internetrules.load(name, userRule=False)[source]

Wrapper for list(name).

ucsschool.lib.internetrules.list(filterName=None, userRule=False)[source]

Returns a list of all existing rules. If name is given, returns only the rule matching the specified name or None. userRule specifies whether all common rules (=False) or only user-specific rules (=True) are listed. If filterName is specified, only rule matching this name is returned as single object (not as list!).

ucsschool.lib.internetrules.getGroupRuleName(groupNames)[source]

Return the name of the filter rule for the specified group name.

Usage:

getGroupRuleName([<groupName>, …]) -> { <groupName>:<ruleName>, … }

or:

getGroupRuleName(<groupName) -> <ruleName>

ucsschool.lib.internetrules.unsetGroupRuleName(groupNames)[source]

Unset the default rule for the given group name.

Usage:

setGroupRuleName(<groupName>)

or:

setGroupRuleName([<groupName>, … ])

ucsschool.lib.internetrules.setGroupRuleName(*args)[source]

Set the default rule for the given group name.

Usage:

setGroupRuleName(<groupName>, <ruleName>)

or:

setGroupRuleName({ <groupName>: <ruleName>, … })

ucsschool.lib.roles module

exception ucsschool.lib.roles.UcsschoolRoleStringError[source]

Bases: Exception

exception ucsschool.lib.roles.UnknownRole[source]

Bases: ucsschool.lib.roles.UcsschoolRoleStringError

exception ucsschool.lib.roles.UnknownContextType[source]

Bases: ucsschool.lib.roles.UcsschoolRoleStringError

exception ucsschool.lib.roles.InvalidUcsschoolRoleString[source]

Bases: ucsschool.lib.roles.UcsschoolRoleStringError

ucsschool.lib.roles.create_ucsschool_role_string(role, context, context_type='school', school='')[source]

This function takes a role, a context_type and a context to create a valid ucsschoolRole string. :param role: The role :param context: The context :param context_type: The context type :param school: Old variable name for context. DEPRECATED! TODO: Should be removed in 4.4v5 :return: The valid ucsschoolRole string

ucsschool.lib.roles.get_role_info(ucsschool_role_string)[source]

This function separates the individual elements of an ucsschool role string. Raises InvalidUcsschoolRoleString if the string provided is no valid role string. Raises UnknownRole if the role is unknown. Raises UnknownContextType if the context type is unknown. :param ucsschool_role_string: The role string to separate :return: (role, context_type, context)

ucsschool.lib.roleshares module

ucsschool.lib.school_umc_base module

class ucsschool.lib.school_umc_base.SchoolSanitizer(regex_pattern=None, re_flags=0, minimum=None, maximum=None, **kwargs)[source]

Bases: univention.management.console.modules.sanitizers.StringSanitizer

class ucsschool.lib.school_umc_base.SchoolBaseModule(domain='univention-management-console')[source]

Bases: univention.management.console.base.Base

This class serves as base class for UCS@school UMC modules that need LDAP access. It initiates the list of available OUs (self.availableSchools) and initiates the search bases (self.searchBase). set_bind_function() is called automatically to allow LDAP connections. In order to integrate this class into a module, use the following paradigm:

class Instance(SchoolBaseModule):
def __init__(self):

# initiate list of internal variables SchoolBaseModule.__init__(self) # … custom code

def init(self):

SchoolBaseModule.init(self) # … custom code

init()[source]

this function is invoked after the initial UMCP SET command that passes the base configuration to the module process

bind_user_connection(lo)[source]
schools(request, ldap_user_read=None)[source]

Returns a list of all available school

classes(request)[source]

Returns a list of all classes of the given school

workgroups(request)[source]

Returns a list of all working groups of the given school

groups(request)[source]

Returns a list of all groups (classes and workgroups) of the given school

rooms(request)[source]

Returns a list of all available school

class ucsschool.lib.school_umc_base.LDAP_Filter[source]

Bases: object

static forSchool(school)[source]
static forUsers(pattern)[source]
static forGroups(pattern, school=None)[source]
static forComputers(pattern)[source]
regWhiteSpaces = re.compile('\\s+')
static forAll(pattern, subMatch=[], fullMatch=[], prefixes={})[source]
class ucsschool.lib.school_umc_base.Display[source]

Bases: object

static user(udm_object)[source]
static user_ldap(ldap_object)[source]

ucsschool.lib.school_umc_ldap_connection module

ucsschool.lib.school_umc_ldap_connection.set_bind_function(bind_callback)[source]
ucsschool.lib.school_umc_ldap_connection.set_credentials(dn, passwd)[source]
ucsschool.lib.school_umc_ldap_connection.LDAP_Connection(*connection_types)[source]

This decorator function provides access to internally cached LDAP connections that can be accessed via adding specific keyword arguments to the function.

The function which uses this decorator may specify the following additional keyword arguments:

Parameters
  • ldap_position (univention.admin.uldap.position) – a valid ldap position.

  • ldap_user_read – a read only LDAP connection to the local LDAP server authenticated with the currently used user

  • ldap_user_write – a read/write LDAP connection to the master LDAP server authenticated with the currently used user

  • ldap_machine_read – a read only LDAP connection to the local LDAP server authenticated with the machine account

  • ldap_machine_write – a read/write LDAP connection to the master LDAP server authenticated with the machine account

  • ldap_admin_write – a read/write LDAP connection to the master LDAP server authenticated with cn=admin account

  • search_base – (deprecated!) a SchoolSearchBase instance which is bound to the school of the user or machine.

This decorator can only be used after set_bind_function() has been executed.

@LDAP_Connection()
def do_ldap_stuff(arg1, arg2, ldap_user_write=None, ldap_user_read=None, ldap_position=None):
    ...
    ldap_user_read.searchDn(..., position=ldap_position)
    ...

ucsschool.lib.schoolldap module

class ucsschool.lib.schoolldap.SchoolSearchBase(availableSchools, school=None, dn=None, ldapBase=None)[source]

Bases: object

Deprecated: don’t use position to identify user objects

ucr = None
group_prefix_students = ''
group_prefix_teachers = ''
group_prefix_admins = ''
group_prefix_staff = ''
classmethod getOU(dn)[source]

Return the school OU for a given DN.

>>> SchoolSearchBase.getOU('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar')
'dc1'
classmethod getOUDN(dn)[source]

Return the School OU-DN part for a given DN.

>>> SchoolSearchBase.getOUDN('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar')
'Ou=dc1,oU=dc,dc=foo,dc=bar'
>>> SchoolSearchBase.getOUDN('ou=dc1,ou=dc,dc=foo,dc=bar')
'ou=dc1,ou=dc,dc=foo,dc=bar'
>>> SchoolSearchBase.getOUDN('dc=foo,dc=bar')
'dc=foo,dc=bar'
property dhcp
property policies
property networks
property school
property schoolDN
property users
property groups
property students_group
property teachers_group
property staff_group
property admins_group
property workgroups
property classes
property rooms
property students
property teachers
property teachersAndStaff
property staff
property admins
property classShares
property shares
property printers
property computers
property examUsers
property globalGroupContainer
property educationalDCGroup
property educationalMemberGroup
property administrativeDCGroup
property administrativeMemberGroup
property examGroupName
property examGroup
isWorkgroup(groupDN)[source]
isGroup(groupDN)[source]
isClass(groupDN)[source]
isRoom(groupDN)[source]
classmethod get_is_teachers_group_regex()[source]
classmethod get_is_admins_group_regex()[source]
classmethod get_is_staff_group_regex()[source]
classmethod get_is_student_group_regex()[source]
classmethod get_staff_group_regex()[source]
classmethod get_students_group_regex()[source]
classmethod get_students_pos_regex()[source]
classmethod get_teachers_pos_regex()[source]
classmethod get_staff_pos_regex()[source]
classmethod get_teachers_and_staff_pos_regex()[source]
classmethod get_admins_pos_regex()[source]
classmethod get_exam_users_pos_regex()[source]
classmethod get_schoolclass_pos_regex()[source]
classmethod get_workgroup_pos_regex()[source]
classmethod get_computerroom_pos_regex()[source]
classmethod get_workgroup_share_pos_regex()[source]
classmethod get_school_class_share_pos_regex()[source]

ucsschool.lib.schoollessons module

class ucsschool.lib.schoollessons.Lesson(name, begin, end)[source]

Bases: object

TIME_REGEX = re.compile('^([01][0-9]|2[0-3]|[0-9]):([0-5][0-9])')
property name
property begin
property end
intersect(lesson)[source]
class ucsschool.lib.schoollessons.SchoolLessons(filename='/var/lib/ucs-school-lib/lessons.ini')[source]

Bases: configparser.ConfigParser

init()[source]
remove(lesson)[source]
add(lesson, begin=None, end=None)[source]
save()[source]
property lessons
property current
property next
property previous

ucsschool.lib.smbstatus module

Parser for smbstatus

class ucsschool.lib.smbstatus.SMB_LockedFile[source]

Bases: dict

property filename
property sharePath
class ucsschool.lib.smbstatus.SMB_Process(args)[source]

Bases: dict

property username
property pid
property machine
property lockedFiles
property services
property ipv4address
property ipv6address
property ipaddress
update([E, ]**F) None.  Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

class ucsschool.lib.smbstatus.SMB_Status(testdata=None)[source]

Bases: list

parse(testdata=None)[source]
update(service)[source]