当我在我的osx上安装ipython并运行它时,我收到以下警告:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/IPython/utils/rlineimpl.py:96:
RuntimeWarning: Leopard libedit detected - readline will not be wel
behaved including some crashes on tab completion, and incorrect
history navigation. It is highly recommended that you install
readline, which is easy_installable with: 'easy_install readline'
Run Code Online (Sandbox Code Playgroud)
我已经安装了readline,并且不使用最初安装的系统python /Library/Frameworks/Python.framework/Versions/2.7/bin/python$./usr/bin/python版本2.7 的要点如下所示
uname -a
Darwin macbook.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$sudo pip install readline ipython
$ipython --version
0.11
$/usr/bin/python --version #
Python 2.7.1
$which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Run Code Online (Sandbox Code Playgroud)
我有mysql Server版本:5.5.32-0ubuntu0.12.04.1(Ubuntu)安装了linux Ubuntu 12.04 LTS.
我似乎拥有root权限.我可以创建一个用户和一个数据库.但是,我似乎无法向用户授予对db的所有权限.
我的.my.cnf:
[client]
user=root
password=test
Run Code Online (Sandbox Code Playgroud)
我登录mysql -u root -h localhost -p,但我没有-p选项登录虽然我有.my.cnf(不是问题,但奇怪).
有一堆root用户,所以我摆脱了他们,我有这些用户:
mysql> SELECT host,user,password FROM mysql.user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | ***************************************** |
| localhost | debian-sys-maint | ***************************************** |
+-----------+------------------+-------------------------------------------+
mysql> SHOW GRANTS FOR 'root'@'localhost';
+----------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*****************************************' |
| GRANT PROXY ON ''@'' …Run Code Online (Sandbox Code Playgroud) 当我./manage.py process_email在我的应用程序中,我得到ImportError: No module named commands.process_email.
我的目录布局是:
./
??? __init__.py
??? admin.py
??? forms.py
??? management
? ??? __init__.py
? ??? commands
? ??? __init.py__
? ??? process_email.py
??? models.py
??? views.py
Run Code Online (Sandbox Code Playgroud)
process_email命令的来源是:
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from website.event.models import Event
class Command(BaseCommand):
def handle(self, *args, **options):
process_email()
def process_email():
print "processing email"
Run Code Online (Sandbox Code Playgroud)
和我得到的错误:
(website.com)kings@bob-kings-MacBook ~/code/website.com/website $ > ./manage.py process_email
Traceback (most recent call last):
File "./manage.py", line 14, in <module> …Run Code Online (Sandbox Code Playgroud) 我在新系统上安装了64位Ubuntu 12.04,无法安装functools.我已多次安装,但不记得收到此错误,并且无法通过Google找到任何解决方案.我需要做什么?
(myvenv)bobs@myvenv:~$ pip install functools
Downloading/unpacking functools
Downloading functools-0.5.tar.gz
Running setup.py egg_info for package functools
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
from setuptools.compat import numeric_types, basestring
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "/usr/lib/python2.7/socket.py", line 49, in …Run Code Online (Sandbox Code Playgroud) 我的django应用程序使用未管理的表,并在我的模型中定义如下:
class Meta:
managed = False
db_table = 'mytable'
Run Code Online (Sandbox Code Playgroud)
当我运行一个导入该人的简单测试时,我得到以下内容:
(person)bob@sh ~/person/dapi $ > python manage.py test
Creating test database for alias 'default'...
DatabaseError: (1060, "Duplicate column name 'db_Om_no'")
Run Code Online (Sandbox Code Playgroud)
tests.py非常简单:
import person.management.commands.dorecall
from person.models import Person
from django.test import TestCase
import pdb
class EmailSendTests(TestCase):
def test_send_email(self):
person = Person.objects.all()[0]
Command.send_email()
Run Code Online (Sandbox Code Playgroud)
我确实读过django docs,其中说"对于涉及使用managed = False的模型的测试,由你来确保在测试设置中创建正确的表格." 所以我明白我的问题是我没有创建合适的表.所以我应该test_person在测试框架创建的db中创建表的副本吗?
每次我运行测试时,test_persondb都会被破坏(我认为)并重新设置,所以我应该如何创建表的副本test_person.我在考虑这个吗?
更新:
我看到的SO这个问题,并增加了ManagedModelTestRunner()在utils.py.虽然ManagedModelTestRunner()确实运行(通过插入确认pbd.set_trace()),但我仍然得到Duplicate column name错误.我没有得到错误 …
我能够使用python websocket连接到 node.js websocket服务器。当我询问python websocket客户端是否连接到服务器时,它不准确。
这是发生的事情:
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
>>> import websocket
>>> ws = websocket.WebSocket()
>>> ws.connect("ws://localhost:8081") # my websocket server is running, so all good here.
>>> ws.connected
True # This is correct. Now I kill the websocker server
>>> ws.connected
True # this should be false since the server is dead.
Run Code Online (Sandbox Code Playgroud)
该WS Node.js的模块自带wscat,您可以通过运行该命令的WebSocket服务器wscat -l 8081。
如何获得指示真正连接/断开连接状态的准确状态?
我正在关注一个教程,我正在尝试运行此代码.每次刷新时,都会出现以下代码
console.log(childView.el);
Run Code Online (Sandbox Code Playgroud)
输出在此之间切换
<div id="master" class="container"></div>
Run Code Online (Sandbox Code Playgroud)
还有这个:
div#master.container
Run Code Online (Sandbox Code Playgroud)
我想明白为什么这会切换.这是我看到的gif(看看控制台).
我正在学习有关在Python记录,所以我试图找出其中的源代码,当你这个具体的输出格式的行部分:"GET /dashboard/ HTTP/1.1" 200 249176?另外,249176是什么意思?
我没有问题,这个问题是为了满足我的好奇心.
我真的在寻找这个logrecord的格式化程序.我也没有看到它来自哪个loghandler(也许这根本不是来自日志记录模块,它只是一个打印命令).我搜索了源代码,无法找到它的来源,并希望有一个链接到源代码.
以下是我运行代码时会发生的情况.
September 05, 2013 - 05:38:50
Django version 1.5.1, using settings 'dapi.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Sep/2013 05:38:57] "GET /dashboard/ HTTP/1.1" 200 249176
[05/Sep/2013 05:38:58] "GET /static/plugins/uniform/css/uniform.default.css HTTP/1.1" 304 0
[05/Sep/2013 05:38:58] "GET /static/plugins/bootstrap-daterangepicker/daterangepicker.css HTTP/1.1" 304 0
Run Code Online (Sandbox Code Playgroud) 我有一个由nginx和django提供服务的网站.
我的staging.py正确包含CACHE和中间件设置.您可以查看nginx.conf和与该站点相关的nginx conf文件.我已经确认memcached正在运行ngrep -d any port 11211.
我开启了整个网站的缓存,并希望通过这样做来看到性能 ab -n 1000 -c 10 http://site.com
关闭缓存后,我得到:
Concurrency Level: 10
Time taken for tests: 10.276 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 11695000 bytes
HTML transferred: 11559000 bytes
Requests per second: 97.32 [#/sec] (mean)
Time per request: 102.759 [ms] (mean)
Time per request: 10.276 [ms] (mean, across all concurrent requests)
Transfer rate: 1111.43 [Kbytes/sec] …Run Code Online (Sandbox Code Playgroud) 我有一个模特人,有时在该birth_date领域没有任何东西.这是一个例子:
(Pdb) dude = Person.objects.get(pk=20)
(Pdb) dude
<Person: Bob Mandene>
(Pdb) dude.birth_date
(Pdb) dude.birth_date == None
True
Run Code Online (Sandbox Code Playgroud)
如何过滤这些记录birth_date == None?
我已经尝试了以下但没有成功:
1:"birth_date__isnull"不起作用.
Person.objects.filter(birth_date__isnull = True)
# does not return the required
# object. Returns a record that have birth_date set to
# NULL when the table was observed in MySQL.
Run Code Online (Sandbox Code Playgroud)
以下内容不会返回ID为20的记录.
Person.objects.filter(birth_date = "")
Run Code Online (Sandbox Code Playgroud)
如何过滤无字段?它似乎是NULL而None是不同的.当我使用sequel pro(mysql图形客户端)看到数据时,我看到"0000-00-00 00:00:00",以下内容也无效
(Pdb) ab=Patient.objects.filter(birth_date = "0000-00-00 00:00:00")
ValidationError: [u"'0000-00-00 00:00:00' value has the correct format
(YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) but it is an …Run Code Online (Sandbox Code Playgroud) django ×5
python ×5
backbone.js ×1
javascript ×1
jquery ×1
logging ×1
memcached ×1
mysql ×1
node.js ×1
pip ×1
python-2.7 ×1
websocket ×1