Ejemplo n.º 1
0
    def getTasks(self, user, mode=IA.All):
        # update last active clients
        self.last_clients[user] = time()

        # filter current mode
        tasks = [t for t in self.tasks.itervalues() if mode == IA.All or bits_set(t.type, mode)]
        # filter correct user / or shared
        tasks = [t for t in tasks if user is None or user == t.owner or t.shared]

        return tasks
Ejemplo n.º 2
0
    def getTasks(self, user, mode=IA.All):
        # update last active clients
        self.last_clients[user] = time()

        # filter current mode
        tasks = [
            t for t in self.tasks.itervalues()
            if mode == IA.All or bits_set(t.type, mode)
        ]
        # filter correct user / or shared
        tasks = [
            t for t in tasks if user is None or user == t.owner or t.shared
        ]

        return tasks
Ejemplo n.º 3
0
 def updateClient(self, mode):
     t = time()
     for output in self.last_clients:
         if bits_set(output, mode):
             self.last_clients[output] = t
Ejemplo n.º 4
0
    def getTask(self, mode=Output.All):
        self.updateClient(mode)

        for task in self.tasks.itervalues():
            if mode == Output.All or bits_set(task.output, mode):
                return task
Ejemplo n.º 5
0
    def hasPermission(self, perms):
        """  Accepts permission bit or name  """
        if isinstance(perms, basestring) and hasattr(Permission, perms):
            perms = getattr(Permission, perms)

        return bits_set(perms, self.permission)
Ejemplo n.º 6
0
 def updateClient(self, mode):
     t = time()
     for output in self.last_clients:
         if bits_set(output, mode):
             self.last_clients[output] = t
Ejemplo n.º 7
0
    def getTask(self, mode=Output.All):
        self.updateClient(mode)

        for task in self.tasks.itervalues():
            if mode == Output.All or bits_set(task.output, mode):
                return task
Ejemplo n.º 8
0
    def hasPermission(self, perms):
        """  Accepts permission bit or name  """
        if isinstance(perms, basestring) and hasattr(Permission, perms):
            perms = getattr(Permission, perms)

        return bits_set(perms, self.permission)