- # make it enabled
- person_record.update({'enabled': True})
- # mark it sfa_created; a string is required here, sfa_created is a tag
- person_record.update({'sfa_created':'True'})
- # set hrn
- person_record.update({'hrn':user_hrn})
-
- person_id = int (self.driver.shell.AddPerson(person_record))
+
+ logger.debug ("about to attempt to AddPerson with {}".format(person_record))
+ try:
+ # the thing is, the PLE db has a limitation on re-using the same e-mail
+ # in the case where people have an account on ple.upmc and then then come
+ # again from onelab.upmc, they will most likely have the same e-mail, and so kaboom..
+ # so we first try with the accurate email
+ person_id = int (self.driver.shell.AddPerson(person_record))
+ except:
+ logger.log_exc("caught during first attempt at AddPerson")
+ # and if that fails we start again with the email based on the hrn, which this time is unique..
+ person_record['email'] = default_email
+ logger.debug ("second chance with email={}".format(person_record['email']))
+ person_id = int (self.driver.shell.AddPerson(person_record))