https://pythonhosted.org/xmodem/xmodem.html
DevOps
1 |
python manage.py createsuperuser |
python manage.py shell
|
1 2 3 4 5 6 |
from django.contrib.auth.models import User user=User() user.username="admin" user.is_superuser=True user.set_password('admin') user.save() |
Python web开发框架:
Django 、Flask、Tornado、Bottle、Twisted
Tornado: http://www.tornadoweb.org/en/stable/
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
Twisted: https://pypi.python.org/pypi/Twisted/ http://twistedmatrix.com/trac/
An asynchronous networking framework written in Python
twisted/tornado 更是一个server,框架部分只是方便使用该server而附带的,不是重点;你可以选择使用tornado server + Django框架, 而对于Bottle框架而言,是允许指定使用哪种server的,支持的server有:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
server_names = { 'cgi': CGIServer, 'flup': FlupFCGIServer, 'wsgiref': WSGIRefServer, 'waitress': WaitressServer, 'cherrypy': CherryPyServer, 'paste': PasteServer, 'fapws3': FapwsServer, 'tornado': TornadoServer, 'gae': AppEngineServer, 'twisted': TwistedServer, 'diesel': DieselServer, 'meinheld': MeinheldServer, 'gunicorn': GunicornServer, 'eventlet': EventletServer, 'gevent': GeventServer, 'geventSocketIO':GeventSocketIOServer, 'rocket': RocketServer, 'bjoern' : BjoernServer, 'auto': AutoServer, } |
Bottle默认使用的server为: 如下:
1 2 3 |
def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, **kargs): |
所以,有些技术不是同一个层面的,不能相提并论,非此即彼;
Django or Flask:
https://www.zhihu.com/question/33538127
http://bottlepy.org/docs/dev/index.html
webssh的关键点:
php 中关于 fopen函数的说明中,mode参数没有正式提到二进制模式(b),但是在参数说明的列表下面有关于二进制打开方式的说明,并且提到可以使用”b” 来指定二进制模式,这里的二进制模式和文本模式的差别仅仅在于 \r\n 与 \n 之间的差别,和文件编码没有关系。
python中关于“文本模式”和“二进制模式”的差别则在于文件的编码
问题:
配置类中明确定义了DataSource bean,但是在另一个类中Autowired的一个jdbcTemplate怎么都装配失败,调试发现,DataSource Bean定义的太晚了,如果提前到jdbcTemplate定义的那个类中就没问题了
另外的解决办法: 其实我们完全可以在配置类上 :
1 |
@EnableAutoConfiguration |
这样的话,只需要在 application.properties 中定义如下即可:
1 2 3 |
spring.datasource.url=jdbc:mysql://172.16.22.37:3306/test spring.datasource.data-username=phpor spring.datasource.data-password=phpor-password |
问题:
当我们在logstash-output-syslog中配置facility为local6的时候,实际上走的是local4;而定义facility为local7的时候,实际上走的是local5,但是,定义为daemon的时候,确实是daemon
原因:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
FACILITY_LABELS = [ "kernel", "user-level", "mail", "daemon", "security/authorization", "syslogd", "line printer", "network news", "uucp", "clock", "ftp", "ntp", "log audit", "log alert", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", ] |
1 2 3 4 5 6 7 8 9 10 11 12 |
Numerical Facility Code 0 kernel messages 1 user-level messages 2 mail system 3 system daemons <strong> 4 security/authorization messages (note 1)</strong> <span class="grey">Lonvick Informational [Page 8]</span> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<a id="page-9" class="invisible" href="https://tools.ietf.org/html/rfc3164#page-9" name="page-9"> </a> <span class="grey"><a href="https://tools.ietf.org/html/rfc3164">RFC 3164</a> The BSD syslog Protocol August 2001</span> 5 messages generated internally by syslogd 6 line printer subsystem 7 network news subsystem 8 UUCP subsystem <strong> 9 clock daemon (note 2)</strong> <strong> 10 </strong> <strong>security/authorization messages (note 1)</strong> 11 FTP daemon 12 NTP subsystem 13 log audit (note 1) 14 log alert (note 1) <strong> 15 clock daemon (note 2)</strong> 16 local use 0 (local0) 17 local use 1 (local1) 18 local use 2 (local2) 19 local use 3 (local3) 20 local use 4 (local4) 21 local use 5 (local5) 22 local use 6 (local6) 23 local use 7 (local7) |
1 2 3 |
ip link set eth0 up ip addr add 172.16.0.3/24 dev eth0 ip route add default via 172.16.0.1 |
注意: 这里使用的是ip命令,而不是ifconfig、ifup之类的,因为ip命令不参考本地文件系统中的相关配置,而后者会参考本地文件系统相关网络配置;因为我们需要ip命令,所以使用的是宿主机的文件系统,而不是容器的文件系统,所以在这里设置容器网卡的时候,不能使用ifconfig、ifup之类
第一步:安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# pip install paramiko Collecting paramiko Downloading paramiko-2.2.1-py2.py3-none-any.whl (176kB) 100% |████████████████████████████████| 184kB 10kB/s Collecting cryptography>=1.1 (from paramiko) Downloading cryptography-2.0.3-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB) 100% |████████████████████████████████| 2.2MB 5.1kB/s Collecting bcrypt>=3.1.3 (from paramiko) Downloading bcrypt-3.1.3-cp27-cp27mu-manylinux1_x86_64.whl (57kB) 100% |████████████████████████████████| 61kB 3.1kB/s Collecting pyasn1>=0.1.7 (from paramiko) ^@ Downloading pyasn1-0.3.2-py2.py3-none-any.whl (63kB) 100% |████████████████████████████████| 71kB 1.3kB/s Collecting pynacl>=1.0.1 (from paramiko) Downloading PyNaCl-1.1.2-cp27-cp27mu-manylinux1_x86_64.whl (539kB) 100% |████████████████████████████████| 542kB 4.4kB/s Collecting idna>=2.1 (from cryptography>=1.1->paramiko) Downloading idna-2.6-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 4.5kB/s Collecting six>=1.4.1 (from cryptography>=1.1->paramiko) Downloading six-1.10.0-py2.py3-none-any.whl Collecting ipaddress (from cryptography>=1.1->paramiko) Downloading ipaddress-1.0.18-py2-none-any.whl Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->paramiko) Downloading asn1crypto-0.22.0-py2.py3-none-any.whl (97kB) 100% |████████████████████████████████| 102kB 4.2kB/s Collecting enum34 (from cryptography>=1.1->paramiko) Downloading enum34-1.1.6-py2-none-any.whl Collecting cffi>=1.7 (from cryptography>=1.1->paramiko) Downloading cffi-1.10.0-cp27-cp27mu-manylinux1_x86_64.whl (392kB) 100% |████████████████████████████████| 399kB 4.2kB/s Collecting pycparser (from cffi>=1.7->cryptography>=1.1->paramiko) Downloading pycparser-2.18.tar.gz (245kB) 100% |████████████████████████████████| 256kB 6.0kB/s Installing collected packages: idna, six, ipaddress, asn1crypto, enum34, pycparser, cffi, cryptography, bcrypt, pyasn1, pynacl, paramiko Running setup.py install for pycparser ... done Successfully installed asn1crypto-0.22.0 bcrypt-3.1.3 cffi-1.10.0 cryptography-2.0.3 enum34-1.1.6 idna-2.6 ipaddress-1.0.18 paramiko-2.2.1 pyasn1-0.3.2 pycparser-2.18 pynacl-1.1.2 six-1.10.0 You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. |
我们见过比较专业一些的软件会包含多个rpm包,如:
phpor.1.0.0.el7.x86_64
phpor-docs.1.0.0.el7.x86_64
phpor-devel.1.0.0.el7.x86_64
phpor-debuginfo.1.0.0.el7.x86_64
那么,一个spec文件如何build出来多个rpm包呢?
首先,我们以devel为例,参考: https://stackoverflow.com/questions/2913130/building-both-devel-and-normal-version-of-a-rpm-package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Name: kmymoney Summary: The Personal Finances Manager for KDE. Version: 0.8 Release: 1.%{disttag}%{distver} License: GPL Packager: %packer Group: Productivity/Office/Finance Source0: %{name}2-%version.tar.bz2 BuildRoot: %{_tmppath}/%{name}2-%{version}-%{release}-build BuildRequires: kdebase3-devel Prereq: /sbin/ldconfig %description Description goes here... %package devel #Requires: Summary: KMyMoney development files Group: Productivity/Office/Finance Provides: kmymoney-devel %description devel This package contains necessary header files for KMyMoney development. ... more to go here ... %files ... some files ... %files devel ... the devel files ... |
可见,devel是以子包的形式出现的
示例:
http://kmymoney2.sourceforge.net/phb/rpm-example.html
rpmbuild 安装到BUILDROOT 下面的文件和目录都要打包的rpm包中,否则会报错(rpmbuild会认为你遗忘了),如果不想打包,就提前删掉