小编Dmi*_*erg的帖子

目标输出文件的路径

我有一个.so库目标add_library,并且需要将该库的绝对路径传递给外部脚本.现在我有了${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}LangShared${CMAKE_SHARED_LIBRARY_SUFFIX}(LIBRARY_OUTPUT_PATH在我的定义中CMakeLists.txt).这看起来像是硬编码,因为一旦重命名目标或其某些属性发生更改,它就会中断.有没有办法获得add_library输出的绝对路径?

cmake

45
推荐指数
2
解决办法
4万
查看次数

将DataGridView绑定到List <>,某些属性不应显示

我试图将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.如何防止它被添加?

c# data-binding datagridview

6
推荐指数
1
解决办法
3363
查看次数

Django和Postgres事务回滚

我有一段代码在后台进程中工作,看起来像

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)

python django postgresql transactions

5
推荐指数
1
解决办法
4210
查看次数

在atexit中引用其他模块

我有一个函数负责在程序结束时终止子进程:

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)

在调用之前看起来像ossignal模块被卸载了atexit.重新导入它们解决了这个问题,但这种行为对我来说似乎很奇怪 - 这些模块是在我注册我的处理程序之前导入的,所以为什么在我自己的退出处理程序运行之前它们被卸载了?

python atexit

2
推荐指数
1
解决办法
1526
查看次数