Development of Python 1---multiple concurrent FTP

Source: Internet
Author: User

First, prepare beforehand

  1. Create 1 new project, my name is: Day9-1.

2. Under the Day9-1 directory, New 2 python package:crazyftp and crazyftpclient, respectively, are used to store the client, server-side directories and files.

3. Then create new files and directories on the server side, under the client package directory, as follows:

    • Crazyftp
      • Bin (User holds executable program directory)
        • crazy_ftp_server.py
      • conf (for storing configuration files)
        • settings.py
      • Modules (for storing the master file directory)
        • main.py
        • socket_server.py
      • Var
        • Log (Package directory)
        • Users (Package directory)
    • Crazyftpclient
      • Bin
        • ftp_client.py (in the core directory)
      • Core
        • socket_client.py
      • Var

    

Second, skills

  1. Import all modules in the root file (that is, modules outside the current module directory) method

   ----Add the server-side "root" directory to the environment variable, which refers to the Crazyftp directory.

1. First import the SYS and OS modules.

2. Then use the Os.path.dirpath method and the Os.path.abspath method to get the "root" of the __file__ (the relative path of the current file). "It's a good idea to take the absolute path first and then to slice it up ..."

3. Add "root" to the environment variable. That is, the sys.path.append (root path).

Import Sysimport Osbase_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath)) #将此路径加入到环境变量里面, That is sys.path.append (directory) sys.path.append (BASE_DIR) from modules import main

  

 

Cond.......

  

  

Development of Python 1---multiple concurrent FTP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.