我正在尝试调试内核模块.我怀疑有一些内存泄漏.为了检查它,我准备了内核和模块的内存泄漏调试的构建.我得到了一些警告:
[11839.429168] slab error in verify_redzone_free(): cache `size-64': memory outside object was overwritten
[11839.438659] [<c005575c>] (unwind_backtrace+0x0/0x164) from [<c0116ca0>] (kfree+0x278/0x4d8)
[11839.447357] [<c0116ca0>] (kfree+0x278/0x4d8) from [<bf083f48>] (some_function+0x18/0x1c [my_module])
[11839.457214] [<bf083f48>] (some_function+0x18/0x1c [my_module]) from [<bf08762c>] (some_function+0x174/0x718 [my_module])
[11839.470184] [<bf08762c>] (some_function+0x174/0x718 [my_module]) from [<bf0a56b8>] (some_function+0x12c/0x16c [my_module])
[11839.483917] [<bf0a56b8>] (some_function+0x12c/0x16c [my_module]) from [<bf085790>] (some_function+0x8/0x10 [my_module])
[11839.496368] [<bf085790>] (some_function+0x8/0x10 [my_module]) from [<bf07b74c>] (some_function+0x358/0x6d4 [my_module])
[11839.507476] [<bf07b74c>] (some_function+0x358/0x6d4 [my_module]) from [<c00a60f8>] (worker_thread+0x1e8/0x284)
[11839.517211] [<c00a60f8>] (worker_thread+0x1e8/0x284) from [<c00a9edc>] (kthread+0x78/0x80)
[11839.525543] [<c00a9edc>] (kthread+0x78/0x80) from [<c004f8fc>] (kernel_thread_exit+0x0/0x8)
Run Code Online (Sandbox Code Playgroud)
转换指向内核的地址没有问题:
$ addr2line …Run Code Online (Sandbox Code Playgroud) 使用:
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我可以得到:
File "x.py", line 20, in <module>
y(x)
File "x.py", line 11, in y
fun(x)
File "x.py", line 8, in fun
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我有办法得到这样的东西:
File "x.py", line 20, in <module>
y(x) WHERE x == 1
File "x.py", line 11, in y
fun(x) WHERE x == 'str'
File "x.py", line 8, in fun
traceback.print_stack()
Run Code Online (Sandbox Code Playgroud)
我只是想看看哪些参数传递给函数.
我试图理解为什么我可以沿着字符串迭代.我在文档中看到的是:
需要为容器对象定义一个方法以提供迭代支持:
容器.__ iter __()
返回一个迭代器对象.该对象需要支持下面描述的迭代器协议.如果容器支持不同类型的迭代,则可以提供其他方法来专门请求这些迭代类型的迭代器.(支持多种迭代形式的对象的示例是支持广度优先和深度优先遍历的树结构.)此方法对应于Python/C API中Python对象的类型结构的tp_iter槽.
迭代器对象本身需要支持以下两种方法,它们共同构成迭代器协议:
迭代器.__ iter __()
返回迭代器对象本身.这是允许容器和迭代器与for和in语句一起使用所必需的.此方法对应于Python/C API中Python对象的类型结构的tp_iter槽.
迭代器.下一个()
从容器中返回下一个项目.如果没有其他项,请提高StopIteration异常.此方法对应于Python/C API中Python对象的类型结构的tp_iternext槽.
但...
>>> dir('aa')
['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__',
'__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__',
'__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__',
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'_formatter_field_name_split', '_formatter_parser', 'capitalize',
'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs',
'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower',
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',
'partition', …Run Code Online (Sandbox Code Playgroud) 我有简单的xmlrpc服务器代码:
from SimpleXMLRPCServer import SimpleXMLRPCServer
port = 9999
def func():
print 'Hi!'
print x # error!
print 'Bye!'
if __name__ == '__main__':
server = SimpleXMLRPCServer(("localhost", port))
print "Listening on port %s..." % port
server.register_function(func)
server.serve_forever()
Run Code Online (Sandbox Code Playgroud)
示例会话.
客户:
>>> import xmlrpclib
>>> p = xmlrpclib.ServerProxy('http://localhost:9999')
>>> p.func()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "C:\Python26\lib\xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "C:\Python26\lib\xmlrpclib.py", line 1253, in request
return …Run Code Online (Sandbox Code Playgroud) python multithreading simplexmlrpcserver xmlrpclib xmlrpcclient
我正在尝试使用IE下载Python文件:
from win32com.client import DispatchWithEvents
class EventHandler(object):
def OnDownloadBegin(self):
pass
ie = DispatchWithEvents("InternetExplorer.Application", EventHandler)
ie.Visible = 0
ie.Navigate('http://website/file.xml')
Run Code Online (Sandbox Code Playgroud)
在此之后,我得到一个窗口,询问用户保存文件的位置.如何从python自动保存此文件?
我需要使用一些浏览器,而不是urllib或mechanize,因为在下载文件之前我需要与一些ajax功能进行交互.
我正试图pylint.vim在Windows 上使用.
我在direcory中有https://github.com/orenhe/pylint.vim版本C:\Program Files\Vim\vimfiles\compiler.我补充说:
autocmd FileType python compiler pylint
Run Code Online (Sandbox Code Playgroud)
要C:\Program Files\Vim\_vimrc提交文件,也可以在我的系统中将pylint识别为命令.
但是当我保存python源代码时,我得到的不是pylint输出:
"file.py" 199L, 5876C written
Error detecded while processing function Pylint:
line 11:
E40: Can't open errorfile C:\DOCUME~1\xxx\LOCALS~1\Temp\VIeAA.tmp
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
编辑: 由于lunaryorn建议我尝试使用syntaly.但我有类似的问题,也找到了关于它的线程:https://github.com/scrooloose/syntastic/issues/29但仍然不知道如何解决它.
我开始学习Qt4模型/视图编程,我有初学者的问题.
我有简单的应用程序,显示sqlite表QTableView:
class Model(QtSql.QSqlTableModel):
def __init__(self, parent=None):
super(Model, self).__init__(parent)
self.setEditStrategy(QtSql.QSqlTableModel.OnFieldChange)
self.setTable("test")
self.select()
class App(QtGui.QMainWindow):
def __init__(self, model):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.tableView.setModel(model)
if __name__ == "__main__":
myDb = QtSql.QSqlDatabase.addDatabase("QSQLITE")
myDb.setDatabaseName("test.db")
if not myDb.open():
print 'FIXME'
model = Model()
app = QtGui.QApplication(sys.argv)
window = App(model)
window.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
这里数据库的样子如下:
sqlite> create table test (a INTEGER, b INTEGER, c STRING);
sqlite> insert into test VALUES(1, 2, "xxx");
sqlite> insert into test VALUES(6, 7, "yyy");
Run Code Online (Sandbox Code Playgroud)
所以我得到了类似的东西:
+---+---+-----+
| a | b …Run Code Online (Sandbox Code Playgroud) 我的图像中某些物体的背景不固定。我想像在 gimp 中一样使用“模糊选择”来提取这个对象。这可以是一个例子:
http://img249.imageshack.us/gal.php?g=25750902.png
问题是使用 python/PIL 执行此操作的最佳方法是什么...
我正在努力学习Prolog.这是我使用这种语言的第一步.作为练习我想写一些可以识别一些扑克手的程序(同花顺,四种,满屋等).
我正在寻找Prolog的优秀卡片代表.我需要有可能检查一张卡是否比其他卡大,如果卡适合,那么一张.
我已经开始使用代码:
rank(2).
rank(3).
rank(4).
rank(5).
rank(6).
rank(7).
rank(8).
rank(9).
rank(t).
rank(j).
rank(q).
rank(k).
rank(a).
value(2, 2).
value(3, 3).
value(4, 4).
value(5, 5).
value(6, 6).
value(7, 7).
value(8, 8).
value(9, 9).
value(t, 10).
value(j, 11).
value(q, 12).
value(k, 13).
value(a, 14).
%value(a, 1).
suite(d).
suite(h).
suite(c).
suite(s).
rank_bigger(X, Y) :-
value(X, A),
value(Y, B),
A > B.
Run Code Online (Sandbox Code Playgroud)
这样可以检查等级A是否大于例如J.
但我不知道如何代表单卡.此表示应包含卡的等级并且也适合.Ace也存在一些问题,因为Ace排名第14,但也可以是1.
所以我的问题是,如果我想制定以下规则,如何表示卡片:
isStraight(C1, C2, C3, C4, C5) :-
[...]
Run Code Online (Sandbox Code Playgroud)
要么
isStraightFlush(C1, C2, C3, C4, C5) :-
[...]
Run Code Online (Sandbox Code Playgroud)
如果你了解语言,我确信这是一个简单的问题,但是用C或python这样的语言"切换"思维并不容易.:-)
poker artificial-intelligence prolog declarative-programming
我正在尝试在pyqt中运行我的第一个应用程序.当我在设计师中做预览时,我的表单看起来很好:
http://imageshack.us/photo/my-images/171/screenshotuw.png/
但如果我从我的剧本中显示它,我得到:
http://imageshack.us/photo/my-images/268/screenshot1hwn.png/
和终端中的信息:QLayout:试图将QLayout""添加到MyForm"Form",它已经有了布局
问题是,我的设计出了什么问题?
pyuic4生成的文件:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'gui.ui'
#
# Created: Tue Aug 23 11:17:30 2011
# by: PyQt4 UI code generator 4.7.2
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(464, 409)
self.verticalLayout_2 = QtGui.QVBoxLayout(Form)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.listView = QtGui.QListView(Form)
self.listView.setObjectName("listView")
self.horizontalLayout.addWidget(self.listView)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton = …Run Code Online (Sandbox Code Playgroud)