From fe01287064719de267d06d63a6540bb91d086dda Mon Sep 17 00:00:00 2001 From: Romain Beuque Date: Tue, 2 Sep 2014 20:26:52 +0200 Subject: [PATCH] correction de quelques erreurs sur le scheduler : anniversary, try/catch, ... --- Brie/brie/controllers/scheduler.py | 10 +++++++++- Brie/brie/lib/aurore_helper.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Brie/brie/controllers/scheduler.py b/Brie/brie/controllers/scheduler.py index 35b96c5..a3d7207 100644 --- a/Brie/brie/controllers/scheduler.py +++ b/Brie/brie/controllers/scheduler.py @@ -60,6 +60,10 @@ def disconnect_members_from_residence(admin_user, residence_dn): machines = admin_user.ldap_bind.search(machine_dn, "(objectClass=organizationalRole)", scope = ldap.SCOPE_ONELEVEL) for machine in machines: dns = Machine.get_dns_by_id(admin_user, machine.dn) + if dns is None: + print "[LOG] Suppression machine erreur (dns is None): " + machine.dn + continue + #end if ip = IpReservation.get_ip(admin_user, residence_dn, dns.dlzData.first()) print("[LOG "+datetime.datetime.now().strftime("%Y-%m-%d %H:%M")+"] suppression machine " + Machine.get_dhcps(admin_user, machine.dn)[0].get("dhcpHWAddress").values[0] + " pour l'utilisateur "+ member.dn + " par le scheduler") #sys.stdout.flush() @@ -87,7 +91,11 @@ def disconnect_members_job(): for residence in residences: print "Disconnect job on : " + residence.uniqueMember.first() - disconnect_members_from_residence(user, residence.uniqueMember.first()) + try: + disconnect_members_from_residence(user, residence.uniqueMember.first()) + except Exception as inst: + print "[LOG "+datetime.datetime.now().strftime("%Y-%m-%d %H:%M")+"] Exception sur le scheduler ("+ residence.uniqueMember.first() +")" + print type(inst) #end for # user.ldap_bind.disconnect() diff --git a/Brie/brie/lib/aurore_helper.py b/Brie/brie/lib/aurore_helper.py index 745395a..52bd173 100644 --- a/Brie/brie/lib/aurore_helper.py +++ b/Brie/brie/lib/aurore_helper.py @@ -151,6 +151,10 @@ class CotisationComputes: anniversary_year = resultat[0].year + 1 anniversary = datetime.datetime.strptime(str(anniversary_year) + "-" + str(anniversary_month) + "-1 0:0", "%Y-%m-%d %H:%M") + datetime.timedelta(days=(anniversary_day - 1)) #end for + + if anniversary == 0: + anniversary = datetime.datetime(1999, 1, 31, 12, 0) + return anniversary #end def