# Path: bliss/interface/filesysteminterface.py
# class FilesystemPluginInterface(PluginBaseInterface):
#     '''Abstract base class for all filesystem plugins'''
#  
#     def __init__(self, name, schemas):
#         '''Class constructor'''
#         PluginBaseInterface.__init__(self, name=name, schemas=schemas,
#                                      api=PluginBaseInterface.api_type_saga_filesystem)
#     
#     def register_file_object(self, file_obj):
#         '''This method is called upon instantiation of a new file object
#         '''
#         errormsg = "Not implemented plugin method called: register_file_object()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def unregister_file_object(self, file_obj):
#         '''This method is called upon deletion of a file object
#         '''
#         self.log_error("Not implemented plugin method called: unregister_file_object()")
#         # don't throw -- destructor context
# 
#     def register_directory_object(self, dir_obj):
#         '''This method is called upon instantiation of a new file object
#         '''
#         errormsg = "Not implemented plugin method called: register_directory_object()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def unregister_directory_object(self, dir_obj):
#         '''This method is called upon deletion of a file object
#         '''
#         self.log_error("Not implemented plugin method called: unregister_directory_object()")
#         # don't throw -- destructor context
# 
#     def file_copy(self, file_obj, target_url, flags):
#         '''This method is called upon file.copy()
#         '''
#         errormsg = "Not implemented plugin method called: file_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def file_move(self, file_obj, target_url, flags):
#         '''This method is called upon file.copy()
#         '''
#         errormsg = "Not implemented plugin method called: file_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def file_get_size(self, file_obj):
#         '''This methid is called upon file.get_size()
#         ''' 
#         errormsg = "Not implemented plugin method called: file_get_size()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def dir_close(self, dir_obj):
#         '''This methid is called upon dir.close()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_close()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_list(self, dir_obj):
#         '''This method is called upon dir.list()
#         '''
#         errormsg = "Not implemented plugin method called: dir_list()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_remove(self, dir_obj, path=None):
#         '''This method is called upon dir.remove()
#         '''
#         errormsg = "Not implemented plugin method called: dir_remove()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_make_dir(self, dir_obj, path, flags):
#         '''This methid is called upon dir.make_dir()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_make_dir()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_copy(self, dir_obj, source, target, flags):
#         '''This methid is called upon dir.copy()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_get_size(self, dir_obj, path):
#         '''This methid is called upon dir.get_size()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_get_size()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_exists(self, dir_obj, path):
#         '''This methid is called upon dir.exists()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_exists()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_is_dir(self, dir_obj, path):
#         '''This methid is called upon dir.is_dir()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_is_dir()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)


from bliss.interface import FilesystemPluginInterface
        from stat import S_ISDIR
            from shutil import rmtree
import os, pwd
import time
import bliss.saga
import logging
import warnings
    import paramiko
            import warnings
                import paramiko
                # add connection to connection pool
                self._connections[fsobj_key] = ssh
                return self._connections[fsobj_key] 
            #except Exception, ex:
            #    self._parent.log_error_and_raise(bliss.saga.Error.NoSuccess, 
            #    "Couldn't create SFTP connection: %s " % (str(ex)))


################################################################################
################################################################################

class SFTPFilesystemPlugin(FilesystemPluginInterface):
    '''Implements a filesystem plugin that does things via SSH
    '''
    ## Define adaptor name. Convention is:
    ##         saga.plugin.<package>.<name>
    _name = 'saga.plugin.file.sftp'

    ## Define supported url schemas
    ## 
    _schemas = ['sftp']

    ## Define apis supported by this adaptor
    ##
    _apis = ['saga.filesystem']


    ##
    def __init__(self, url):
        '''Class constructor'''

# Path: bliss/interface/filesysteminterface.py
# class FilesystemPluginInterface(PluginBaseInterface):
#     '''Abstract base class for all filesystem plugins'''
#  
#     def __init__(self, name, schemas):
#         '''Class constructor'''
#         PluginBaseInterface.__init__(self, name=name, schemas=schemas,
#                                      api=PluginBaseInterface.api_type_saga_filesystem)
#     
#     def register_file_object(self, file_obj):
#         '''This method is called upon instantiation of a new file object
#         '''
#         errormsg = "Not implemented plugin method called: register_file_object()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def unregister_file_object(self, file_obj):
#         '''This method is called upon deletion of a file object
#         '''
#         self.log_error("Not implemented plugin method called: unregister_file_object()")
#         # don't throw -- destructor context
# 
#     def register_directory_object(self, dir_obj):
#         '''This method is called upon instantiation of a new file object
#         '''
#         errormsg = "Not implemented plugin method called: register_directory_object()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def unregister_directory_object(self, dir_obj):
#         '''This method is called upon deletion of a file object
#         '''
#         self.log_error("Not implemented plugin method called: unregister_directory_object()")
#         # don't throw -- destructor context
# 
#     def file_copy(self, file_obj, target_url, flags):
#         '''This method is called upon file.copy()
#         '''
#         errormsg = "Not implemented plugin method called: file_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def file_move(self, file_obj, target_url, flags):
#         '''This method is called upon file.copy()
#         '''
#         errormsg = "Not implemented plugin method called: file_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def file_get_size(self, file_obj):
#         '''This methid is called upon file.get_size()
#         ''' 
#         errormsg = "Not implemented plugin method called: file_get_size()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg) 
# 
#     def dir_close(self, dir_obj):
#         '''This methid is called upon dir.close()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_close()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_list(self, dir_obj):
#         '''This method is called upon dir.list()
#         '''
#         errormsg = "Not implemented plugin method called: dir_list()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_remove(self, dir_obj, path=None):
#         '''This method is called upon dir.remove()
#         '''
#         errormsg = "Not implemented plugin method called: dir_remove()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_make_dir(self, dir_obj, path, flags):
#         '''This methid is called upon dir.make_dir()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_make_dir()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_copy(self, dir_obj, source, target, flags):
#         '''This methid is called upon dir.copy()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_copy()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_get_size(self, dir_obj, path):
#         '''This methid is called upon dir.get_size()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_get_size()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_exists(self, dir_obj, path):
#         '''This methid is called upon dir.exists()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_exists()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)
# 
#     def dir_is_dir(self, dir_obj, path):
#         '''This methid is called upon dir.is_dir()
#         ''' 
#         errormsg = "Not implemented plugin method called: dir_is_dir()"
#         self.log_error_and_raise(SAGAError.NotImplemented, errormsg)


# Path: bliss/plugins/sftp/sftpfile.py
from bliss.interface import FilesystemPluginInterface
        from stat import S_ISDIR
            from shutil import rmtree
import os, pwd
import time
import bliss.saga
import logging
import warnings
    import paramiko
            import warnings
                import paramiko

                # add connection to connection pool
                self._connections[fsobj_key] = ssh
                return self._connections[fsobj_key] 
            #except Exception, ex:
            #    self._parent.log_error_and_raise(bliss.saga.Error.NoSuccess, 
            #    "Couldn't create SFTP connection: %s " % (str(ex)))


################################################################################
################################################################################

class SFTPFilesystemPlugin(FilesystemPluginInterface):
    '''Implements a filesystem plugin that does things via SSH
    '''
    ## Define adaptor name. Convention is:
    ##         saga.plugin.<package>.<name>
    _name = 'saga.plugin.file.sftp'

    ## Define supported url schemas
    ## 
    _schemas = ['sftp']

    ## Define apis supported by this adaptor
    ##
    _apis = ['saga.filesystem']


    ##
    def __init__(self, url):
        '''Class constructor'''

        FilesystemPluginInterface.__init__(self, name=self._name, schemas=self._schemas)