Python Secure FTP module

Overview In the previous post we covered the ftplib module in Python, which you can read more about here. In this post we will cover the pysftp module. SFTP (Secure File Transfer Protocol) is used for for securely exchanging files over the Internet. What is it? pysftp is an easy to use sftp module that ...

How to use FTP in Python

Overview This article will show how you can use FTP in Python with the help of the ftplib module. Ftplib The ftplib module in Python allows you to write Python programs that perform a variety of automated FTP jobs. You can easily connect to a FTP server to retrieve files and process them locally. To ...

Argparse Tutorial

What is it? Parser for command-line options, arguments and subcommands Why use it? The argparse module makes it easy to write user-friendly command-line interfaces. How does it do that? The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. The argparse module also automatically generates help ...

How to use the envoy wrapper

Overview Recently I stumble upon Envoy. Envoy is a wrapper around the subprocess module. Its written by Kenneth Reitz (the author of "Requests: HTTP for Humans") Why use it? It was written to be an easy to use alternative to subprocess. "Envoy: Python Subprocesses for Humans." How do I get it? Envoy is available from ...

Sending emails using Google

Overview A common task for system administrators and developers is to use scripts to send emails if an error occurs. Why use Gmail? Using Googles SMTP servers are free to use and works perfectly fine to relay emails. Note that Google has a sending limit: "Google will temporarily disable your account if you send messages ...

Web Scraping with BeautifulSoup

Web Scraping "Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites." HTML parsing is easy in Python, especially with help of the BeautifulSoup library. In this post we will scrape a website (our own) to extract all URL's. Getting Started To begin with, make sure that ...

Development Environment in Python

Overview Some of the steps needed to setup a development environment includes: Operating system - e.g Linux / Mac Project structure - project structure Virtualenv - isolated installation of the project Pip - a tool for installing and managing Python packages Git - source control Webserver - where we can manage our applications Fabric - ...

Using pywhois

What is pywhois? pywhois is a Python module for retrieving WHOIS information of domains. pywhois works with Python 2.4+ and no external dependencies [Source] Installation The installation of pywhois is done through the pip command. pip install python-whois >>> import whois >>> pywhois Usage We can use the pywhois module to query a WHOIS server ...

How to use sh in Python

What is sh? sh is a unique subprocess wrapper that maps your system programs to Python functions dynamically. sh helps you write shell scripts in Python by giving you the good features of Bash (easy command calling, easy piping) with all the power and flexibility of Python. [source] Starting with sh sh is a full-fledged ...

With statement in Python

Overview In Python you need to give access to a file by opening it. You can do it by using the open() function. Open returns a file object, which has methods and attributes for getting information about and manipulating the opened file. With statement With the "With" statement, you get better syntax and exceptions handling. ...