Ciaran Farrell avatar Ciaran Farrell committed 76ac97f

Fix logic when returning busyblocks - remember to actually sleep and keep asking the Groupwise server until the server states that there are no outstanding calendars to be checked

Comments (0)

Files changed (1)

       logger.debug(resp.status.description)
       raise GWFatalException,resp.status.description
 
-  def __parseBusyBlocks__(self,udict):
+  def __parseBusyBlocks__(self,udict,s=None,e=None):
     '''Use Dyck-Words type algorithm to find out what the available times
        are. Note that if a user has an appointment that _started_ before now,
        then this is going to be the first element in the list of blocks. Thus,
       resp = self.client.service.getFreeBusyRequest(sessionid)
       if int(resp.status.code)==0:
         outstanding = int(resp.freeBusyStats.outstanding)
-        #TODO: rather than the 'or' in the next line check each condition
-        #individually. That way the warning can be that the threshold time for
-        #getting responses from GW has been exceeded
-        users = resp.freeBusyInfo.user
-        for user in users:
-          # remember, conference rooms are users without displayName
-          if hasattr(user,'displayName'):
-            dn = user.displayName
-          else:
-            dn = ''
-          u[user.email] = {'email':user.email,'uuid':user.uuid,
-                          'displayName':dn,
-                          'blocks':user.blocks}
         if (outstanding == 0) or (datetime.now() >= e):
           self.client.service.closeFreeBusySessionRequest(sessionid)
           logger.debug('GW server says he is finished. Get out of here')
-          return self.__parseBusyBlocks__(u)
-          finished = True
-        
+          users = resp.freeBusyInfo.user
+          for user in users:
+            # remember, conference rooms are users without displayName
+            if hasattr(user,'displayName'):
+              dn = user.displayName
+            else:
+              dn = ''
+            u[user.email] = {'email':user.email,'uuid':user.uuid,
+                          'displayName':dn,
+                          'blocks':user.blocks}
+          return self.__parseBusyBlocks__(u,s=st,e=et)
+          finished = True # this will never be reached
+        else:
+          logger.debug('Groupwise is not finished looking up calendars...')
       if datetime.now() >= e:
-        return self.__parseBusyBlocks__(u)
+        logger.debug('Timeout exceeded - cancel calendar lookup now')
+        return self.__parseBusyBlocks__(u,s=st,e=et)
         finished = True
-      logger.debug('sleeping for 2 seconds before asking GW server again')
+      logger.debug('sleeping for 4 seconds before asking GW server again')
       sleep(4) # don't hammer the GW server too often
     return self.__parseBusyBlocks__(u,s=st,e=et)
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.