Loading client/config.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python from configparser import ConfigParser, ExtendedInterpolation Loading transfer_service/abort_job_amqp_server.py +3 −2 Original line number Diff line number Diff line #!/usr/bin/env python from amqp_server import AMQPServer from db_connector import DbConnector from config import Config Loading @@ -19,9 +21,8 @@ class AbortJobAMQPServer(AMQPServer): super(AbortJobAMQPServer, self).__init__(host, port, queue) def execute_callback(self, requestBody): #self.dbConn.connect() #TODO # do something... #self.dbConn.disconnect() return 42 def run(self): Loading transfer_service/amqp_server.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python import pika import threading import json Loading transfer_service/checksum.py +16 −10 Original line number Diff line number Diff line #!/usr/bin/env python import hashlib import os import sys Loading @@ -13,20 +15,22 @@ class Checksum(object): self.fileBufferSize = self.params.getint("file_buffer_size") self.md5FileSuffix = self.params["md5_file_suffix"] # Sets the buffer size in bytes when reading a chunk of data def setFileBufferSize(fileBufferSize): """Sets the buffer size in bytes when reading a chunk of data.""" self.fileBufferSize = fileBufferSize # Checks whether a file is a checksum file or not def fileIsValid(self, absFilePath): """Checks whether a file is a checksum file or not""" if not self.md5FileSuffix in absFilePath: return True else: return False # Returns the MD5 checksum corresponding to a give filename # according to its absolute path on disk def getMD5(self, absFilePath): """ Returns the MD5 checksum corresponding to a give filename according to its absolute path on disk. """ if self.fileIsValid(absFilePath): md5FileName = os.path.dirname(absFilePath) + self.md5FileSuffix md5File = open(md5FileName, "r") Loading @@ -37,17 +41,19 @@ class Checksum(object): return md5sum return None # Calculates the MD5 checksum of a file def md5sum(self, filePath): """Calculates the MD5 checksum of a file.""" md5Hash = hashlib.md5() with open(filePath, "rb") as f: for chunk in iter(lambda: f.read(self.fileBufferSize), b""): md5Hash.update(chunk) return md5Hash.hexdigest() # Calculates MD5 checksums recursively and saves on disk the list of # files in a folder with also the corresponding checksums def recursive(self, folderPath): """ Calculates MD5 checksums recursively and saves on disk the list of files in a folder with also the corresponding checksums. """ for folder, subfolder, files in os.walk(folderPath, topdown = False): cwd = os.path.basename(folder) parent = os.path.dirname(folder) Loading transfer_service/config.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python from configparser import ConfigParser, ExtendedInterpolation Loading Loading
client/config.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python from configparser import ConfigParser, ExtendedInterpolation Loading
transfer_service/abort_job_amqp_server.py +3 −2 Original line number Diff line number Diff line #!/usr/bin/env python from amqp_server import AMQPServer from db_connector import DbConnector from config import Config Loading @@ -19,9 +21,8 @@ class AbortJobAMQPServer(AMQPServer): super(AbortJobAMQPServer, self).__init__(host, port, queue) def execute_callback(self, requestBody): #self.dbConn.connect() #TODO # do something... #self.dbConn.disconnect() return 42 def run(self): Loading
transfer_service/amqp_server.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python import pika import threading import json Loading
transfer_service/checksum.py +16 −10 Original line number Diff line number Diff line #!/usr/bin/env python import hashlib import os import sys Loading @@ -13,20 +15,22 @@ class Checksum(object): self.fileBufferSize = self.params.getint("file_buffer_size") self.md5FileSuffix = self.params["md5_file_suffix"] # Sets the buffer size in bytes when reading a chunk of data def setFileBufferSize(fileBufferSize): """Sets the buffer size in bytes when reading a chunk of data.""" self.fileBufferSize = fileBufferSize # Checks whether a file is a checksum file or not def fileIsValid(self, absFilePath): """Checks whether a file is a checksum file or not""" if not self.md5FileSuffix in absFilePath: return True else: return False # Returns the MD5 checksum corresponding to a give filename # according to its absolute path on disk def getMD5(self, absFilePath): """ Returns the MD5 checksum corresponding to a give filename according to its absolute path on disk. """ if self.fileIsValid(absFilePath): md5FileName = os.path.dirname(absFilePath) + self.md5FileSuffix md5File = open(md5FileName, "r") Loading @@ -37,17 +41,19 @@ class Checksum(object): return md5sum return None # Calculates the MD5 checksum of a file def md5sum(self, filePath): """Calculates the MD5 checksum of a file.""" md5Hash = hashlib.md5() with open(filePath, "rb") as f: for chunk in iter(lambda: f.read(self.fileBufferSize), b""): md5Hash.update(chunk) return md5Hash.hexdigest() # Calculates MD5 checksums recursively and saves on disk the list of # files in a folder with also the corresponding checksums def recursive(self, folderPath): """ Calculates MD5 checksums recursively and saves on disk the list of files in a folder with also the corresponding checksums. """ for folder, subfolder, files in os.walk(folderPath, topdown = False): cwd = os.path.basename(folder) parent = os.path.dirname(folder) Loading
transfer_service/config.py +2 −0 Original line number Diff line number Diff line #!/usr/bin/env python from configparser import ConfigParser, ExtendedInterpolation Loading