Ftp server with python

python-ftp-server 1.3.18

Command line FTP server tool designed for performance and ease of use.

Ссылки проекта

Статистика

Метаданные

Лицензия: MIT

Сопровождающий:

Требует: Python >=3.6

Сопровождающие

Классификаторы

Описание проекта

FTP server to transfer files between machines with zero configuration

Usage

  1. python3 -m pip install python-ftp-server
  2. python3 -m python_ftp_server -d «dirctory/to/share» will print:

Local address: ftp://:60000 User: Password:

Подробности проекта

Ссылки проекта

Статистика

Метаданные

Лицензия: MIT

Сопровождающий:

Требует: Python >=3.6

Сопровождающие

Классификаторы

История выпусков Уведомления о выпусках | Лента RSS

Загрузка файлов

Загрузите файл для вашей платформы. Если вы не уверены, какой выбрать, узнайте больше об установке пакетов.

Source Distribution

Uploaded 7 апр. 2023 г. source

Built Distribution

Uploaded 7 апр. 2023 г. py3

Хеши для python_ftp_server-1.3.18.tar.gz

Хеши для python_ftp_server-1.3.18.tar.gz
Алгоритм Хеш-дайджест
SHA256 1950e8062e11ce5fb530213c5a4a1e269b23ef2e977fa20a843d3990ecac07c7 Копировать
MD5 de7587514cd8af13ca5ffb2f3fa05246 Копировать
BLAKE2b-256 dc3adbcb2d6107e4ae6acfdb16acfe2bd652b277d369fb0188fceb3cfa6dd822 Копировать

Хеши для python_ftp_server-1.3.18-py3-none-any.whl

Хеши для python_ftp_server-1.3.18-py3-none-any.whl
Алгоритм Хеш-дайджест
SHA256 7d7009380738e81c0bbdd0cc31225d99415bc9a9f7d2061e95d3e1b077a3d05a Копировать
MD5 b678eabe2a655c6e6843d363dccdf861 Копировать
BLAKE2b-256 a46a67eb3f29238bdaa099f9aabf1c038cd73db41df291b2674c21bded8002b8 Копировать

Помощь

О PyPI

Внесение вклада в PyPI

Использование PyPI

Разработано и поддерживается сообществом Python’а для сообщества Python’а.
Пожертвуйте сегодня!

PyPI», «Python Package Index» и логотипы блоков являются зарегистрированными товарными знаками Python Software Foundation.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Simple ftps server in python using pyftpdlib

santoshghimire/python-ftp-server

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Simple ftps server in python using pyftpdlib

Before installing anything, follow these steps:

  1. Rename config_sample.yaml file inside the source directory to config.yaml
  2. Change a few things in the config.yaml file.
  3. Replace the value of masquerade_address with the public ip address of the server.
  4. Replace the value of certfile with the absolute path of the certificate file keycert.pem
  5. Add users with username, password and their home directory, and permissions. 1. Read permissions:
    • «e» = change directory (CWD command)
    • «l» = list files (LIST, NLST, MLSD commands)
    • «r» = retrieve file from the server (RETR command)
2. Write permissions: - "a" = append data to an existing file (APPE command) - "d" = delete file or directory (DELE, RMD commands) - "f" = rename file or directory (RNFR, RNTO commands) - "m" = create directory (MKD command) - "w" = store a file to the server (STOR, STOU commands) 
  1. sudo apt-get update
  2. sudo apt-get install python-pip
  3. sudo apt-get install build-essential libssl-dev libffi-dev python-dev
  4. sudo pip install pyftpdlib
  5. sudo pip install cryptography
  6. sudo pip install pyopenssl
  7. sudo pip install pyyaml
  8. (If the ftps server is an EC2 instance, before running the script, we need to open some ports for ftp)
  9. In Amazon EC2 console, on the left, click on Security group.
  10. Select security group of the ec2 instance.
  11. Click on inbound tab and click edit.
  12. Add two tcp rules shown in the screenshot tcp.png
  1. Paste the upstart config file pyftplib.conf to /etc/init/ (it requires admin privilage to paste so use sudo).
  2. Make the script ftps.py and ftps.sh exucetable by the following command.
  3. chmod u+x ftps.py
  4. chmod u+x ftps.sh

sudo service pyftpdlib start

That’s it !! The ftps server is now ready !

About

Simple ftps server in python using pyftpdlib

Источник

Work with FTP Server using Python: Complete Guide

In this tutorial we will explore how to work with FTP server using Python.

Table of Contents

Introduction

FTP (File Transfer Protocol) is a set of rules describing how the files are transferred within a computer network.

Many companies using FTP to securely send large files across the organization.

For programmers it is often a requirement to send output files such as model predictions or test results using FTP so the files can be retrieved by the stakeholders across different business units.

In this tutorial we will use a public FTP test server DLP Test that offers free FTP server for testing purposes and automatically deletes the files after a few minutes.

Connect to FTP server using Python

The first step to start working with FTP server using Python is to connect to the FTP server.

Let’s import the required dependency:

In order to connect to the FTP server, you will need to know some credentials:

Let’s define the credentials as Python variables:

And finally establish a connection to the FTP server using Python:

Now the connection is established and we can verify it by requesting a welcome message from the FTP server:

'220 Welcome to the DLP Test FTP Server'

Note : not all FTP servers have welcome messages, in case of the DLP Test FTP server, a welcome message should be displayed.

List files in the FTP server using Python

One of the simplest operations with FTP server is to retrieve a list of files in the directory.

Currently we are in the root directory and it can be verified by running:

Now we can get a list of files in the current directory. There are two ways of doing it:

    Produce a directory listing which prints it to standard output

Produce a directory listing

which should print a standard output with something like:

-rw-r--r-- 1 1001 1001 958 Aug 15 17:30 file1.txt -rw-r--r-- 1 1001 1001 958 Aug 15 17:30 file2.txt -rw-r--r-- 1 1001 1001 0 Aug 15 17:31 file3.txt

Return a list of file names in a directory

which should return a Python list like:

['file1.txt', 'file2.txt', 'file3.txt']

Note : the filenames returned by both commands will be identical.

Create a new directory in the FTP server using Python

Before we start testing uploading files to FTP, let’s create our own folder for these test cases.

Since this FTP server is used by many developers to test their FTP code, we will create a subdirectory so it’s easier to follow the tutorial.

Our folder will be called ‘pyshark’.

and the folder will be created.

You can verify it either by connecting to FTP server using FileZilla or my printing a list of file names in the directory, and one of them will be ‘pyshark’, which is the folder that we have just created.

Next, lets set this new directory as the current directory on the server by running:

and to validate the change, print the name of the current directory:

Sample file

In order to continue in this tutorial we will need some sample file to work with.

We will create a sample TXT file with test: “This is a sample file.”

Upload files to FTP server

In this section we will explore how to upload a file to the FTP server.

So far we have create a new folder in FTP called “pyshark” and set it as the current working directory.

In order to upload the file to FTP server, we will use the .storbinary() method of the FTP class. This method initiates a file transfer from FTP client to FTP server using the FTP command STOR.

First we will open the sample file “file1.txt” as a binary file with read mode and then perform the FTP file transfer (we will name the transferred file on the server as “uploaded_file”):

To check if it was uploaded simply produce a list of files in the directory:

Download files from FTP server

In this section we will explore how to download a file from the FTP server.

We continue to work with “pyshark” folder as the current working directory.

In order to download a file from FTP server, we will use the .retrbinary() method of the FTP class. This method retrieves a file from the FTP server to the local system in binary mode using the FTP command RETR.

We are going to download the file that we uploaded to the FTP server in the previous section.

First we will create a file object “downloaded_file.txt” in as a binary file with write mode and then download the “uploaded_file.txt” from the FTP server:

The “downloaded_file.txt” should appear in the same directory as the file with the code:

Rename files in FTP server

In this section we will explore how to rename a file in the FTP server.

We continue to work with “pyshark” folder as the current working directory.

In order to delete a file from FTP server, we will use the .delete() method of the FTP class. This method takes two parameter which are the original file name and the new file name.

Let’s delete the “uploaded_file.txt” to “renamed_file.txt” in the FTP server:

To check if it was uploaded simply produce a list of files in the directory:

Delete files from FTP server

In this section we will explore how to delete a file from the FTP server.

We continue to work with “pyshark” folder as the current working directory.

In order to delete a file from FTP server, we will use the .delete() method of the FTP class. This method takes one parameter which is the file name and then deletes it from the directory.

Let’s delete the “uploaded_file.txt” from the FTP server:

To check if it was uploaded simply produce a list of files in the directory:

Источник

Читайте также:  Удаление дубликатов python list
Оцените статью