当前位置: 首页>>代码示例>>Python>>正文


Python FTP_TLS.pwd方法代码示例

本文整理汇总了Python中ftplib.FTP_TLS.pwd方法的典型用法代码示例。如果您正苦于以下问题:Python FTP_TLS.pwd方法的具体用法?Python FTP_TLS.pwd怎么用?Python FTP_TLS.pwd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ftplib.FTP_TLS的用法示例。


在下文中一共展示了FTP_TLS.pwd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import pwd [as 别名]
 def connect(self):
     #初始化 FTP 链接
     if self.ftp_ssl:
         ftp = FTPS()
     else:
         ftp = FTP()
     print('-'*20+self.ftp_name+'-'*20)
     print('connect '+('ftps' if self.ftp_ssl else 'ftp')+'://'+self.ftp_host+':'+self.ftp_port)
     try:
         ftp.connect(self.ftp_host,self.ftp_port)
     except Exception as e:
         print (e)
         print ('connect ftp server failed')
         sys.exit()
     try:
         ftp.login(self.ftp_user,self.ftp_passwd)
         print ('login ok')
     except Exception as e:#可能服务器不支持ssl,或者用户名密码不正确
         print (e)
         print ('Username or password are not correct')
         sys.exit()        
     
     if self.ftp_ssl:
         try:    
             ftp.prot_p()
         except Exception as e:
             print (e)
             print ('Make sure the SSL is on ;')
         
     print(ftp.getwelcome())
     ftp.cwd(self.ftp_webroot)
     print('current path: '+ftp.pwd())
     
     self.ftp=ftp
开发者ID:ttym7993,项目名称:sync_web,代码行数:36,代码来源:sync_web.py

示例2: FTPClient

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import pwd [as 别名]

#.........这里部分代码省略.........
                'htk_on_error', 'error: {0}'.format(ex), self._mh.fromhere())
            return None

    def change_dir(self, path):
        """Method changes remote working directory

        Args:
           path (str): new remote path

        Returns:
           bool: result         

        Raises:
           event: ftp_before_change_dir        

        """

        try:

            self._mh.demsg('htk_on_debug_info', self._mh._trn.msg(
                'htk_ftp_change_dir', path), self._mh.fromhere())

            if (not self._is_connected):
                self._mh.demsg('htk_on_warning', self._mh._trn.msg(
                    'htk_ftp_not_connected'), self._mh.fromhere())
                return False

            ev = event.Event('ftp_before_change_dir', path)
            if (self._mh.fire_event(ev) > 0):
                path = ev.argv(0)

            if (ev.will_run_default()):
                self._client.cwd(path)
                self._path = self._client.pwd()

            self._mh.demsg('htk_on_debug_info', self._mh._trn.msg(
                'htk_ftp_cur_dir', self._path), self._mh.fromhere())
            return True

        except all_errors as ex:
            self._mh.demsg(
                'htk_on_error', 'error: {0}'.format(ex), self._mh.fromhere())
            return False

    def download_file(self, remote_path, local_path=None):
        """Method downloads file from server

        Args:
           remote_path (str): remote path
           local_path (str): local path, default ./filename

        Returns:
           bool: result         

        Raises:
           event: ftp_before_download_file
           event: ftp_after_download_file    

        """

        try:

            self._mh.demsg('htk_on_debug_info', self._mh._trn.msg(
                'htk_ftp_downloading_file', remote_path), self._mh.fromhere())

            if (not self._is_connected):
开发者ID:hydratk,项目名称:hydratk-lib-network,代码行数:70,代码来源:ftp_client.py

示例3: FTP_TLS

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import pwd [as 别名]
secret = '123456'
host = '192.168.1.113'
try:
    #instantiate FTPS
    #ftps = FTP_TLS(host,user,secret)
    ftps = FTP_TLS(host)
    # TODO check why the next line not work
    #See http://stackoverflow.com/questions/10207628/python-module-ftplib-ftp-tls-error-530
    #Try TLS Lite or M2Crypto both are FTP/TLS client and server.

    #ftps.login(user,secret)

    ftps.sendcmd('USER ' + user)
    ftps.sendcmd('PASS ' + secret)
    print(ftps.getwelcome())
    print('CURRENT WORKING DIRECTORY IS:',ftps.pwd())
    #Enable data encryption
    # TODO solve the encryption problem
    #ftps.prot_p()
    #define default DIR
    d = 'feeds'
    #Change to default DIR
    ftps.cwd(d)
    #Build list of files on servers
    l = ftps.nlst()
    l.sort()
    for i in l:
        print(i)
    #Assign last element to var
    litem = len(l)-1
    print("MOST RECENT FILE ON SERVER IS; ",l[litem])
开发者ID:yaowenqiang,项目名称:python,代码行数:33,代码来源:ftp.py


注:本文中的ftplib.FTP_TLS.pwd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。