摘要:一、os模块概述 Python os模块包含普遍的操作系统功能。如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的。(一语中的) 二、常用方法 1、os.name 输出字符串指示正在使用的平台。如果是window 则用'nt'表示,对于Linux/Unix用户,它是'posix'。 2、os.getcwd() 函数得到当前工作目录,即当前Python脚本工作的目录路径。 3、os.l
2017年01月07日
Python-模块-filecmp
摘要:filecmp模块用于比较文件及文件夹的内容,它是一个轻量级的工具,使用非常简单。python标准库还提供了difflib模块用于比较文件的内容。关于difflib模块,且听下回分解。 filecmp定义了两个函数,用于方便地比较文件与文件夹: filecmp.cmp(f1, f2[, shallow]): 比较两个文件的内容是否匹配。参数f1, f2指定要比较的文件
分类:Python
2017年01月07日
Python-模块-dnspython
摘要:安装: # www.dnspython.org/kits/1.12.0/dnspython-1.12.0.tar.gz # tar -zxvf dnspython-1.12.0.tar.gz # cd dnspython-1.12.0 # python setup.py install qyery 引擎定义: query(self,qname,rdtype=1,rdclass=1,tcp=False,source=None,raise_on_no_answer=True,
分类:Python
2017年01月07日
Python-模块-IPy
摘要:模块安装:进去linux主机 安装IPy模块cd /usr/local/src/pythongit clone https://github.com/haypo/python-ipy.gitcd python-ipypython setup.py installfrom IPy import IPip=IP('192.168.1.0/24')print ip.len() #查看指定IP地址的个数for x in ip: #返回所有的IP地址 print (x)eg;256192.168.1.0192.168.1.1192.168
分类:Python
2017年01月07日
Python-模块-psutil
摘要:进去linux主机 安装IPy模块cd /usr/local/src/pythongit clone https://github.com/haypo/python-ipy.gitcd python-ipypython setup.py install安装psutil模块,可以通过python获取系统的cpu,磁盘,内存,进程,网络等相关信息下载地址https://pypi.python.org/pypi/psutil/cd /usr/local/src/pythonwget https://pypi.python.org/packages/source/p/psutil/psutil-2.1.3.tar.
分类:Python
2017年01月07日
Python-外部模块的安装
摘要:方法一: 下载外部模块源文件,解压后放到指定的目录下: 将安装文件复制到:/usr/lib/python2.7/site-packages 这个目录下 或使用: python setup.py install 来安装到上面的目录下方法二: setuptools:直接根据模块名称来自动下载安装,不需要自己再去寻找模块的安装文件 yum insta
分类:Python
2017年01月07日
Python-模块安装
摘要:Python模块常用的几种安装方式Python模块安装方法一、方法1:单文件模块直接把文件拷贝到 $python_dir/Lib二、方法2:多文件模块,带setup.py下载模块包,进行解压,进入模块文件夹,执行:python setup.py install三、方法3:easy_install 方式方法一:yum installpython-setuptools 方法二:先下载ez_setup.py,运行python ez_setup 进行easy_install工具的安装,之后就可
分类:Python
2017年01月07日
Python入门教程
摘要:重要说明这不是给编程新手准备的教程,如果您入行编程不久,或者还没有使用过1到2门编程语言,请移步!这是有一定编程经验的人准备的.最好是熟知Java或C,懂得命令行,Shell等.总之,这是面向老鸟的,让老鸟快速上手Python教程.为什么总结这样的一个教程我虽不是老鸟,但已熟悉Java,C/C++, Shell和Perl,且对常见的数据结构和算法等都了解.最近因项目需要,要做一个小工具,评估后感觉用Pyt
分类:Python
2017年01月06日
FastDFS安装配置-client.conf
摘要:# is this config file disabled# false for enabled# true for disableddisabled=false# bind an address of this host# empty for bind all addresses of this hostbind_addr=# the tracker server portport=22122# connect timeout in seconds# default value is 30sconnect_timeout=30# network timeout in seconds# default value is 30snetwork_timeout=60# the base pat
分类:系统管理
2017年01月06日
FastDFS安装配置-storage.conf
摘要:# is this config file disabled# false for enabled# true for disableddisabled=false# the name of the group this storage server belongs to## comment or remove this item for fetching from tracker server,# in this case, use_storage_id must set to true in tracker.conf,# and storage_ids.conf must be configed correctly.group_name=group1# bind an address o
分类:系统管理
2017年01月06日
FastDFS安装配置-mod_fastdfs.conf
摘要:# connect timeout in seconds# default value is 30sconnect_timeout=2# network recv and send timeout in seconds# default value is 30snetwork_timeout=30# the base path to store log filesbase_path=/tmp# if load FastDFS parameters from tracker server# since V1.12# default value is falseload_fdfs_parameters_from_tracker=true# storage sync file max delay
分类:系统管理
2017年01月06日
FastDFS安装配置
摘要:http://github.com/happyfish100源码文件 所有的安装都是一个安装包,只是启动的服务不同而已 服务端安装配置:从github上下载lib库安装:https://github.com/happyfish100/libfastcommon.git安装依赖包:cd /usr/local/src/fastdfs# unzip libfastcommon-master.zip #./make.sh#./make.sh install 从gibhub上下载 安装包:(每台安装都一样)[root@node120
分类:系统管理
2016年12月30日
Docker数据管理
摘要:数据卷: 在Docker容器内将里面的数据直接写到硬盘上-v /data[root@node121 data]# docker run -it --namevolume-test1 -h centos -v /docker/data centos -i :让终端保持打开的状态 -t:启动一个tty -h:指定主机名 &nb
分类:自动化运维
2016年12月30日
Docker FAQ FATA[0000] Error starting daemon: Error initializing network controller: Error creating d
摘要:FATA[0000] Error starting daemon: Error initializingnetwork controller: Error creating default "bridge" network: packagenot installed 解决方法: docker -d –bip=172.17.42.1/16 指定一个docker网段就可以成功启动了 网上有好多类似的解决方法,不过好麻烦,这里主要说下最方便的解决方法 先su到root 找一下doc
分类:自动化运维
2016年12月30日
Docker FAQ FATA[0000] Error mounting devices cgroup: mountpoint for devices not found
摘要:FATA[0000] Error mounting devices cgroup: mountpoint fordevices not found这个错误为cgroup在宿主机上没有挂载。我们编辑挂载上去 vi /etc/fstab#在结尾添加none /sys/fs/cgroup cgroup &
分类:自动化运维
2016年12月30日
Docker --help
摘要:[root@node121 ~]# docker --helpUsage: docker [OPTIONS] COMMAND [arg...] A self-sufficient runtime for linux containers. Options: --api-cors-header= Set CORS headers in the remote API -b,--bridge= &nb
分类:自动化运维
2016年12月30日
在宿主机查看docket容器的IP
摘要: 在宿主机查看docket容器的IP:docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID[root@node121 ~]# docker inspect --format='{{.NetworkSettings.IPAddress}}' 462442d61745 172.17.0.2
分类:自动化运维
2016年12月30日
Docker Nginx安装配置
摘要:启动一个容器运行nginx:[root@node121 ~]# docker search nginxNAME DESCRIPTION
分类:自动化运维
2016年12月30日
Docker 查看容器的IP地址和网络相关的参数
摘要:查看容器的IP地址,可以在主机上运行 sudo Docker ps查看正在运行的容器的id等信息”sudo docker inspect 容器id“可以查看到容器的相关信息“docker inspect --format '{{.NetworkSettings.IPAddress }}' 容器id”可以查看容器的具体IP地址,如果输出是空的说明没有配置IP地址 ifconfig查看主机上的网络cat /etc/hosts查看主机内部IP映射表cat /etc/resolv.conf查看
分类:自动化运维
2016年12月30日
Docker网络访问
摘要:docker会在本地安装一个网桥:[root@node121 ~]# brctl showbridge name bridgeid STP enabled interfacesdocker0 8000.7ee2e924ad83 no &