def upload(self, localpath, href):
        """
        Upload file from localpath to remote server
        :param localpath: local path
        :param href: remote path
        :return: response
        """
        localpath = _(localpath)
        href = remote(href)
        if not os.path.exists(localpath):
            logger.info(u("ERROR: localfile: %s not found") % localpath)
            return
        if os.path.islink(localpath):
            return self.upload(os.path.abspath(os.path.realpath(localpath)), href)
            # 3 tryings to upload file
        for iTry in range(TRYINGS):
            try:
                logger.info(u("upload: %s %s") % (localpath, href))
                length = os.path.getsize(localpath)

                if PY3:
                    _open = open(_encode_utf8(localpath), "r", encoding='latin-1')
                else:
                    _open = open(_encode_utf8(localpath), "r")
                with _open as f:
                    return self.write(f, href, length=length)
            except ConnectionException:
                raise
            except Exception:
                e = sys.exc_info()[1]
                logger.exception(e)
def upload ( self , localpath , href ) : localpath = _ ( localpath ) href = remote ( href ) if not os . path . exists ( localpath ) : logger . info ( u ( "ERROR: localfile: %s not found" ) % localpath ) return if os . path . islink ( localpath ) : return self . upload ( os . path . abspath ( os . path . realpath ( localpath ) ) , href ) for iTry in range ( TRYINGS ) : try : logger . info ( u ( "upload: %s %s" ) % ( localpath , href ) ) length = os . path . getsize ( localpath ) if PY3 : _open = open ( _encode_utf8 ( localpath ) , "r" , encoding = 'latin-1' ) else : _open = open ( _encode_utf8 ( localpath ) , "r" ) with _open as f : return self . write ( f , href , length = length ) except ConnectionException : raise except Exception : e = sys . exc_info ( ) [ 1 ] logger . exception ( e )
Upload file from localpath to remote server
        :param localpath: local path
        :param href: remote path
        :return: response