python-2.6

Python multiprocessing on Python 2.6 Win32 (xp)

跟風遠走 提交于 2019-12-02 04:56:22
问题 I tried to copy this example from this Multiprocessing lecture by jesse noller (as recommended in another SO post)[http://pycon.blip.tv/file/1947354?filename=Pycon-IntroductionToMultiprocessingInPython630.mp4] But for some reason I'm getting an error, as though it's ignoring my function definitions: I'm on Windows XP (win32) which I know has restrictions with regards to the multiprocessing library in 2.6 that requires everything be pickleable from multiprocessing import Process import time

Sending email without keyfile (only certfile) using Python smtplib

走远了吗. 提交于 2019-12-02 04:56:16
问题 Trying to send email with a certificate file using the following script: import smtplib client = smtplib.SMTP(myhost, myport) client.ehlo() client.starttls(certfile=mycertfile) client.ehlo() client.login(myusername, mypassword) client.sendmail(sender, receiver, Message) client.quit() I get the following error: SSLError: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib I think documentations (smtplib.html and ssl.html) say I need to provide a private key. I only have the

Sending email without keyfile (only certfile) using Python smtplib

冷暖自知 提交于 2019-12-02 02:04:37
Trying to send email with a certificate file using the following script: import smtplib client = smtplib.SMTP(myhost, myport) client.ehlo() client.starttls(certfile=mycertfile) client.ehlo() client.login(myusername, mypassword) client.sendmail(sender, receiver, Message) client.quit() I get the following error: SSLError: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib I think documentations ( smtplib.html and ssl.html ) say I need to provide a private key. I only have the certificate file (base64 PEM format). My devops says that a private key is not required in this case because

Convert QDate to seconds

霸气de小男生 提交于 2019-12-02 01:34:15
I take date from QDateTimeEdit and convert it to seconds like this: import time from datetime import datetime date = self.__ui.dateTimeEdit.date().toString("dd/MM/yy") dateString = str(date) seconds = time.mktime(datetime.strptime(dateString, "%d/%m/%y").timetuple()) This works well, but since it looks to long to me, my question is: Is it possible to convert self.__ui.dateTimeEdit.date() directly, without those string conversions? EDIT1 Unfortunately toMSecsSinceEpoch() as falsetru suggested, doesn't work for me. AttributeError: 'QDateTime' object has no attribute 'toMSecsSinceEpoch' I'm using

How to use logging NullHandler in python 2.6

三世轮回 提交于 2019-12-02 00:09:50
Most of my code at this point has been designed to run on python 2.76. So the library I wrote uses the following code so that any consumers of my libraries can have debug logging coming from the library: So in each library file I have this: log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) This way if a client script using my library instantiates a logger object, the library will have log output as well. However, I now need to tweak this library so it runs on python 2.6 and it's complaining about this bit of code: Traceback (most recent call last): File "./LCMTool.py",

Floating point behavior in Python 2.6 vs 2.7

我怕爱的太早我们不能终老 提交于 2019-12-01 23:15:46
问题 So I break out the Python 2.6 interpreter and I get this: Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 2.1 2.1000000000000001 >>> 2.2 2.2000000000000002 >>> 2.2 2.2000000000000002 However in Python 2.7 I get more human-like results like below: Python 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for

Duplicate packets in Python multicast receiver

主宰稳场 提交于 2019-12-01 22:02:20
问题 There is a script that opens a socket and read from it the multicast (from Multicast in Python) import socket import struct MCAST_GRP = '224.1.1.1' MCAST_PORT = 1234 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('', MCAST_PORT)) mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY) sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) while True: print sock.recv

How do I prevent my Python application from automatically closing once reaching the end of code? [duplicate]

旧时模样 提交于 2019-12-01 21:16:05
This question already has an answer here: How to keep a Python script output window open? 19 answers I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6. Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells

Duplicate packets in Python multicast receiver

泪湿孤枕 提交于 2019-12-01 21:07:12
There is a script that opens a socket and read from it the multicast (from Multicast in Python ) import socket import struct MCAST_GRP = '224.1.1.1' MCAST_PORT = 1234 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('', MCAST_PORT)) mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY) sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) while True: print sock.recv(10240) Everything is fine as long as I do not run parallel to the same script to another multicast

undefined symbol: clapack_sgesv

故事扮演 提交于 2019-12-01 20:09:31
I have this little code: from numpy import * from scipy import signal, misc import matplotlib.pyplot as plt path="~/pics/" band_1 = misc.imread(path + "foo.tif"); H = array((1/2.0, 1/4.0, 1/2.0)); signal.convolve2d(band_1.flatten(), H) plt.figure() plt.imshow(band_1) plt.show() then I execute this code python foo.py and it throws this error: Traceback (most recent call last): File "foo.py", line 2, in <module> from scipy import signal File "/usr/lib/python2.6/site-packages/scipy/signal/__init__.py", line 10, in <module> from filter_design import * File "/usr/lib/python2.6/site-packages/scipy