小编J C*_*per的帖子

ImportError:没有名为_ssl的模块

Ubuntu Maverick w/Python 2.7:

我无法弄清楚如何解决以下导入错误:

>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
   import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl
Run Code Online (Sandbox Code Playgroud)

更新: 我重新编译了源代码.我无法弄清楚如何在下面提到的答案中添加--with-ssl选项,而是通过在/Modules/Setup.dist中编辑关于SSL的行来实现这一点.

python python-2.7

45
推荐指数
5
解决办法
10万
查看次数

更新并连接多行,使用哪一行的值?

假设我有以下语句,内连接产生3行,其中a.Id = b.Id,但3行中的每一行都有不同的b.Value.由于只更新了tableA中的一行,因此更新中使用了3个值中的哪一个?

UPDATE a
SET a.Value = b.Value
FROM tableA AS a
INNER JOIN tableB as b 
ON a.Id = b.Id
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2008-r2

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

fcntl.flock - 如何实现超时?

我正在使用python 2.7

我想创建一个围绕fcntl.flock()的包装函数,它将在设置的间隔后超时:

wrapper_function(timeout):
Run Code Online (Sandbox Code Playgroud)

我试过调用另一个线程并使用thread.join(超时),但似乎fcntl.flock()继续阻塞:

def GetLock(self, timeout):
    """Returns true if lock is aquired, false if lock is already in use"""
    self.__lock_file = open('proc_lock', 'w')

    def GetLockOrTimeOut():
        print 'ProcessLock: Acquiring Lock'            
        fcntl.flock(self.__lock_file.fileno(), fcntl.LOCK_EX)
        print 'ProcessLock: Lock Acquired'

    thread = threading.Thread(target=GetLockOrTimeOut)
    thread.start()
    thread.join(timeout)

    if thread.isAlive():
        print 'GetLock timed out'
        return False
    else:
        return True
Run Code Online (Sandbox Code Playgroud)

我已经研究了终止线程的解决方案,最流行的解决方案似乎是对threading.thread进行子类化并添加一个功能来引发线程中的异常.但是,我遇到一个链接,说这个方法不适用于本机调用,我很确定fcntl.flock()正在调用本机函数.建议?

上下文:我使用文件锁来创建单个实例应用程序,但我不希望应用程序的第二个实例坐下来并挂起,直到第一个实例终止.

python multithreading

11
推荐指数
3
解决办法
7725
查看次数

CommandTimeout无效

我试图在一个测试我的连接为给定的连接字符串的方法中更改SqlCommand查询的超时.代码类似于:

using (SqlConnection connection = new SqlConnection(connectionString))
    {
      SqlCommand cmd = new SqlCommand("SELECT ...", connection);
      cmd.CommandTimeout = 10;
      connection.Open();
      SqlDataReader reader = cmd.ExecuteReader();
      ...
      connection.Close();
    }
Run Code Online (Sandbox Code Playgroud)

我想在这里有一个短暂的超时,因为我只想测试这个连接字符串是否正常.但是,无论我在CommandTimeout上设置了什么号码(我尝试过0,1,2,4,10,30,60,120),我为虚拟连接字符串获得的实时总是大致相同(总运行时间约为15秒).

所以,在我看来,我在CommandTimeout上设置的值由于某种原因被忽略.

有什么想法吗?

c# sql ado.net

11
推荐指数
1
解决办法
1万
查看次数

Sql Server Reporting Services与通过.NET应用程序进行报告

我的老板要我在不久的将来创建一些报告,我想他想使用SQL Server Reporting Services来部署报告.考虑到我们是一个非常小的组织,我不太确定这将是一个好主意,我看不到我们正在充分利用或需要此解决方案提供的功能,如设置用户,组和订阅.

虽然我之前没有使用SSRS,但我已经观看了为期3天的网络研讨会,看起来这是一件很好的事情,对于简单的情况来说很好但是当需求变得更加复杂时会变得很痛苦并且受到限制.我会将报告部署为.net应用程序中的本地报告(.rdlc),因为:

  1. 我宁愿用.NET然后用SQL处理和格式化数据.当然你可以使用CLR,但这条路线看起来似乎更难以维护,而不仅仅像处理.NET应用程序那样处理数据.
  2. 添加参数控件时UI的限制 - 如果我记得你对布局没有太多控制权.

所以我想我的问题是SSRS在什么情况下运作良好,哪些情况不好?我的观点是有效还是我只是怀疑论者?

.net sql-server rdlc reporting-services

10
推荐指数
2
解决办法
3052
查看次数

来自wsdl文件的svcutil:找不到具有目标命名空间的错误架构

在我的机器上,我有一个WSDL文件和所有必要的模式文件.我正在尝试使用svcutil从WSDL创建客户端代理代码.命令:

svcutil myfile.wsdl
Run Code Online (Sandbox Code Playgroud)

我在使用svcutil时遇到错误,但在使用soapUI加载wsdl时没有问题,如果这意味着什么.

我一直收到这个错误:

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0']/wsdl:portType[@name='areventservice']
Run Code Online (Sandbox Code Playgroud)

这是WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    name="areventservice"
    targetNamespace="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
    xmlns:tns="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
    xmlns:es="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0">



    <wsdl:types>
        <xsd:schema targetNamespace="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
                    xmlns:tns="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
                    xmlns:es="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0">

            <xsd:include schemaLocation="arevent-service.xsd"/>
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="SaveAREventWithShortNames">
        <wsdl:part element="es:save-arevent-with-shortnames" name="SaveAREventWithShortNames"/>
    </wsdl:message>

    <wsdl:message name="RetrieveAREventByConsumerIdentifier">
        <wsdl:part element="es:retrieve-arevent-by-consumer-agency-identifier" name="RetrieveAREventByConsumerIdentifier"/>
    </wsdl:message>

    <wsdl:message name="RetrieveAREventByConsumerAccountIdentifier">
        <wsdl:part element="es:retrieve-arevent-by-consumer-account-agency-identifier" name="RetrieveAREventByConsumerAccountIdentifier"/>
    </wsdl:message>

    <wsdl:message name="RetrieveAREventResponse">
        <wsdl:part element="es:retrieve-arevent-response" name="RetrieveAREventResponse"/> …
Run Code Online (Sandbox Code Playgroud)

wcf svcutil.exe

8
推荐指数
1
解决办法
1万
查看次数

调整SQL查询以强制首先显示记录?

如何调整以下查询以始终返回MemberID ='xxx'作为第一行的成员

SELECT*FROM Members

sql sql-server select sql-server-2008

5
推荐指数
2
解决办法
4525
查看次数

为什么streamreader连接到网络流在ReadLine()上返回null?

在下面的代码中,我有一个从网络流中读取的StreamReader.这段代码通常可以运行好几天.我遇到了一个问题,突然StreamReader.ReadLine()开始返回null.

根据Microsoft文档,StreamReader.ReadLine()在到达输入流的末尾时将返回null.当底层流是NetworkStream时,这对我没有意义.ReadLine()不应该阻塞直到网络流接收数据?

这是我第一次遇到这个问题而我无法复制它.什么可能导致这个?

背景信息:应用程序从电话交换机接收CDR记录.电话交换机连接到应用程序并发送普通的旧文本记录.在开关连接后,它将保持连接并继续发送永久记录,除非出现故障.

    private void ProcessClient(TcpClient client)
    {
        try
        {
            using (NetworkStream stream = client.GetStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    //continue processing while service is on
                    while (m_RunService & client.Connected)
                    {

                        string curLine = reader.ReadLine();

                        //code here does stuff to string
                        //will catch any exceptions that have to do with 
                        //processing the string
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //write to log
        }
    }
Run Code Online (Sandbox Code Playgroud)

以下是启动侦听器的代码:

    private void Listen()
    {
        try
        {
            while (m_RunService)
            { …
Run Code Online (Sandbox Code Playgroud)

.net c# tcp

4
推荐指数
1
解决办法
5221
查看次数

为什么附加属性属性更改事件只触发一次?

我有一个绑定到对象列表的列表框.对于每个列表项,我想要一个矩形,其填充颜色由绑定对象的一些属性决定.所以我做了以下事情:

  1. 确保在我的对象上实现了INotifyPropertyChanged.
  2. 创建了一个类来公开我感兴趣的属性作为附加属性.
  3. 将对象的属性绑定到矩形的附加属性
  4. 创建了一个样式,该样式使用触发器根据附加属性设置矩形填充.

这是有效的,但只是第一次对象的属性发生变化.之后,附加属性似乎在数据对象的属性更改时不会收到通知.我已经双重检查,我的数据对象正在引发INotifyPropertyChanged事件.可能是什么问题呢?

<Rectangle Style="{StaticResource RecordStateRectangleStyle}" 
                Width="10" Height="10" Stroke="Black"
                local:RecordAttachment.RecordState="{Binding Path=RecordState}"
                local:RecordAttachment.IsDeleted="{Binding Path=IsDeleted}" />
Run Code Online (Sandbox Code Playgroud)

风格:

   <Style x:Key="RecordStateRectangleStyle" TargetType="Rectangle">
        <Style.Resources>
            <SolidColorBrush x:Key="AddedStateBrush" Color="LightGreen" Opacity=".8" />
            <SolidColorBrush x:Key="ModifiedStateBrush" Color="Orange"  Opacity=".8" />
            <SolidColorBrush x:Key="DeletedStateBrush" Color="Red" Opacity=".8" />
        </Style.Resources>
        <Style.Triggers>
            <Trigger Property="local:RecordAttachment.RecordState" Value="{x:Static model:RecordState.Added}">
                <Setter Property="Fill" Value="{StaticResource AddedStateBrush}" />
            </Trigger>
            <Trigger Property="local:RecordAttachment.RecordState" Value="{x:Static model:RecordState.Modified}">
                <Setter Property="Fill" Value="{StaticResource ModifiedStateBrush}" />
            </Trigger>
            <Trigger Property="local:RecordAttachment.IsDeleted" Value="true">
                <Setter Property="Fill" Value="{StaticResource DeletedStateBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

附属物类:

Public Class RecordAttachment
Public Shared ReadOnly RecordStateProperty As DependencyProperty …
Run Code Online (Sandbox Code Playgroud)

c# vb.net wpf

4
推荐指数
1
解决办法
5263
查看次数

如何在分组时强制SQL Server Group By尊重列顺序?

我正在使用SQL Server 2005.

关于坏桌设计,请看这篇文章的结尾.

我有两列.我想按照第二列的顺序在第一列分组.微软文档声明GROUP BY子句不关心顺序,我该如何强制执行?

这是我的伪查询:

SELECT col_1,
       MIN(col_2),
       MAX(col_2)
FROM someTable
GROUP BY col_1 (*** WITH RESPECT TO ORDER OF col_2***)
Run Code Online (Sandbox Code Playgroud)

如果我在下表中运行查询:

Col_1    Col_2
A       1
A       2
A       3
B       4
C       5
C       6
B       7
A       9
Run Code Online (Sandbox Code Playgroud)

我应该得到以下结果:

Col_1  Min   Max
A      1     3
B      4     4
C      5     6
B      7     7
A      9     9
Run Code Online (Sandbox Code Playgroud)

关键部分是我不能在结果集中将A的所有4条记录集中在一起.当查询表/子查询时,它按col_2排序,col_1的每个新实例都应该导致新的分组.谢谢,我找不到任何相关内容.

我可以做NOTHING与表的设计.这是一个由外部供应商创建的表,该表与其专有软件一起使用.我再说一遍,我对表设计无能为力!!!!

sql sql-server sql-server-2005 gaps-and-islands

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

带图像的按钮,为什么单击图像时按钮命令不会触发?

仅当单击鼠标时鼠标未在图像上方时,才会触发按钮命令.我错过了什么?

<Button Cursor="Hand" Command="{Binding Path=SomeCommand}">
    <Image Source="image.png" />                         
</Button>
Run Code Online (Sandbox Code Playgroud)

wpf

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

select语句中的where子句 - datetime问题

我想根据数据库中时间戳字段的年份和月份在我的select语句中放置一个where子句

我有一个月和一年的下拉列表,它给了我以下字符串01/2012

我的数据库中的日期格式是"2012-01-01 00:00:00"但是当我选择一个单独的日期并将其放入消息框时,它会转换为"01/01/2012"

我已经修改了下面的选择语句以反映转换日期.但是我仍然没有给出正确的细节.有任何想法吗?在处理时间戳字段时是否需要使用特定格式?我甚至可以在select语句中使用"Right"函数吗?

Dim newRecordDate As String = val1 & "/" & ComboBox2.SelectedValue 
Dim sql2 As String = "Select CatA, CatB, CatC,  Cost, Currency, MarketingCode, Comment, RecordDate from vw_tblP_Usage_Details where puid = '" & puid & "' right(RecordDate, 7) = '" & newRecordDate & "'"
Run Code Online (Sandbox Code Playgroud)

sql vb.net sql-server

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

使用表alias.column名称作为参数调用Inline UDF

我有一个内联表值函数,我想从select传递一个列,但将使用表别名.

例如:

select top 1000 a.*, b.* from item a
LEFT JOIN itemList b on a.item_id = b.item_id
where a.item_id in (SELECT * FROM dbo.fn_GIVFUC('1234567', a.item_id))
Run Code Online (Sandbox Code Playgroud)

结果:'a'附近的语法不正确.

谢谢

sql sql-server sql-server-2005 user-defined-functions

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