<commit_before>import os
import pysftp
import logging

from emailsender import EmailSender


class SFTPClient:
    """A class for handling the sftp transactions. This class contains
    functions for getting a file from sftp server and putting a file
    to a sftp server"""
    def __init__(self, hostname, port=22, username=None, password=<PASSWORD>,
                 private_key=None, private_key_pass=None):
        self.data = []
        self._hostname = hostname
        self._port = int(port)
        self._username = username
        self._password = password
        self._private_key = private_key
        self._private_key_pass = private_key_pass


    def send_file_to_uri(self, remote_path, file_name, local_path, props = None):
        '''
        To email exceptions the caller must pass
        the object `props` of type EmailProps
        '''
        try:
            self.put(local_path, os.path.join(remote_path, file_name))
        except Exception, e:
            error = 'There was an error sending file %s to %s: %s' % (file_name, self._hostname, str(e))
            logging.error(error)
            logging.error('Please check the credentials/remotepath/localpath/Server URI')

            if props:
                # include the exception in the email body
                props.msg_body = error
                EmailSender().send(props)


    def get_file_from_uri(self, remote_path, local_path, props = None):
        '''
        To email exceptions the caller must pass
        the object `props` of type EmailProps
        '''
        try:
            self.get(remote_path, local_path)
        except Exception, e:
            error = 'There was an error getting file %s from %s: %s' % (remote_path, self._hostname, str(e))
            logging.error(error)

            if props:
                # include the exception in the email body
                props.msg_body = error
                EmailSender().send(props)

        return

<commit_msg>sftpclient.py now logs the directory that caused an error.<commit_after>import os
import pysftp
import logging

from emailsender import EmailSender


class SFTPClient:
    """A class for handling the sftp transactions. This class contains
    functions for getting a file from sftp server and putting a file
    to a sftp server"""
    def __init__(self, hostname, port=22, username=None, password=<PASSWORD>,
                 private_key=None, private_key_pass=None):
        self.data = []
        self._hostname = hostname
        self._port = int(port)
        self._username = username
        self._password = password
        self._private_key = private_key
        self._private_key_pass = private_key_pass


    def send_file_to_uri(self, remote_path, file_name, local_path, props = None):
        '''
        To email exceptions the caller must pass
        the object `props` of type EmailProps
        '''
        try:
            self.put(local_path, os.path.join(remote_path, file_name))
        except Exception, e:
            error = 'There was an error sending file %s to %s: %s\n' % (file_name, self._hostname, str(e))
            error = error + "SFTP file location: " + remote_path
            logging.error(error)
            logging.error('Please check the credentials/remotepath/localpath/Server URI')

            if props:
                # include the exception in the email body
                props.msg_body = error
                EmailSender().send(props)


    def get_file_from_uri(self, remote_path, local_path, props = None):
        '''
        To email exceptions the caller must pass
        the object `props` of type EmailProps
        '''
        try:
            self.get(remote_path, local_path)
        except Exception, e:
            error = 'There was an error getting file %s from %s: %s' % (remote_path, self._hostname, str(e))
            logging.error(error)

            if props:
                # include the exception in the email body
                props.msg_body = error
                EmailSender().send(props)

        return


{'fraction_non_alphanumeric': 0.07940019665683383, 'fraction_numerical': 0.0009832841691248771, 'mean_word_length': 2.13, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '777199', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1079, 'n_words': 356}