Exemple #1
0
 def __init__(self):
     # __init__() cannot have arguments, as it has replaced
     # DefaultUserImportFactory.make_reader() and is instantiated from
     # UserImport.__init__() without arguments.
     # So we'll fetch the necessary information from the configuration.
     self.config = Configuration()
     filename = self.config["input"]["filename"]
     header_lines = self.config["csv"]["header_lines"]
     super(HttpApiCsvReader, self).__init__(filename, header_lines)
     self.config = Configuration()
Exemple #2
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)
Exemple #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()
Exemple #4
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
Exemple #5
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()
Exemple #6
0
 def __init__(self):
     self.config = Configuration()
     filename = self.config["input"]["filename"]
     header_lines = self.config["csv"]["header_lines"]
     super(TypeCsvReader, self).__init__(filename, header_lines)
Exemple #7
0
 def __init__(self, *arg, **kwargs):
     super(LegacyNewUserPasswordCsvExporter, self).__init__(*arg, **kwargs)
     self.config = Configuration()
 def __init__(self):
     self.config = Configuration()
     self.logger = get_logger()
     self.load_methods_from_config()