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

Added getRapId(username) temporary method.

parent 0b09bd05
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@ class DbConnector(object):
        self.cursor = self.conn.cursor()

    def disconnect(self):
        if(self.conn):
        if self.conn:
            self.cursor.close()
            self.conn.close()

    def insertNode(self, node, parentOSPath):
        if(self.conn):
        if self.conn:
            #print(f"parentOSPath: {parentOSPath}")
            self.cursor.execute("SELECT get_ltree_path(%s)", (parentOSPath,))
            parentLtreePath = self.cursor.fetchone()[0]
@@ -42,3 +42,7 @@ class DbConnector(object):
    def selectNode(self):
        pass

    def getRapId(self, username):
        if self.conn:
            self.cursor.execute("SELECT rap_id FROM Users WHERE user_name = %s;", (username,))
            return self.cursor.fetchone()[0]
 No newline at end of file
+10 −6
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ class StorePreprocessor(Preprocessor):
        self.params = config.loadSection("transfer_node")
        self.storageBasePath = self.params["base_path"]        
        self.jobObj = None
        self.username = None
        self.userId = None
        self.dbConn.connect()
        super(StorePreprocessor, self).__init__()

@@ -132,6 +134,7 @@ class StorePreprocessor(Preprocessor):
        
        # File catalog update
        out = open("log.txt", "w")
        self.userId = self.dbConn.getRapId(self.username)
        for dir in dirs:
            out.write(f"DIR: {dir}\n")
            pathPrefix = self.storageBasePath.replace("{username}", self.username)
@@ -140,8 +143,8 @@ class StorePreprocessor(Preprocessor):
            out.write(f"basePath: {basePath}\n")
            cnode = Node(os.path.basename(dir), "container");            
            cnode.setParentPath(basePath)
            cnode.setOwnerID("3354")
            cnode.setCreatorID("3354")
            cnode.setOwnerID(self.userId)
            cnode.setCreatorID(self.userId)
            self.dbConn.insertNode(cnode, cnode.parentPath)
            
        for flist in files:
@@ -154,8 +157,8 @@ class StorePreprocessor(Preprocessor):
                    out.write(f"basePath: {basePath}\n")
                    dnode = Node(os.path.basename(file), "data")
                    dnode.setParentPath(basePath)
                    dnode.setOwnerID("3354")
                    dnode.setCreatorID("3354")
                    dnode.setOwnerID(self.userId)
                    dnode.setCreatorID(self.userId)
                    dnode.setContentMD5(self.md5calc.getMD5(file))                
                    self.dbConn.insertNode(dnode, dnode.parentPath)

@@ -164,6 +167,7 @@ class StorePreprocessor(Preprocessor):
        
    def run(self):
        while True:
            time.sleep(10)
            if(self.readyQueue.len() <= self.maxReadyJobs and self.pendingQueue.len() > 0):
                self.jobObj = self.pendingQueue.getJob()
                self.username = self.jobObj["jobInfo"]["userName"]
@@ -171,7 +175,7 @@ class StorePreprocessor(Preprocessor):
                self.execute()
                self.pendingQueue.moveJobTo("ready")
                print("Job MOVED!")
            time.sleep(1)
            time.sleep(10)

# Test
#sp = StorePreprocessor()