Beispiel #1
0
 def StorePackageHashes(self, projectPathSrc, username, projectname,
                        branchname):
     shell = Shell(Logger())
     con = Database(self.config)
     for dir in os.listdir(projectPathSrc):
         if os.path.isdir(projectPathSrc + "/" + dir):
             packagename = os.path.basename(dir)
             # update hash of each package
             cmd = "find " + projectPathSrc + "/" + dir + " -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | awk '{print $1}'"
             hash = shell.evaluateshell(cmd)
             # print(packagename + " " + hash)
             cursor = con.execute(
                 "SELECT * FROM package WHERE username = ? AND projectname = ? AND packagename = ? AND branchname = ?",
                 (username, projectname, packagename, branchname))
             row = cursor.fetchone()
             alreadyuptodate = False
             idToUpdate = None
             if row is not None:
                 if row['sourcehash'] == hash:
                     alreadyuptodate = True
                 else:
                     idToUpdate = row['id']
             if not alreadyuptodate:
                 if idToUpdate is None:
                     stmt = "INSERT INTO package(username, projectname, packagename, branchname, sourcehash) VALUES(?,?,?,?,?)"
                     cursor = con.execute(stmt,
                                          (username, projectname,
                                           packagename, branchname, hash))
                 else:
                     stmt = "UPDATE package SET sourcehash = ? WHERE id = ?"
                     cursor = con.execute(stmt, (hash, idToUpdate))
                     self.MarkPackageAsDirty(con, idToUpdate)
                 con.commit()
     con.close()
 def StorePackageHashes(self, projectPathSrc, username, projectname, branchname):
   shell = Shell(Logger())
   con = Database(self.config)
   for dir in os.listdir(projectPathSrc):
     if os.path.isdir(projectPathSrc + "/" + dir):
       packagename = os.path.basename(dir)
       # update hash of each package
       cmd = "find " + projectPathSrc + "/" + dir + " -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | awk '{print $1}'"
       hash = shell.evaluateshell(cmd)
       # print(packagename + " " + hash)
       cursor = con.execute("SELECT * FROM package WHERE username = ? AND projectname = ? AND packagename = ? AND branchname = ?", (username, projectname, packagename, branchname))
       row = cursor.fetchone()
       alreadyuptodate = False
       idToUpdate = None
       if row is not None:
         if row['sourcehash'] == hash:
           alreadyuptodate = True
         else:
           idToUpdate = row['id']
       if not alreadyuptodate:
         if idToUpdate is None:
           stmt = "INSERT INTO package(username, projectname, packagename, branchname, sourcehash) VALUES(?,?,?,?,?)"
           cursor = con.execute(stmt, (username, projectname, packagename, branchname, hash))
         else:
           stmt = "UPDATE package SET sourcehash = ? WHERE id = ?"
           cursor = con.execute(stmt, (hash, idToUpdate))
           self.MarkPackageAsDirty(con, idToUpdate)
         con.commit()
   con.close()