Esempio n. 1
0
    def __init__(self, name=None, school=None, **kwargs):
        self.action = None  # "A", "D" or "M"
        self.entry_count = 0  # line/node number of input data
        self.udm_properties = dict(
        )  # UDM properties from input, that are not stored in Attributes
        self.input_data = list()  # raw input data created by SomeReader.read()
        self.old_user = None  # user in LDAP, when modifying
        self.in_hook = False  # if a hook is currently running

        for attr in self._additional_props:
            try:
                val = kwargs.pop(attr)
                setattr(self, attr, val)
            except KeyError:
                pass

        if not self.factory:
            self.__class__.factory = Factory()
            self.__class__.ucr = self.factory.make_ucr()
            self.__class__.config = Configuration()
            self.__class__.reader = self.factory.make_reader()
            self.__class__.logger = get_logger()
            self.__class__.default_username_max_length = self._default_username_max_length
            self.__class__.attribute_udm_names = dict(
                (attr.udm_name, name)
                for name, attr in self._attributes.items() if attr.udm_name)
            self.__class__.no_overwrite_attributes = self.ucr.get(
                "ucsschool/import/generate/user/attributes/no-overwrite-by-schema",
                "mailPrimaryAddress uid").split()
        self._lo = None
        self._userexpiry = None
        self._purge_ts = None
        super(ImportUser, self).__init__(name, school, **kwargs)
Esempio n. 2
0
    def __init__(self, lo, *args, **kwargs):
        """
		:param lo: LDAP object
		"""
        super(ImportPyHook, self).__init__(*args, **kwargs)
        self.lo = lo  # LDAP object
        self.logger = get_logger()  # Python logging instance
Esempio n. 3
0
    def __init__(self, dry_run=True):
        """
		:param dry_run: bool: set to False to actually commit changes to LDAP
		"""
        self.dry_run = dry_run
        self.config = Configuration()
        self.logger = get_logger()
        self.factory = Factory()
        self.result_exporter = self.factory.make_result_exporter()
        self.password_exporter = self.factory.make_password_exporter()
        self.errors = list()
Esempio n. 4
0
	def __init__(self, max_length, dry_run=True):
		"""
		:param max_length: int: created usernames will be no longer
		than this
		:param dry_run: bool: if False use LDAP to store already-used usernames
		if True store for one run only in memory
		"""
		self.max_length = max_length
		self.dry_run = dry_run
		self.logger = get_logger()
		self.storage_backend = self.get_storage_backend()
		self.logger.debug('%r storage_backend=%r', self,  self.storage_backend.__class__.__name__)
		self.replacement_variable_pattern = re.compile(r'(%s)' % '|'.join(map(re.escape, self.counter_variable_to_function.keys())), flags=re.I)
Esempio n. 5
0
	def __init__(self, filename, header_lines=0, **kwargs):
		"""
		:param filename: str: Path to file with user data.
		:param header_lines: int: Number of lines before the actual data starts.
		:param kwargs: dict: optional parameters for use in derived classes
		"""
		self.config = Configuration()
		self.logger = get_logger()
		self.filename = filename
		self.header_lines = header_lines
		self.import_users = self.read()
		self.factory = Factory()
		self.ucr = self.factory.make_ucr()
		self.entry_count = 0    # line/node in input data
		self.input_data = None  # input data, as raw as possible/sensible
Esempio n. 6
0
    def __init__(self, dry_run=True):
        """
		:param dry_run: bool: set to False to actually commit changes to LDAP
		"""
        self.dry_run = dry_run
        self.errors = list()
        self.imported_users = list()
        self.added_users = defaultdict(
            list
        )  # dict of lists of dicts: {ImportStudent: [ImportStudent.to_dict(), ..], ..}
        self.modified_users = defaultdict(list)  # like added_users
        self.deleted_users = defaultdict(list)  # like added_users
        self.config = Configuration()
        self.logger = get_logger()
        self.connection, self.position = get_admin_connection()
        self.factory = Factory()
        self.reader = self.factory.make_reader()
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     super(FormatPyHook, self).__init__(*args, **kwargs)
     self.logger = get_logger()  # Python logging instance
Esempio n. 8
0
	def __init__(self, filename):
		self.filename = filename
		self.logger = get_logger()
Esempio n. 9
0
import json
import tempfile

from ucsschool.lib.models import role_pupil, role_teacher, role_staff
from ucsschool.importer.configuration import Configuration
from ucsschool.importer.utils.logging import get_logger
from ucsschool.importer.exceptions import UnkownRole
from ucsschool.importer.reader.csv_reader import CsvReader
from ucsschool.importer.mass_import.mass_import import MassImport
from ucsschool.importer.writer.new_user_password_csv_exporter import NewUserPasswordCsvExporter
from ucsschool.importer.writer.user_import_csv_result_exporter import UserImportCsvResultExporter
from ucsschool.importer.mass_import.user_import import UserImport
from ucsschool.importer.utils.username_handler import UsernameHandler
from ucsschool.importer.writer.base_writer import BaseWriter

logger = get_logger()


class TypeCsvReader(CsvReader):
    """
	Read user roles from CSV files.
	"""
    roles_mapping = {
        "student": [role_pupil],
        "staff": [role_staff],
        "teacher": [role_teacher],
        "staffteacher": [role_teacher, role_staff]
    }

    def __init__(self):
        self.config = Configuration()
 def __init__(self):
     self.config = Configuration()
     self.logger = get_logger()
     self.load_methods_from_config()
Esempio n. 11
0
 def __init__(self):
     self.logger = get_logger()
     self.args = None
     self.config = None
     self.factory = None
     self.errors = list()