<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ftplib on Sourav Badami</title>
    <link>https://souravbadami.com/tags/ftplib/</link>
    <description>Recent content in ftplib on Sourav Badami</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Wed, 15 Nov 2017 02:31:13 +0530</lastBuildDate><atom:link href="https://souravbadami.com/tags/ftplib/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>the requested address is not valid in its context</title>
      <link>https://souravbadami.com/the-requested-address-is-not-valid-in-its-context/</link>
      <pubDate>Wed, 15 Nov 2017 02:31:13 +0530</pubDate>
      
      <guid>https://souravbadami.com/the-requested-address-is-not-valid-in-its-context/</guid>
      <description>facing this with Python 2.7 and ftplib? i won’t waste your time; let’s fix it.
the error shows up when passive mode returns an address your client can’t route to. ftplib trusts that address; your network doesn’t. so we stop trusting it — subclass FTP_TLS, keep the port from makepasv, and force the host you already connected to.
import ftplib class FTP_TLS_UNROUTABLE_HOST(ftplib.FTP_TLS, object): def makepasv(self): _, port = super(FTP_TLS_UNROUTABLE_HOST, self).makepasv() return self.</description>
    </item>
    
  </channel>
</rss>
