Commit ba4ebc9b authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'nodeIsBusy()' getter method.

parent 99b59983
Loading
Loading
Loading
Loading
+27 −6
Original line number Diff line number Diff line
@@ -221,6 +221,27 @@ class DbConnector(object):
                print(e)
        return result

    def nodeIsBusy(self, vospacePath):
        """Returns 'True' if the VOSpace node is busy, 'False' otherwise."""
        with self.getConnection() as conn:
            try:
                cursor = conn.cursor(cursor_factory = RealDictCursor)
                cursor.execute("""
                    SELECT job_id
                    FROM node
                    WHERE node_id = id_from_vos_path(%s);
                    """,
                    (vospacePath,))
                result = cursor.fetchall()
            except Exception as e:
                if not conn.closed:
                    conn.rollback()
                print(e)
        if result[0]["job_id"]:
            return True
        else:
            return False

    ##### Job #####

    def jobExists(self, jobId):