我有一个.so库目标add_library
,并且需要将该库的绝对路径传递给外部脚本.现在我有了${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}LangShared${CMAKE_SHARED_LIBRARY_SUFFIX}
(LIBRARY_OUTPUT_PATH
在我的定义中CMakeLists.txt
).这看起来像是硬编码,因为一旦重命名目标或其某些属性发生更改,它就会中断.有没有办法获得add_library
输出的绝对路径?
我试图将DataGridView绑定到List,MyObject看起来像
class MyObject
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
//List<MyObject> objects;
grid.Columns[0].DataPropertyName = "Property1";
grid.DataSource = objects;
Run Code Online (Sandbox Code Playgroud)
我只想显示一个属性,但我将另一列添加到我的DataGridView,其中也显示了Property2.如何防止它被添加?
我有一段代码在后台进程中工作,看起来像
from django.db import transaction
try:
<some code>
transaction.commit()
except Exception, e:
print e
transaction.rollback()
Run Code Online (Sandbox Code Playgroud)
在测试中,我打破<some_code>
了导致数据库错误的数据.例外情况如下
File "/home/commando/Development/Diploma/streaminatr/stream/testcases/feeds.py", line 261, in testInterrupt
form.save(self.user1)
File "/usr/lib/pymodules/python2.5/django/db/transaction.py", line 223, in _autocommit
return func(*args, **kw)
File "/home/commando/Development/Diploma/streaminatr/stream/forms.py", line 99, in save
print(models.FeedChannel.objects.all())
File "/usr/lib/pymodules/python2.5/django/db/models/query.py", line 68, in `__repr__ `
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/usr/lib/pymodules/python2.5/django/db/models/query.py", line 83, in `__len__ `
self._result_cache.extend(list(self._iter))
File "/usr/lib/pymodules/python2.5/django/db/models/query.py", line 238, in iterator
for row in self.query.results_iter():
File "/usr/lib/pymodules/python2.5/django/db/models/sql/query.py", line 287, in results_iter
for rows in …
Run Code Online (Sandbox Code Playgroud) 我有一个函数负责在程序结束时终止子进程:
class MySingleton:
def __init__(self):
import atexit
atexit.register(self.stop)
def stop(self):
os.kill(self.sel_server_pid, signal.SIGTERM)
Run Code Online (Sandbox Code Playgroud)
但是,当调用此函数时,我收到错误消息:
Traceback (most recent call last):
File "/usr/lib/python2.5/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/commando/Development/Diploma/streaminatr/stream/selenium_tests.py", line 66, in stop
os.kill(self.sel_server_pid, signal.SIGTERM)
AttributeError: 'NoneType' object has no attribute 'kill'
Run Code Online (Sandbox Code Playgroud)
在调用之前看起来像os
和signal
模块被卸载了atexit
.重新导入它们解决了这个问题,但这种行为对我来说似乎很奇怪 - 这些模块是在我注册我的处理程序之前导入的,所以为什么在我自己的退出处理程序运行之前它们被卸载了?
python ×2
atexit ×1
c# ×1
cmake ×1
data-binding ×1
datagridview ×1
django ×1
postgresql ×1
transactions ×1