Skip to main content

Posts

Showing posts from July, 2013

About install from Ubuntu PPA

The PPA is short for Personal Package Archives for Ubuntu , which is a place for publishing/installing personal organized packages from  launchpad.net . Usually, the url of a package archive is organized as https://launchpad.net/~PUBLISHER_NAME/+archive/PACKAGE_ARCHIVE_NAME. At the url, you may see a full list of packages included. You can also search PPA packages in  https://launchpad.net/ubuntu/+ppas  . To install some packages using a ppa, you may use sudo add-apt-repository ppa:PPA_PUBLISHER_NAME/PPA_ARCHIVE_NAME sudo apt-get update sudo apt-get install PACKAGE_NAME If you want to remove a ppa sudo add-apt-repository --remove ppa:PPA_PUBLISHER_NAME/PPA_ARCHIVE_NAME For the command add-apt-repository, if not found, you may need to install python-software-properties for Ubuntu version <= 12.04, or software-properties-common for Ubuntu version >= 12.10. For earlier versions of Ubuntu or just you want manually add the ppa into the source.list, you may follow  https:/

A possible [Errno 32] Broken pipe when using socket._fileobject

In Python 2.x, socket object have an makefile() method to provide you a file like object. Please do use it carefully, if the socket itself closed unexpectedly, the fileobject may not know the connection is actually closed. So some buffered write is not going to be performed correctly. For example, considering the following code: import socket sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('google.com', 80)) wfile = sock.makefile('w') wfile.write('a') sock.shutdown(socket.SHUT_WR) wfile.close() It will cause exceptions as below: Traceback (most recent call last): File "socket_shut.py", line 9, in wfile.close() File "/usr/lib/python2.7/socket.py", line 279, in close self.flush() File "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) socket.error: [Errno 32] Broken pipe The reason is that wfile has some buffered write,