Author: Wolfram Donat

How to: FTP Uploads with Python

Introduction

In another article on using ftplib in Python, we talked about using Python’s ftplib library to connect to an FTP server and download both binary and text files to our local machine. In this segment, I’ll introduce several new concepts, including uploading text and binary files, error handling, and common directory commands using the same imported library.
.

Prerequisites

It is difficult to experiment with many of these calls with a server that you don’t own–most FTP servers will not allow anonymous logins. Assuming you do not have access to a web-based FTP server, your best bet is to install a server on your local machine (see “Installing an FTP server“) and test your code using localhost as the target server.
.

FTP Uploads

As with downloads, you’ll need to specify whether a file you wish to upload to a server is a text file or a binary file since each uses a different method. You can upload text files using the storlines() method and binary files with the storbinary() method. A nice feature of these functions is that neither one requires you to write a separate function to handle reading the source file: storlines() calls the readline() method on each line in the file until it reads the last line, while storbinary() uses the read() method until there is no more data to read and upload.

Read More


How to Install Your Own FTP Server

Introduction

If you’re interested in learning about networking, or if you have files that you would like to share with the world at large, then at some point you’re probably going to want to get an FTP server running on a machine. There is a vast array of options for a server, depending on what operating system your server is running and how much work you want to put in to setting it up. Read on for instructions on how to get free FTP servers up and running quickly using Linux, Mac, or Windows. All of the software mentioned here is free; paid FTP server programs do exist, but almost anything you need to do with an FTP server can be done with an open-source program.

Read More


How to FTP with Python: The Basics

Introduction

If you’re running a server of any kind or dealing with cloud server storage, at some point you’ll probably find it necessary to use FTP. FTP stands for File Transfer Protocol and is the de facto standard for transferring files from one place to another. Python has a fully mature FTP library that any script can utilize with a simple import statement. That library, called ftplib, is both easy to use and very useful.
.

Prerequisites

  • Basic familiarity with Python interactive session and scripts.

What is FTP?

FTP is a standard network protocol that allows for the transfer files from one computer to another over a network. It uses a client/server model, where the client computer makes requests of the server–requests to download or upload files, create and delete directories and files, and other common file operations. It commonly uses clear text authentication, with a simple user/password scheme, but often FTP servers are configured to allow anonymous access (to allow unlimited clients to download particular files without needing individual logins, for instance.)

Many of the most common uses of FTP are via a graphical interface, using software such as Filezilla, Cyberduck, or WinSCP. These programs make using FTP a simple matter of dragging and dropping files between servers and clients, and right-clicking for context menus. You can also use a web browser to connect to many FTP servers; the browser takes care of the actual mechanics of the FTP connection, but you lose many of the features that dedicated FTP clients have.

Read More


How to: Socket Programming in Python

Wolfram Donat November 24, 2015 by under Cloud Hosting 0 Comments

Introduction

Network and communication programming are particularly powerful uses of any programming language. It is much more common these days for computers to interface with one another (or with an entire network, such as the Internet) than it is for a machine to act alone, and knowing exactly how that communication takes place is an important skill for any programmer. If you happen to be a Python aficionado, you may be aware that Python has several complete libraries designed to make network programming simple.
.

Prerequisites

  • Any version of Python (See our Guide for installing Python 2.7 in Centos)
  • Basic understanding of Python

Read More


What is Python: An Intro to a Cross-Platform Programming Language

Wolfram Donat November 11, 2015 by under Cloud Hosting 0 Comments
Python Illustration by Walker Cahall

Python Illustration by Walker Cahall

Target audience

This article assumes the reader has at least a basic familiarity with programming languages.

Introduction

Any Introduction to Computer Science course would be incomplete without a mention of Python. It may seem relatively new to the programming languages scene, but it has been in use since the early 1990s. Scores of large corporations, including Google, Facebook, and even NASA and the Jet Propulsion Laboratory in Pasadena, are among the organizations who make use of Python.
.

Python’s Origin Story

Python was developed by Guido van Rossum in the late 1980s, incorporating what he saw as improvements to the ABC programming language. Because he is a huge fan of Monty Python, the British comedy troupe, he named the language “Python”, even going so far as to call the integrated development environment, or IDE, IDLE in honor of Eric Idle, one of the group’s members.

Van Rossum is still one of the language’s principal authors and contributors, and has received the title of BDFL (Benevolent Dictator For Life) from the Python community.

Read More


HTTP vs. HTTPS : What is the difference?

Target audience

This article is geared toward a general reader with a basic understanding of how the Internet works.

Introduction

When you surf the Internet, most web pages are delivered to your computer using a communications protocol called HTTP, which serves the vast majority of web pages on the World Wide Web. However, it can be a vulnerable communications scheme, which is where HTTPS comes into play.

Read More


What Is UART (Universal Asynchronous Receiver/Transmitter)

Wolfram Donat September 28, 2015 by under Cloud Hosting 0 Comments
Target Audience

This article assumes that the reader has a basic understanding of electronic devices, circuits, and terminology.

Introduction

In the world of embedded device communications, there is a small handful of protocols that are used for many different applications. It is often the case that more common protocols that are commonly used for everyday operations, such as FTP and TCP, either do not work with small embedded devices or are unsuitable (often due to power or space requirements). It is in cases like these that more basic, ‘down to the metal’ communications standards such as UART are very useful.

Read More


What Is I2C (Inter-Integrated-Circuit)?

Wolfram Donat September 16, 2015 by under Managed Server Hosting 0 Comments
Target Audience

This article assumes that the reader is familiar with basic electronics circuits and terminology.

Introduction

The purpose of this article is to familiarize the reader with the basics of the I2C communications bus, including how it is set up, its physical properties, and where and why it is often used.
.

I2C

I2C is ordinarily pronounced “I-two-C”, though it is also sometimes written as IIC (and pronounced “I-I-C”) or I2C (pronounced “I-squared-C”). The acronym stands for Inter-Integrated-Circuit. It is a type of serial computer bus and communications protocol that was first introduced to the market by Philips Semiconductor in 1982.

I2C is a way of allowing multiple electronic devices (most often low-speed, peripheral integrated circuits) to communicate with each other over a single pair of wires. These wires are also called data lines, or buses. The first of these buses is the data line and is called the SDA (Serial DAta) line, and the other bus is the clock, or SCL (Serial CLock) line. Since all devices on any I2C circuit are hooked to these two lines to communicate, most I2C-compatible devices have pins labeled SDA and SCL, as well as VIN and GND pins for positive and ground connections.
.

I2C diagram

Typical I2C Schematic / licensed under CC BY-SA 3.0

.
Both the clock and data buses are open-drain lines. A resistor must be connected between each line and the circuit’s positive voltage supply (also referred to as Vcc) in order for the bus to work correctly. The size of these resistors can vary, from 1 kΩ all the way up to 47 kΩ, but they must be present between the bus and the system’s HIGH voltage. If they are not present, all lines will be pulled low, and the I2C bus will fail to work. Luckily, only one pair of resistors (one for each line) is necessary for the entire system, not a pair for each device–that could quickly get messy with a lot of devices.

Quite a few devices (also called nodes) can be attached to these buses. In fact, the number of devices that can practically be connected to any I2C circuit is normally limited only by space, the inherent capacitance of the lines, and the addresses of the connected devices. Most experts agree that this limit falls around 1008 devices.

There are two kinds of devices in I2C communications: masters and slaves. In most implementations of the protocol there is one master device connected to many slaves. It is possible to have more than one master communicating with various slave devices as well as other masters, but this form is less common and is a bit beyond the scope of this introduction. Many I2C devices can be configured as either a master or a slave, depending on the desired system results. The master node is the one device that controls the clock (SCL) line, and is the only device that can initiate a data transfer. The slave nodes are limited to listening for and responding to calls from the master node. Each node, including the master, has a unique (normally 7-bit) address that identifies it on the I2C network. In some cases the address can be 10 bits in length, allowing for more than 128 different devices, but this is not a normal setup.

During the operation of an I2C system, the master node sends commands and requests on the data line. These signals are 8 bits in length, are only begun when the clock line is HIGH, and are started with a particular ‘start’ sequence and finished with a particular ‘stop’ sequence. The start sequence alerts all connected slave nodes that a data transfer request is imminent. The next sequence the master sends out is the address of the slave with which it wants to communicate. The named slave node then responds to the master, beginning at the next HIGH clock signal, and the other slaves go back to listening for their address to be called.

The eighth bit that is sent with the command, after the 7-bit device address, is a simple read/write bit. It tells the addressed device whether the master device will be reading from or writing to it. This allows the receiving device to either prepare data to send or prepare to receive data along the SDA line at the next clock HIGH signal.

The clock speed (and the associated signal transfers) on most I2C circuits normally falls somewhere between serial communications and SPI speeds, between 100kHz and 400kHz. I2C is commonly used in systems where simplicity, low cost, and low power are more important than speed. Some of these applications include analog-to-digital converters, LCD displays, real-time clocks, and many different sensors such as barometers, compasses, and even GPS receivers.

I2C is a very useful communications protocol, though it may only be applicable to a small number of applications. It is ideal for small, low-power-consumption settings, and as a result has found a following among many hobbyists, who use it to interface sensors and controls with embedded devices and microcontrollers such as the Arduino and the Raspberry Pi. Two of the Pi’s GPIO pins are preset to interface with devices using the protocol, and the Arduino wire library allows communications with I2C devices. Learning and using I2C can significantly extend a hobbyist’s toolkit when it comes to building projects.

Atlantic.Net

Atlantic.net offers managed hosting services which include a layer of business-essential managed services to your hosting packages. Contact us today for more information.


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources

We use cookies for advertising, social media and analytics purposes. Read about how we use cookies in our updated Privacy Policy. If you continue to use this site, you consent to our use of cookies and our Privacy Policy.