def path_localLocationCheck(self, d_msg, **kwargs):
        """
        Check if a path exists on the local filesystem

        :param self:
        :param kwargs:
        :return:
        """
        b_pull                      = False
        d_meta                      = d_msg['meta']
        if 'do' in d_meta:
            if d_meta['do'] == 'pull':
                b_pull              = True
        if 'local' in d_meta:
            d_local                 = d_meta['local']
        if 'to' in d_meta:
            d_local                 = d_meta['to']

        str_localPathFull           = d_local['path']
        str_localPath, str_unpack   = os.path.split(str_localPathFull)
        str_msg                     = ''
        str_checkedDir              = str_localPathFull

        b_isFile                    = os.path.isfile(str_localPathFull)
        b_isDir                     = os.path.isdir(str_localPathFull)
        b_exists                    = os.path.exists(str_localPathFull)

        if 'pull' in d_msg['action'] or b_pull:
            # If we are "pulling" data to local, then we assume the local
            # directory does not exist. If it does, and if 'createDir' is 'true', 
            # we remove the localPath and re-create it, thus assuring it will 
            # only contain the info pulled from the remote source.
            # If 'writeInExisting' is 'true', then execution continues, but
            # may fail if the pulled target exists in the localPath.

            str_checkedDir              = str_localPath
            b_isFile                    = os.path.isfile(str_localPath)
            b_isDir                     = os.path.isdir(str_localPath)
            b_exists                    = os.path.exists(str_localPath)

            if 'createDir' in d_local.keys():
                if d_local['createDir']:
                    if os.path.isdir(str_localPathFull):
                        self.dp.qprint('Removing local path %s...' % str_localPathFull)
                        shutil.rmtree(str_localPathFull)
                        str_msg         = 'Removed existing local path... '
                    self.dp.qprint('Creating empty local path %s...' % str_localPathFull)
                    os.makedirs(str_localPathFull)
                    b_exists = True
                    str_msg += 'Created new local path'
            else:
                str_msg = 'local path already exists!'
                if 'writeInExisting' in d_local.keys():
                    if not d_local['writeInExisting']: 
                        if b_isDir: b_exists = False
                else:
                    if b_isDir: b_exists = False

        d_ret = {
            'action':   d_msg['action'],
            'dir':      str_checkedDir,
            'status':   b_exists,
            'isfile':   b_isFile,
            'isdir':    b_isDir,
            'msg':      str_msg
        }

        return {'check':        d_ret,
                'status':       d_ret['status'],
                'timestamp':    '%s' % datetime.datetime.now()}
def path_localLocationCheck ( self , d_msg , ** kwargs ) : b_pull = False d_meta = d_msg [ 'meta' ] if 'do' in d_meta : if d_meta [ 'do' ] == 'pull' : b_pull = True if 'local' in d_meta : d_local = d_meta [ 'local' ] if 'to' in d_meta : d_local = d_meta [ 'to' ] str_localPathFull = d_local [ 'path' ] str_localPath , str_unpack = os . path . split ( str_localPathFull ) str_msg = '' str_checkedDir = str_localPathFull b_isFile = os . path . isfile ( str_localPathFull ) b_isDir = os . path . isdir ( str_localPathFull ) b_exists = os . path . exists ( str_localPathFull ) if 'pull' in d_msg [ 'action' ] or b_pull : str_checkedDir = str_localPath b_isFile = os . path . isfile ( str_localPath ) b_isDir = os . path . isdir ( str_localPath ) b_exists = os . path . exists ( str_localPath ) if 'createDir' in d_local . keys ( ) : if d_local [ 'createDir' ] : if os . path . isdir ( str_localPathFull ) : self . dp . qprint ( 'Removing local path %s...' % str_localPathFull ) shutil . rmtree ( str_localPathFull ) str_msg = 'Removed existing local path... ' self . dp . qprint ( 'Creating empty local path %s...' % str_localPathFull ) os . makedirs ( str_localPathFull ) b_exists = True str_msg += 'Created new local path' else : str_msg = 'local path already exists!' if 'writeInExisting' in d_local . keys ( ) : if not d_local [ 'writeInExisting' ] : if b_isDir : b_exists = False else : if b_isDir : b_exists = False d_ret = { 'action' : d_msg [ 'action' ] , 'dir' : str_checkedDir , 'status' : b_exists , 'isfile' : b_isFile , 'isdir' : b_isDir , 'msg' : str_msg } return { 'check' : d_ret , 'status' : d_ret [ 'status' ] , 'timestamp' : '%s' % datetime . datetime . now ( ) }
Check if a path exists on the local filesystem

        :param self:
        :param kwargs:
        :return: