pylint用于Python代码规范检查。默认代码风格遵循PEP08

使用配置文件

配置文件可以通过如下命令生成

1
pylint --generate-rcfile > .pylintrc

执行pylint时,可以通过指定–rcfile参数来加载配置文件。而默认配置文件加载顺序可以参考命令行参数这节。

Django代码检查

对于Django, 有pylint-django这个pylint插件用来代码检查。pip install pylint-djangop安装后,添加–load-plugins参数即可启用,如pylint --load-plugins pylint_django

警告忽略

有时pylint的检查不满足需求,太繁琐,此时可以忽略它。如在for d in data:里,会报Invalid variable错误,即C0103, 此时加上# pylint: disable=C0103可以忽略这个警告。

联系作者

在编写测试时遇到表单上传文件的问题,问了同事后,给了stackoverflow上how to unit test file upload in django链接, 在django.test.Client.post里看到如下例子

1
2
3
>>> c = Client()
>>> with open('wishlist.doc') as fp:
... c.post('/customers/wishes/', {'name': 'fred', 'attachment': fp})

对于图片,需要加上rb模式,例子如下

1
2
3
>>> c = Client()
>>> with open('wishlist.png', 'rb') as fp:
... c.post('/customers/wishes/', {'name': 'fred', 'attachment': fp})

解决问题。

联系作者

CentOS上安装mysql, 使用yum安装很方便。

按照A Quick Guide to Using the MySQL Yum Repository里的步骤即可。

配置镜像仓库

Download MySQL Yum Repository下载仓库, 服务器是CentOS6, 于是下载mysql57-community-release-el6-9.noarch.rpm,之后执行rpm -i mysql57-community-release-el6-9.noarch.rpm

下载镜像

yum install mysql-community-server下载mysql

启动MySQL

service mysqld start

修改root用户密码

  • 使用grep ‘temporary password’ /var/log/mysqld.log找到root用户密码,
  • mysql -uroot -p登录,输入grep得到的密码
  • 执行ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';修改root用户密码

联系作者

git克隆仓库时,报如下错误

1
2
3
4
Initialized empty Git repository in 
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/maqmall/eyaos_signature.git/info/refs

fatal: HTTP request failed

参考HTTPS cloning errors,发现是git版本过低,用的CentOS6默认是1.7.1, 于是升级git版本。如何升级git, 可参考之前写的CentOS6.5升级git

联系作者