Projet

Général

Profil

ead.patch

Benjamin Bohard, 20/10/2016 10:25

Télécharger (3,03 ko)

Voir les différences:

backend/actions/lib/importation/fichier.py
33 33
from ead2.backend.config.config import debug
34 34

  
35 35
PARSE_CMD = "%s --parse=%%s %%s" % IMPORTATION_SCRIPT
36
IMPORTATION_CMD = "%s --import --type=%%s %%s" % IMPORTATION_SCRIPT
36
IMPORTATION_CMD = "%s --import --type=%%s --user=%%s %%s" % IMPORTATION_SCRIPT
37 37

  
38 38
def _thread_message((message, txtmessage), return_dict):
39 39
    """
......
81 81

  
82 82
    register_file = mktemp('.register', 'ead-importation-',
83 83
                                        EXTRACTION_TEMP_DIR)
84
    user_description = Dict(default={}, doc="description de l’exécutant",
85
                            keys=['ip', 'name', 'role'])
84 86

  
85 87
    def execute(self):
86 88
        """
......
424 426
        """
425 427
            Lance l'importation des comptes
426 428
        """
427
        cmd = IMPORTATION_CMD % (import_type, category_type)
429
        cmd = IMPORTATION_CMD % (import_type, self.user_description['name'], category_type)
428 430
        ret_code, value, ret_value = system_out(['at', 'now'], stdin=cmd)
429 431
        if ret_code:
430 432
            log.err(ret_value)
backend/bin/importation.py
52 52
    """
53 53
    try:
54 54
        opts, args = getopt.getopt(sys.argv[1:],
55
                                   "t:p:i",
56
                                   ["type=","parse=","import"])
55
                                   "t:p:i:u",
56
                                   ["type=","parse=","import","user="])
57 57
    except getopt.GetoptError, err:
58 58
        print(err)
59 59
        usage()
......
73 73
            break
74 74
        elif option in ('-i', '--import'):
75 75
            action = 'import'
76
        elif option in ('-u', '--user'):
77
            user = value
76 78
        else:
77 79
            usage()
78 80
            print("Option inconnue")
......
432 434
        except Exception, error:
433 435
            self.log_err(error=error)
434 436
        self.log_end()
435
        importlog.end_importation('EAD')
437
        importlog.end_importation('EAD', user)
436 438

  
437 439
    def do_import_personnel(self, enseignants=True):
438 440
        """
......
513 515
        importlog.debuglog("Démarrage de nscd...", title=True)
514 516
        nscd_start()
515 517
        self.log_end()
516
        importlog.end_importation('EAD')
518
        importlog.end_importation('EAD', user)
517 519

  
518 520
    def do_import_invite(self):
519 521
        """
......
537 539
        except Exception, error:
538 540
            self.log_err(error=error)
539 541
        self.log_end()
540
        importlog.end_importation('EAD')
542
        importlog.end_importation('EAD', user)
541 543

  
542 544
if __name__ == '__main__':
543 545
    main()