fdfs_client-py&FastDFS客户端---Python

使用python编写FastDFS客户端进行上传测试

https://github.com/JaceHo/fdfs_client-py

进入fdfs_client-py-master.zip所在目录

依赖包
 mutagenl
 requests

以下是在windows系统下需要修改否则无法安装


修改 fdfs_client-py-master.zip 中setup.py文 33 、34代码注释

#!/usr/bin/env python
import os
from fdfs_client import __version__

try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup, Extension

f = open(os.path.join(os.path.dirname(__file__), 'README.md'))
long_description = f.read()
f.close()

sdict = {
    'name': 'fdfs_client-py',
    'version': __version__,
    'description': 'Python client for Fastdfs ver 4.06',
    'long_description': long_description,
    'author': 'scott yuan',
    'author_email': '[email protected]',
    'maintainer': 'scott yuan',
    'maintainer_email': '[email protected]',
    'keywords': ['Fastdfs', 'Distribute File System'],
    'license': 'GPLV3',
    'packages': ['fdfs_client'],
    'classifiers': [
        'Development Status :: 1 - Production/Beta',
        'Environment :: Console',
        'Intended Audience :: Developers',
        'License :: GPLV3',
        'Operating System :: OS Independent',
        'Programming Language :: Python'],
    # 'ext_modules': [Extension('fdfs_client.sendfile',       # windows 下需要注释
    #                           sources=['fdfs_client/sendfilemodule.c'])],
}

setup(**sdict)


解压后的fdfs_client-py-master\fdfs_client 目录下的storage_client.py
屏蔽第12行  # from fdfs_client.sendfile import *
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# filename: storage_cliet.py

import os, stat
import struct
import socket
import datetime
import errno
from fdfs_client.fdfs_protol import *
from fdfs_client.connection import *
# from fdfs_client.sendfile import *   屏蔽我~
from fdfs_client.exceptions import (
    FDFSError,
    ConnectionError,
    ResponseError,
    InvaildResponse,
    DataError
)

解压后的fdfs_client-py-master\fdfs_client 目录下的storage_client.py

屏蔽第12行 # from fdfs_client.sendfile import *

\

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# filename: storage_cliet.py

import os, stat
import struct
import socket
import datetime
import errno
from fdfs_client.fdfs_protol import *
from fdfs_client.connection import *
# from fdfs_client.sendfile import *   屏蔽我~
from fdfs_client.exceptions import (
    FDFSError,
    ConnectionError,
    ResponseError,
    InvaildResponse,
    DataError
)

非windows跳过上面步骤
完成以上两步,接着安装

pip install mutagen  

pip install requests

不然会提示缺少此两个包。

pip install fdfs_client-py-master.zip 

FastDFS在192.168.3.7主机上

python程序所在的主机192.168.3.1

该机将FastDFS安装包中的client.conf复制到本地文件夹

修改client.conf配置

[外链图片转存失败(img-iL8TUK26-1564931637031)(C:\Users\Administrator\Pictures\tpicture\clipboard-1564931333972.png)]

# the base path to store log files
base_path=/Users/smart/Desktop     #  必须配置,在client.conf所在的机器创建文件存储日志文件

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=192.168.3.5:22122      #  设置tracker服务器所在的机器IP

python中配置测试

[外链图片转存失败(img-3UF3m7XC-1564931637031)(C:\Users\Administrator\Pictures\tpicture\clipboard-1564931333973.png)]

你可能感兴趣的:(分布式,FastDFS,Python)