diff --git a/backend/actions/lib/importation/fichier.py b/backend/actions/lib/importation/fichier.py index a7c86b1..5c04ba6 100644 --- a/backend/actions/lib/importation/fichier.py +++ b/backend/actions/lib/importation/fichier.py @@ -33,7 +33,7 @@ from ead2.backend.actions.lib.importation.tools import (write_file, from ead2.backend.config.config import debug PARSE_CMD = "%s --parse=%%s %%s" % IMPORTATION_SCRIPT -IMPORTATION_CMD = "%s --import --type=%%s %%s" % IMPORTATION_SCRIPT +IMPORTATION_CMD = "%s --import --type=%%s --user=%%s %%s" % IMPORTATION_SCRIPT def _thread_message((message, txtmessage), return_dict): """ @@ -81,6 +81,8 @@ class BaseImportationFichier(BaseImportation): register_file = mktemp('.register', 'ead-importation-', EXTRACTION_TEMP_DIR) + user_description = Dict(default={}, doc="description de l’exécutant", + keys=['ip', 'name', 'role']) def execute(self): """ @@ -424,7 +426,7 @@ Lancer l'importation", """ Lance l'importation des comptes """ - cmd = IMPORTATION_CMD % (import_type, category_type) + cmd = IMPORTATION_CMD % (import_type, self.user_description['name'], category_type) ret_code, value, ret_value = system_out(['at', 'now'], stdin=cmd) if ret_code: log.err(ret_value) diff --git a/backend/bin/importation.py b/backend/bin/importation.py index 62df210..b79d0d6 100755 --- a/backend/bin/importation.py +++ b/backend/bin/importation.py @@ -52,8 +52,8 @@ def main(): """ try: opts, args = getopt.getopt(sys.argv[1:], - "t:p:i", - ["type=","parse=","import"]) + "t:p:i:u", + ["type=","parse=","import","user="]) except getopt.GetoptError, err: print(err) usage() @@ -73,6 +73,8 @@ def main(): break elif option in ('-i', '--import'): action = 'import' + elif option in ('-u', '--user'): + user = value else: usage() print("Option inconnue") @@ -432,7 +434,7 @@ class Importer(Logger): except Exception, error: self.log_err(error=error) self.log_end() - importlog.end_importation('EAD') + importlog.end_importation('EAD', user) def do_import_personnel(self, enseignants=True): """ @@ -513,7 +515,7 @@ class Importer(Logger): importlog.debuglog("Démarrage de nscd...", title=True) nscd_start() self.log_end() - importlog.end_importation('EAD') + importlog.end_importation('EAD', user) def do_import_invite(self): """ @@ -537,7 +539,7 @@ class Importer(Logger): except Exception, error: self.log_err(error=error) self.log_end() - importlog.end_importation('EAD') + importlog.end_importation('EAD', user) if __name__ == '__main__': main()