Available Count int64 1 12 | GUI and Desktop Applications int64 0 1 | Q_Score int64 0 1.53k | Question stringlengths 28 6.1k | Networking and APIs int64 1 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 90 | Data Science and Machine Learning int64 0 1 | Score float64 -1 1.2 | Q_Id int64 337 51.9M | Users Score int64 -8 412 | Other int64 0 1 | Answer stringlengths 14 7k | A_Id int64 635 72.5M | ViewCount int64 13 1.34M | Web Development int64 0 1 | is_accepted bool 2
classes | CreationDate stringlengths 23 23 | Database and SQL int64 0 1 | Python Basics and Environment int64 0 1 | AnswerCount int64 1 28 | Title stringlengths 15 149 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 1 | 337 | 6 | 0 | I write a SOAP server that receives XML requests and creates XML responses. (Unfortunately, it's not my project, so it's closed source, but that's another problem).
It turned out for me that creating (SOAP) XML documents is fairly simple if you have a data structure that "fits" the schema.
I keep the envelope since th... | 635 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 1 | 337 | 8 | 0 | I've used ElementTree for several projects and recommend it.
It's pythonic, comes 'in the box' with Python 2.5, including the c version cElementTree (xml.etree.cElementTree) which is 20 times faster than the pure Python version, and is very easy to use.
lxml has some perfomance advantages, but they are uneven and you ... | 123,307 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 1 | 337 | 8 | 0 | It depends a bit on how complicated the document needs to be.
I've used minidom a lot for writing XML, but that's usually been just reading documents, making some simple transformations, and writing them back out. That worked well enough until I needed the ability to order element attributes (to satisfy an ancient appl... | 202,259 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 0.033321 | 337 | 2 | 0 | I assume that the .NET way of processing XML builds on some version of MSXML and in that case I assume that using, for example, minidom would make you feel somewhat at home. However, if it is simple processing you are doing, any library will probably do.
I also prefer working with ElementTree when dealing with XML in P... | 69,772 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 0.049958 | 337 | 3 | 0 | I strongly recommend SAX - Simple API for XML - implementation in the Python libraries. They are fairly easy to setup and process large XML by even driven API, as discussed by previous posters here, and have low memory footprint unlike validating DOM style XML parsers. | 13,832,269 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
6 | 0 | 82 | I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it.
Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python.
... | 1 | 0 | python,xml | 0 | 1 | 337 | 8 | 0 | There are 3 major ways of dealing with XML, in general: dom, sax, and xpath. The dom model is good if you can afford to load your entire xml file into memory at once, and you don't mind dealing with data structures, and you are looking at much/most of the model. The sax model is great if you only care about a few tags,... | 69,410 | 9,979 | 0 | false | 2008-08-02T03:35:00.000 | 0 | 0 | 12 | XML Processing in Python |
1 | 0 | 245 | What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its website? | 1 | 0 | python,xml,dom,xpath,python-2.x | 0 | 1 | 8,692 | 40 | 0 | Use LXML. LXML uses the full power of libxml2 and libxslt, but wraps them in more "Pythonic" bindings than the Python bindings that are native to those libraries. As such, it gets the full XPath 1.0 implementation. Native ElemenTree supports a limited subset of XPath, although it may be good enough for your needs. | 1,732,475 | 338,237 | 0 | false | 2008-08-12T11:28:00.000 | 0 | 0 | 11 | How to use XPath in Python? |
1 | 0 | 1,032 | I have a small utility that I use to download an MP3 file from a website on a schedule and then builds/updates a podcast XML file which I've added to iTunes.
The text processing that creates/updates the XML file is written in Python. However, I use wget inside a Windows .bat file to download the actual MP3 file. I woul... | 1 | 0 | python,http,urllib | 0 | 1 | 22,676 | 20 | 0 | Following are the most commonly used calls for downloading files in python:
urllib.urlretrieve ('url_to_file', file_name)
urllib2.urlopen('url_to_file')
requests.get(url)
wget.download('url', file_name)
Note: urlopen and urlretrieve are found to perform relatively bad with downloading large files (size > 500 MB). req... | 39,573,536 | 1,341,778 | 0 | false | 2008-08-22T15:34:00.000 | 0 | 0 | 27 | How to download a file over HTTP? |
1 | 0 | 58 | What's the best way to specify a proxy with username and password for an http connection in python? | 1 | 0 | python,http,proxy | 0 | 1 | 34,079 | 15 | 0 | Setting an environment var named http_proxy like this: http://username:password@proxy_url:port | 3,942,980 | 95,434 | 0 | false | 2008-08-29T06:55:00.000 | 0 | 0 | 6 | How to specify an authenticated proxy for a python http connection? |
1 | 0 | 86 | How can I retrieve the page title of a webpage (title html tag) using Python? | 1 | 0 | python,html | 0 | 0.033321 | 51,233 | 2 | 0 | soup.title.string actually returns a unicode string.
To convert that into normal string, you need to do
string=string.encode('ascii','ignore') | 17,123,979 | 103,114 | 1 | false | 2008-09-09T04:38:00.000 | 0 | 0 | 12 | How can I retrieve the page title of a webpage using Python? |
2 | 0 | 10 | When I call socket.getsockname() on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this? | 1 | 0 | python,sockets | 0 | 1.2 | 58,294 | 9 | 0 | This isn't possible without cooperation from an external server, because there could be any number of NATs between you and the other computer. If it's a custom protocol, you could ask the other system to report what address it's connected to. | 58,296 | 19,360 | 0 | true | 2008-09-12T04:21:00.000 | 0 | 0 | 9 | How do I get the external IP of a socket in Python? |
2 | 0 | 10 | When I call socket.getsockname() on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this? | 1 | 0 | python,sockets | 0 | 0.044415 | 58,294 | 2 | 0 | import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("msn.com",80))
s.getsockname() | 256,358 | 19,360 | 0 | false | 2008-09-12T04:21:00.000 | 0 | 0 | 9 | How do I get the external IP of a socket in Python? |
2 | 0 | 12 | Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions? | 1 | 0 | python,linux,firefox,ubuntu,automation | 0 | 0 | 60,152 | 0 | 1 | The languages of choice of Firefox is Javascript. Unless you have a specific requirement that requires Python, I would advice you to use that. | 60,218 | 21,896 | 0 | false | 2008-09-12T23:28:00.000 | 0 | 0 | 8 | Automate firefox with python? |
2 | 0 | 12 | Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions? | 1 | 0 | python,linux,firefox,ubuntu,automation | 0 | 0.024995 | 60,152 | 1 | 1 | I would suggest you to use Selenium instead of Mechanize/Twill because Mechanize would fail while handling Javascript. | 7,610,441 | 21,896 | 0 | false | 2008-09-12T23:28:00.000 | 0 | 0 | 8 | Automate firefox with python? |
2 | 0 | 9 | I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol. | 1 | 0 | python,client | 0 | 0.01818 | 64,426 | 1 | 0 | There is no need to use HTTP (indeed, HTTP is not good for RPC in general in some respects), and no need to use a standards-based protocol if you're talking about a python client talking to a python server.
Use a Python-specific RPC library such as Pyro, or what Twisted provides (Twisted.spread). | 256,833 | 8,856 | 0 | false | 2008-09-15T16:27:00.000 | 0 | 0 | 11 | Best Python supported server/client protocol? |
2 | 0 | 9 | I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol. | 1 | 0 | python,client | 0 | 0.072599 | 64,426 | 4 | 0 | I suggest you look at 1. XMLRPC 2. JSONRPC 3. SOAP 4. REST/ATOM
XMLRPC is a valid choice. Don't worry it is too old. That is not a problem. It is so simple that little needed changing since original specification. The pro is that in every programming langauge I know there is a library for a client to be written in. Cer... | 256,826 | 8,856 | 0 | false | 2008-09-15T16:27:00.000 | 0 | 0 | 11 | Best Python supported server/client protocol? |
2 | 0 | 0 | When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.
I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo? | 1 | 0 | python,macos,libxml2 | 0 | 0 | 68,541 | 0 | 0 | I would suspect the permissions on the library. Can you do a strace or similar to find out the filenames it's looking for, and then check the permissions on them? | 70,895 | 225 | 0 | false | 2008-09-16T01:27:00.000 | 0 | 0 | 3 | libxml2-p25 on OS X 10.5 needs sudo? |
2 | 0 | 0 | When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.
I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo? | 1 | 0 | python,macos,libxml2 | 0 | 0 | 68,541 | 0 | 0 | The PATH environment variable was the mistake. | 77,114 | 225 | 0 | false | 2008-09-16T01:27:00.000 | 0 | 0 | 3 | libxml2-p25 on OS X 10.5 needs sudo? |
3 | 0 | 1 | My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?
If it's not, how would you do it with POST? Just out of curiosity.
Cheers! | 1 | 0 | python,authentication,cgi | 0 | 0 | 69,979 | 0 | 1 | With a bit of JavaScript, you could have the client hash the entered password and a server-generated nonce, and use that in an HTTP GET. | 70,003 | 2,893 | 0 | false | 2008-09-16T07:07:00.000 | 0 | 0 | 6 | Can I implement a web user authentication system in python without POST? |
3 | 0 | 1 | My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?
If it's not, how would you do it with POST? Just out of curiosity.
Cheers! | 1 | 0 | python,authentication,cgi | 0 | 1.2 | 69,979 | 5 | 1 | You can actually do it all with GET methods. However, you'll want to use a full challenge response protocol for the logins. (You can hash on the client side using javascript. You just need to send out a unique challenge each time.) You'll also want to use SSL to ensure that no one can see the strings as they go acr... | 69,995 | 2,893 | 0 | true | 2008-09-16T07:07:00.000 | 0 | 0 | 6 | Can I implement a web user authentication system in python without POST? |
3 | 0 | 1 | My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?
If it's not, how would you do it with POST? Just out of curiosity.
Cheers! | 1 | 0 | python,authentication,cgi | 0 | 0.033321 | 69,979 | 1 | 1 | You could use HTTP Authentication, if supported.
You'd have to add SSL, as all methods, POST, GET and HTTP Auth (well, except Digest HHTP authentication) send plaintext.
GET is basically just like POST, it just has a limit on the amount of data you can send which is usually a lot smaller than POST and a semantic differ... | 69,989 | 2,893 | 0 | false | 2008-09-16T07:07:00.000 | 0 | 0 | 6 | Can I implement a web user authentication system in python without POST? |
4 | 0 | 9 | I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas? | 1 | 1 | python,network-programming | 0 | 0.024995 | 85,577 | 1 | 0 | I don't think there is a built in way to get it from Python itself.
My question is, how are you getting the IP information from your network?
To get it from your local machine you could parse ifconfig (unix) or ipconfig (windows) with little difficulty. | 85,608 | 16,340 | 0 | false | 2008-09-17T17:23:00.000 | 0 | 0 | 8 | Search for host with MAC-address using Python |
4 | 0 | 9 | I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas? | 1 | 1 | python,network-programming | 0 | 0 | 85,577 | 0 | 0 | You would want to parse the output of 'arp', but the kernel ARP cache will only contain those IP address(es) if those hosts have communicated with the host where the Python script is running.
ifconfig can be used to display the MAC addresses of local interfaces, but not those on the LAN. | 85,641 | 16,340 | 0 | false | 2008-09-17T17:23:00.000 | 0 | 0 | 8 | Search for host with MAC-address using Python |
4 | 0 | 9 | I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas? | 1 | 1 | python,network-programming | 0 | 0.024995 | 85,577 | 1 | 0 | It seems that there is not a native way of doing this with Python. Your best bet would be to parse the output of "ipconfig /all" on Windows, or "ifconfig" on Linux. Consider using os.popen() with some regexps. | 85,634 | 16,340 | 0 | false | 2008-09-17T17:23:00.000 | 0 | 0 | 8 | Search for host with MAC-address using Python |
4 | 0 | 9 | I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas? | 1 | 1 | python,network-programming | 0 | 0 | 85,577 | 0 | 0 | Depends on your platform. If you're using *nix, you can use the 'arp' command to look up the mac address for a given IP (assuming IPv4) address. If that doesn't work, you could ping the address and then look, or if you have access to the raw network (using BPF or some other mechanism), you could send your own ARP packe... | 85,620 | 16,340 | 0 | false | 2008-09-17T17:23:00.000 | 0 | 0 | 8 | Search for host with MAC-address using Python |
1 | 0 | 16 | Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions? | 1 | 0 | python,xml,streaming | 0 | 1.2 | 93,710 | -4 | 0 | xml.etree.cElementTree, included in the default distribution of CPython since 2.5. Lightning fast for both reading and writing XML. | 93,850 | 2,617 | 0 | true | 2008-09-18T15:42:00.000 | 0 | 0 | 6 | What's the easiest non-memory intensive way to output XML from Python? |
2 | 0 | 117 | What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http://somedomain/foo/ will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download th... | 1 | 0 | python,python-2.7,http,http-headers,content-type | 0 | 0.01818 | 107,405 | 1 | 1 | As an aside, when using the httplib (at least on 2.5.2), trying to read the response of a HEAD request will block (on readline) and subsequently fail. If you do not issue read on the response, you are unable to send another request on the connection, you will need to open a new one. Or accept a long delay between req... | 779,985 | 72,799 | 0 | false | 2008-09-20T06:38:00.000 | 0 | 0 | 11 | How do you send a HEAD HTTP request in Python 2? |
2 | 0 | 117 | What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http://somedomain/foo/ will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download th... | 1 | 0 | python,python-2.7,http,http-headers,content-type | 0 | 0.01818 | 107,405 | 1 | 1 | I have found that httplib is slightly faster than urllib2. I timed two programs - one using httplib and the other using urllib2 - sending HEAD requests to 10,000 URL's. The httplib one was faster by several minutes. httplib's total stats were: real 6m21.334s
... | 2,630,687 | 72,799 | 0 | false | 2008-09-20T06:38:00.000 | 0 | 0 | 11 | How do you send a HEAD HTTP request in Python 2? |
1 | 0 | 225 | I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? | 1 | 0 | python,http,put | 0 | 1 | 111,945 | 8 | 0 | I needed to solve this problem too a while back so that I could act as a client for a RESTful API. I settled on httplib2 because it allowed me to send PUT and DELETE in addition to GET and POST. Httplib2 is not part of the standard library but you can easily get it from the cheese shop. | 114,648 | 174,987 | 0 | false | 2008-09-21T20:11:00.000 | 0 | 0 | 14 | Is there any way to do HTTP PUT in python |
1 | 0 | 18 | Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript. | 1 | 0 | javascript,python,html | 0 | 1 | 126,131 | 8 | 0 | The big complication here is emulating the full browser environment outside of a browser. You can use stand alone javascript interpreters like Rhino and SpiderMonkey to run javascript code but they don't provide a complete browser like environment to full render a web page.
If I needed to solve a problem like this I wo... | 126,250 | 34,652 | 1 | false | 2008-09-24T09:05:00.000 | 0 | 0 | 2 | Python library for rendering HTML and javascript |
1 | 0 | 2 | I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will fa... | 1 | 0 | python,web-services,cookies,soappy,zsi | 0 | 0 | 139,212 | 0 | 1 | Additionally, the Binding class also allows any header to be added. So I figured out that I can just add a "Cookie" header for each cookie I need to add. This worked well for the code generated by wsdl2py, just adding the cookies right after the binding is formed in the SOAP client class. Adding a parameter to the g... | 148,379 | 526 | 0 | false | 2008-09-26T12:45:00.000 | 0 | 0 | 2 | Adding Cookie to ZSI Posts |
1 | 0 | 4 | I'm trying to redirect/forward a Pylons request. The problem with using redirect_to is that form data gets dropped. I need to keep the POST form data intact as well as all request headers.
Is there a simple way to do this? | 1 | 0 | python,post,request,header,pylons | 0 | 1.2 | 153,773 | 2 | 0 | Receiving data from a POST depends on the web browser sending data along. When the web browser receives a redirect, it does not resend that data along. One solution would be to URL encode the data you want to keep and use that with a GET. In the worst case, you could always add the data you want to keep to the sessi... | 153,822 | 1,415 | 0 | true | 2008-09-30T16:11:00.000 | 0 | 0 | 1 | What is the preferred way to redirect a request in Pylons without losing form data? |
1 | 0 | 46 | I've discovered that cElementTree is about 30 times faster than xml.dom.minidom and I'm rewriting my XML encoding/decoding code. However, I need to output XML that contains CDATA sections and there doesn't seem to be a way to do that with ElementTree.
Can it be done? | 1 | 0 | python,xml | 0 | 0.013333 | 174,890 | 1 | 0 | The DOM has (atleast in level 2) an interface
DATASection, and an operation Document::createCDATASection. They are
extension interfaces, supported only if an implementation supports the
"xml" feature.
from xml.dom import minidom
my_xmldoc=minidom.parse(xmlfile)
my_xmldoc.createCDATASection(data)
now u have cadata node... | 510,324 | 52,719 | 0 | false | 2008-10-06T15:56:00.000 | 0 | 0 | 15 | How to output CDATA using ElementTree |
1 | 0 | 1 | If I have no connection to internet, does that mean I can't start IDLE (which comes with python 3.0)? | 1 | 0 | python,python-3.x,python-idle | 0 | 0 | 190,115 | 0 | 0 | Not really. You can download the latest version of Python 3.x suitable for whichever operating system you are using, and you can load IDLE without any internet. | 56,122,726 | 945 | 0 | false | 2008-10-10T04:19:00.000 | 0 | 1 | 3 | IDLE doesn't start in python 3.0 |
1 | 0 | 80 | Python has several ways to parse XML...
I understand the very basics of parsing with SAX. It functions as a stream parser, with an event-driven API.
I understand the DOM parser also. It reads the XML into memory and converts it to objects that can be accessed with Python.
Generally speaking, it was easy to choose bet... | 1 | 0 | python,xml,dom,sax,elementtree | 0 | 1 | 192,907 | 7 | 0 | ElementTree's parse() is like DOM, whereas iterparse() is like SAX. In my opinion, ElementTree is better than DOM and SAX in that it provides API easier to work with. | 192,913 | 33,129 | 0 | false | 2008-10-10T20:22:00.000 | 0 | 0 | 4 | XML parsing - ElementTree vs SAX and DOM |
3 | 0 | 2 | I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?
More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes down to is th... | 1 | 0 | python,sockets | 0 | 0.066568 | 203,758 | 1 | 0 | What is your question exactly?
What happens when you do receive on a socket is that the current available data in the socket buffer is immediately returned. If you give receive (or read, I guess), a huge buffer size, such as 40000, it'll likely never return that much data at once. If you give it a tiny buffer size lik... | 203,769 | 1,350 | 0 | false | 2008-10-15T04:55:00.000 | 0 | 1 | 3 | Receive socket size limits good? |
3 | 0 | 2 | I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?
More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes down to is th... | 1 | 0 | python,sockets | 0 | 1.2 | 203,758 | 2 | 0 | Most likely you've seen code which protects against "extra" incoming data. This is often due to the possibility of buffer overruns, where the extra data being copied into memory overruns the pre-allocated array and overwrites executable code with attacker code. Code written in languages like C typically has a lot of le... | 203,933 | 1,350 | 0 | true | 2008-10-15T04:55:00.000 | 0 | 1 | 3 | Receive socket size limits good? |
3 | 0 | 2 | I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?
More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes down to is th... | 1 | 0 | python,sockets | 0 | 0 | 203,758 | 0 | 0 | I don't know what your actual application is, however, setting a hard limit on the total amount of data that a client can send could be useful in reducing your exposure to denial of service attacks, e.g. client connects and sends 100MB of data which could load your application unacceptably.
But it really depends on wha... | 207,096 | 1,350 | 0 | false | 2008-10-15T04:55:00.000 | 0 | 1 | 3 | Receive socket size limits good? |
1 | 0 | 46 | How can I get a list of the IP addresses or host names from a local network easily in Python?
It would be best if it was multi-platform, but it needs to work on Mac OS X first, then others follow.
Edit: By local I mean all active addresses within a local network, such as 192.168.xxx.xxx.
So, if the IP address of my com... | 1 | 1 | python,networking | 0 | 1.2 | 207,234 | 24 | 0 | If by "local" you mean on the same network segment, then you have to perform the following steps:
Determine your own IP address
Determine your own netmask
Determine the network range
Scan all the addresses (except the lowest, which is your network address and the highest, which is your broadcast address).
Use your DNS... | 207,246 | 129,230 | 0 | true | 2008-10-16T02:32:00.000 | 0 | 0 | 11 | List of IP addresses/hostnames from local network in Python |
2 | 0 | 3 | I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).
Setup Info: This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL. C... | 1 | 0 | python,performance,trac | 0 | 1.2 | 213,838 | 5 | 1 | It's hard to say without knowing more about your setup, but one easy win is to make sure that Trac is running in something like mod_python, which keeps the Python runtime in memory. Otherwise, every HTTP request will cause Python to run, import all the modules, and then finally handle the request. Using mod_python (or ... | 214,162 | 2,997 | 0 | true | 2008-10-17T21:02:00.000 | 0 | 0 | 4 | How to improve Trac's performance |
2 | 0 | 3 | I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).
Setup Info: This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL. C... | 1 | 0 | python,performance,trac | 0 | 0.148885 | 213,838 | 3 | 1 | We've had the best luck with FastCGI. Another critical factor was to only use https for authentication but use http for all other traffic -- I was really surprised how much that made a difference. | 215,084 | 2,997 | 0 | false | 2008-10-17T21:02:00.000 | 0 | 0 | 4 | How to improve Trac's performance |
1 | 0 | 17 | I am interested in making a Google Talk client using Python and would like to use the Twisted libraries Words module. I have looked at the examples, but they don't work with the current implementation of Google Talk.
Has anybody had any luck with this? Would you mind documenting a brief tutorial?
As a simple task, I'... | 1 | 0 | python,twisted,xmpp,google-talk | 0 | -0.099668 | 227,279 | -2 | 0 | As the Twisted libs seem to be out of date, you have two choices:
Implement your own XMPP-handler or look for another library.
I would suggest working with the raw XML; XMPP is not that complicated and you are bound to learn something. | 228,877 | 8,406 | 0 | false | 2008-10-22T19:48:00.000 | 0 | 1 | 4 | How do you create a simple Google Talk Client using the Twisted Words Python library? |
2 | 0 | 2 | I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also cr... | 1 | 0 | python,web-applications,browser | 0 | 0 | 256,021 | 0 | 0 | You would have to write the web page in Python. There are many Python web frameworks out there (e.g. Django) that are easy to work with. You could convert your entire scripting framework to a web application that has a worker thread going and crawling through html pages, saving them to a particular location, indexing t... | 256,028 | 1,222 | 1 | false | 2008-11-01T19:52:00.000 | 0 | 0 | 4 | Can I Use Python to Make a Delete Button in a 'web page' |
2 | 0 | 2 | I have written a script that goes through a bunch of files and snips out a portion of the files for further processing. The script creates a new directory and creates new files for each snip that is taken out. I have to now evaluate each of the files that were created to see if it is what I needed. The script also cr... | 1 | 0 | python,web-applications,browser | 0 | 0.049958 | 256,021 | 1 | 0 | You could make this even simpler by making it all happen in one main page. Instead of having a list of hyperlinks, just have the main page have one frame that loads one of the autocreated pages in it. Put a couple of buttons at the bottom - a "Keep this page" and a "Delete this page." When you click either button, the ... | 256,040 | 1,222 | 1 | false | 2008-11-01T19:52:00.000 | 0 | 0 | 4 | Can I Use Python to Make a Delete Button in a 'web page' |
2 | 0 | 47 | I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page. | 1 | 0 | python,screen-scraping | 0 | 0.085505 | 257,409 | 3 | 0 | Use htmllib to extract all img tags (override do_img), then use urllib2 to download all the images. | 257,413 | 97,893 | 1 | false | 2008-11-02T21:31:00.000 | 0 | 0 | 7 | Download image file from the HTML page source using python? |
2 | 0 | 47 | I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page. | 1 | 0 | python,screen-scraping | 0 | 1 | 257,409 | 8 | 0 | You have to download the page and parse html document, find your image with regex and download it.. You can use urllib2 for downloading and Beautiful Soup for parsing html file. | 257,412 | 97,893 | 1 | false | 2008-11-02T21:31:00.000 | 0 | 0 | 7 | Download image file from the HTML page source using python? |
1 | 0 | 2 | I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.
Ideas how this can be done? | 1 | 0 | python,smtp,tor | 0 | 1.2 | 266,849 | 1 | 1 | Because of abuse by spammers, many Tor egress nodes decline to emit port 25 (SMTP) traffic, so you may have problems. | 275,164 | 2,405 | 0 | true | 2008-11-05T21:50:00.000 | 0 | 0 | 2 | Using Python's smtplib with Tor |
1 | 0 | 58 | I am running my HTTPServer in a separate thread (using the threading module which has no way to stop threads...) and want to stop serving requests when the main thread also shuts down.
The Python documentation states that BaseHTTPServer.HTTPServer is a subclass of SocketServer.TCPServer, which supports a shutdown metho... | 1 | 0 | python,http,basehttpserver | 0 | 1 | 268,629 | 15 | 0 | I think you can use [serverName].socket.close() | 4,020,093 | 87,640 | 0 | false | 2008-11-06T13:10:00.000 | 0 | 0 | 11 | How to stop BaseHTTPServer.serve_forever() in a BaseHTTPRequestHandler subclass? |
2 | 0 | 13 | I develop a client-server style, database based system and I need to devise a way to stress / load test the system. Customers inevitably want to know such things as:
• How many clients can a server support?
• How many concurrent searches can a server support?
• How much data can we store in the database?
• Etc.
Key to... | 1 | 0 | python,database,client-server,load-testing,stress-testing | 0 | 0.197375 | 271,825 | 5 | 1 | For performance you are looking at two things: latency (the responsiveness of the application) and throughput (how many ops per interval). For latency you need to have an acceptable benchmark. For throughput you need to have a minimum acceptable throughput.
These are you starting points. For telling a client how many x... | 271,918 | 10,487 | 0 | false | 2008-11-07T11:35:00.000 | 0 | 0 | 5 | How should I stress test / load test a client server application? |
2 | 0 | 13 | I develop a client-server style, database based system and I need to devise a way to stress / load test the system. Customers inevitably want to know such things as:
• How many clients can a server support?
• How many concurrent searches can a server support?
• How much data can we store in the database?
• Etc.
Key to... | 1 | 0 | python,database,client-server,load-testing,stress-testing | 0 | 0 | 271,825 | 0 | 1 | If you have the budget, LoadRunner would be perfect for this. | 271,891 | 10,487 | 0 | false | 2008-11-07T11:35:00.000 | 0 | 0 | 5 | How should I stress test / load test a client server application? |
1 | 0 | 6 | Let's say I wanted to make a python script interface with a site like Twitter.
What would I use to do that? I'm used to using curl/wget from bash, but Python seems to be much nicer to use. What's the equivalent?
(This isn't Python run from a webserver, but run locally via the command line) | 1 | 0 | python,web-services,twitter | 0 | 0.07983 | 285,226 | 2 | 1 | Python has a very nice httplib module as well as a url module which together will probably accomplish most of what you need (at least with regards to wget functionality). | 285,252 | 839 | 0 | false | 2008-11-12T20:28:00.000 | 0 | 0 | 5 | What Python tools can I use to interface with a website's API? |
1 | 0 | 26 | I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password.
Is this possible? ... | 1 | 0 | python,email,connection,exchange-server,pywin32 | 0 | 1.2 | 288,546 | 1 | 1 | I'm pretty sure this is going to be impossible without using Outlook and a MAPI profile. If you can sweet talk your mail admin into enabling IMAP on the Exchange server it would make your life a lot easier. | 288,569 | 107,535 | 0 | true | 2008-11-13T22:19:00.000 | 0 | 0 | 4 | Connect to Exchange mailbox with Python |
1 | 0 | 21 | We have developers with knowledge of these languages - Ruby , Python, .Net or Java. We are developing an application which will mainly handle XML documents. Most of the work is to convert predefined XML files into database tables, providing mapping between XML documents through database, creating reports from database ... | 1 | 0 | java,.net,python,xml,ruby | 0 | 0.044415 | 301,493 | 2 | 1 | either C# or VB.Net using LiNQ to XML. LiNQ to XML is very very powerful and easy to implement | 301,538 | 18,193 | 1 | false | 2008-11-19T10:35:00.000 | 0 | 0 | 9 | Which language is easiest and fastest to work with XML content? |
1 | 0 | 2 | Is there a way to find all nodes in a xml tree using cElementTree? The findall method works only for specified tags. | 1 | 0 | python,xml,search,celementtree | 0 | 0.099668 | 304,216 | 1 | 0 | Have you looked at node.getiterator()? | 304,221 | 1,525 | 0 | false | 2008-11-20T03:06:00.000 | 0 | 0 | 2 | Find all nodes from an XML using cElementTree |
1 | 0 | 1 | Comparable to cacti or mrtg. | 1 | 0 | python,django,pylons,snmp,turbogears | 0 | 0 | 310,759 | 0 | 1 | or you can start building your own solution (like me), you will be surprised how much can you do with few lines of code using for instance cherryp for web server, pysnmp, and python rrd module. | 541,516 | 1,942 | 1 | false | 2008-11-22T02:26:00.000 | 0 | 0 | 2 | Does anyone know of a python based web ui for snmp monitoring? |
1 | 0 | 6 | I need to run a simple request/response python module under an
existing system with windows/apache/FastCGI.
All the FastCGI wrappers for python I tried work for Linux only
(they use socket.fromfd() and other such shticks).
Is there a wrapper that runs under windows? | 1 | 1 | python,windows,apache,fastcgi | 0 | 0.132549 | 312,928 | 2 | 0 | You might find it easier to ditch FastCGI altogether and just run a python webserver on a localhost port. Then just use mod_rewrite to map the apache urls to the internal webserver.
(I started offering FastCGI at my hosting company and to my surprise, nearly everyone ditched it in favor of just running their own web se... | 318,517 | 3,212 | 0 | false | 2008-11-23T20:39:00.000 | 0 | 0 | 3 | Python as FastCGI under windows and apache |
1 | 0 | 175 | What's the best way to validate that an IP entered by the user is valid? It comes in as a string. | 1 | 0 | python,validation,networking,ip-address | 0 | 0 | 319,279 | 0 | 0 | I only needed to parse IP v4 addresses. My solution based on Chills strategy follows:
def getIP():
valid = False
while not valid :
octets = raw_input( "Remote Machine IP Address:" ).strip().split(".")
try: valid=len( filter( lambda(item):0<=int(item)<256, octets) ) == 4
except: valid = ... | 17,214,916 | 305,361 | 0 | false | 2008-11-25T23:40:00.000 | 0 | 1 | 11 | How to validate IP address in Python? |
2 | 0 | 41 | I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in ... | 1 | 0 | python,xml,elementtree | 0 | 0.059928 | 321,795 | 3 | 1 | Why are you examining the XML data at all?
The way to test object serialization is to create an instance of the object, serialize it, deserialize it into a new object, and compare the two objects. When you make a change that breaks serialization or deserialization, this test will fail.
The only thing checking the XML ... | 322,088 | 17,177 | 0 | false | 2008-11-26T19:09:00.000 | 0 | 0 | 10 | Comparing XML in a unit test in Python |
2 | 0 | 41 | I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in ... | 1 | 0 | python,xml,elementtree | 0 | 0 | 321,795 | 0 | 1 | The Java component dbUnit does a lot of XML comparisons, so you might find it useful to look at their approach (especially to find any gotchas that they may have already addressed). | 322,600 | 17,177 | 0 | false | 2008-11-26T19:09:00.000 | 0 | 0 | 10 | Comparing XML in a unit test in Python |
1 | 0 | 5 | I need to check whether a page is being redirected or not without actually downloading the content. I just need the final URL. What's the best way of doing this is Python?
Thanks! | 1 | 0 | python,http,http-headers | 0 | 0.099668 | 331,855 | 1 | 1 | When you open the URL with urllib2, and you're redirected, you get a status 30x for redirection. Check the info to see the location to which you're redirected. You don't need to read the page to read the info() that's part of the response. | 331,871 | 3,318 | 0 | false | 2008-12-01T19:10:00.000 | 0 | 0 | 2 | How to determine if a page is being redirected |
1 | 0 | 2 | We use a number of diffrent web services in our company, wiki(moinmoin), bugtracker (internally), requestracker (customer connection), subversion. Is there a way to parse the wikipages so that if I write "... in Bug1234 you could ..." Bug1234 woud be renderd as a link to http://mybugtracker/bug1234 | 1 | 0 | python,wiki,moinmoin | 0 | 1.2 | 343,769 | 3 | 0 | check out the interwiki page in moinmoin, (most wikis have them) we use trac for example and you can set up different link paths to point to your different web resources. So in our Trac you can go [[SSGWiki:Some Topic]] and it will point to another internal wiki. | 343,926 | 714 | 1 | true | 2008-12-05T13:08:00.000 | 0 | 0 | 3 | How to use InterWiki links in moinmoin? |
3 | 0 | 3 | I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields.
I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract ... | 1 | 0 | python,xml,performance,large-files,expat-parser | 0 | 0.049958 | 344,559 | 1 | 1 | If you know that the XML files are generated using the ever-same algorithm, it might be more efficient to not do any XML parsing at all. E.g. if you know that the data is in lines 3, 4, and 5, you might read through the file line-by-line, and then use regular expressions.
Of course, that approach would fail if the file... | 344,641 | 572 | 0 | false | 2008-12-05T17:15:00.000 | 0 | 0 | 4 | What is the most efficient way of extracting information from a large number of xml files in python? |
3 | 0 | 3 | I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields.
I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract ... | 1 | 0 | python,xml,performance,large-files,expat-parser | 0 | 0.049958 | 344,559 | 1 | 1 | One thing you didn't indicate is whether or not you're reading the XML into a DOM of some kind. I'm guessing that you're probably not, but on the off chance you are, don't. Use xml.sax instead. Using SAX instead of DOM will get you a significant performance boost. | 345,650 | 572 | 0 | false | 2008-12-05T17:15:00.000 | 0 | 0 | 4 | What is the most efficient way of extracting information from a large number of xml files in python? |
3 | 0 | 3 | I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields.
I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract ... | 1 | 0 | python,xml,performance,large-files,expat-parser | 0 | 1.2 | 344,559 | 3 | 1 | The quickest way would be to match strings (with, e.g., regular expressions) instead of parsing XML - depending on your XMLs this could actually work.
But the most important thing is this: instead of thinking through several options, just implement them and time them on a small set. This will take roughly the same amou... | 344,694 | 572 | 0 | true | 2008-12-05T17:15:00.000 | 0 | 0 | 4 | What is the most efficient way of extracting information from a large number of xml files in python? |
1 | 0 | 31 | I'm using urllib2 to read in a page. I need to do a quick regex on the source and pull out a few variables but urllib2 presents as a file object rather than a string.
I'm new to python so I'm struggling to see how I use a file object to do this. Is there a quick way to convert this into a string? | 1 | 0 | python,file,urllib2 | 0 | 1.2 | 346,230 | 77 | 0 | You can use Python in interactive mode to search for solutions.
if f is your object, you can enter dir(f) to see all methods and attributes. There's one called read. Enter help(f.read) and it tells you that f.read() is the way to retrieve a string from an file object. | 346,237 | 48,579 | 0 | true | 2008-12-06T12:41:00.000 | 0 | 1 | 3 | Read file object as string in python |
4 | 0 | 43 | How can I receive and send email in python? A 'mail server' of sorts.
I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.
Now, am I able to do this all in python, would it be best to use 3rd party libraries? | 1 | 0 | python,email | 0 | 0.044415 | 348,392 | 2 | 1 | Depending on the amount of mail you are sending you might want to look into using a real mail server like postifx or sendmail (*nix systems) Both of those programs have the ability to send a received mail to a program based on the email address. | 348,579 | 51,409 | 0 | false | 2008-12-08T00:12:00.000 | 0 | 0 | 9 | Receive and send emails in python |
4 | 0 | 43 | How can I receive and send email in python? A 'mail server' of sorts.
I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.
Now, am I able to do this all in python, would it be best to use 3rd party libraries? | 1 | 0 | python,email | 0 | 0.088656 | 348,392 | 4 | 1 | poplib and smtplib will be your friends when developing your app. | 348,403 | 51,409 | 0 | false | 2008-12-08T00:12:00.000 | 0 | 0 | 9 | Receive and send emails in python |
4 | 0 | 43 | How can I receive and send email in python? A 'mail server' of sorts.
I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.
Now, am I able to do this all in python, would it be best to use 3rd party libraries? | 1 | 0 | python,email | 0 | 1 | 348,392 | 12 | 1 | I do not think it would be a good idea to write a real mail server in Python. This is certainly possible (see mcrute's and Manuel Ceron's posts to have details) but it is a lot of work when you think of everything that a real mail server must handle (queuing, retransmission, dealing with spam, etc).
You should explain ... | 349,352 | 51,409 | 0 | false | 2008-12-08T00:12:00.000 | 0 | 0 | 9 | Receive and send emails in python |
4 | 0 | 43 | How can I receive and send email in python? A 'mail server' of sorts.
I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.
Now, am I able to do this all in python, would it be best to use 3rd party libraries? | 1 | 0 | python,email | 0 | 1 | 348,392 | 7 | 1 | Python has an SMTPD module that will be helpful to you for writing a server. You'll probably also want the SMTP module to do the re-send. Both modules are in the standard library at least since version 2.3. | 348,423 | 51,409 | 0 | false | 2008-12-08T00:12:00.000 | 0 | 0 | 9 | Receive and send emails in python |
1 | 0 | 1 | Edit: How to return/serve a file from a python controller (back end) over a web server, with the file_name? as suggested by @JV | 1 | 0 | python,file,mime-types,download | 0 | 0.132549 | 352,340 | 2 | 0 | You can either pass back a reference to the file itself i.e. the full path to the file. Then you can open the file or otherwise manipulate it.
Or, the more normal case is to pass back the file handle, and, use the standard read/write operations on the file handle.
It is not recommended to pass the actual data as files ... | 352,385 | 14,590 | 1 | false | 2008-12-09T10:34:00.000 | 0 | 0 | 3 | Return file from python module |
1 | 0 | 90 | There is a socket related function call in my code, that function is from another module thus out of my control, the problem is that it blocks for hours occasionally, which is totally unacceptable, How can I limit the function execution time from my code? I guess the solution must utilize another thread. | 1 | 0 | python,multithreading | 0 | 0.076772 | 366,682 | 5 | 0 | The only "safe" way to do this, in any language, is to use a secondary process to do that timeout-thing, otherwise you need to build your code in such a way that it will time out safely by itself, for instance by checking the time elapsed in a loop or similar. If changing the method isn't an option, a thread will not s... | 366,754 | 100,904 | 0 | false | 2008-12-14T16:20:00.000 | 0 | 1 | 13 | How to limit execution time of a function call? |
1 | 0 | 23 | I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them.
What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome. | 1 | 0 | python,api,rest,geocoding | 0 | 0 | 373,383 | 0 | 1 | You can have better look in Geopy module.And it is worth enough to use as it contains Google map, yahoo map geocoders with which you can implement geocodings. | 2,229,732 | 13,754 | 0 | false | 2008-12-17T01:19:00.000 | 0 | 0 | 9 | Geocoding libraries |
3 | 0 | 39 | We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:
(104, 'Connection reset by peer')
When I listen in with wireshark, the "good" and "bad" responses look very similar:
... | 1 | 0 | python,sockets,wsgi,httplib2,werkzeug | 0 | 0.099668 | 383,738 | 2 | 0 | I had the same issue however with doing an upload of a very large file using a python-requests client posting to a nginx+uwsgi backend.
What ended up being the cause was the the backend had a cap on the max file size for uploads lower than what the client was trying to send.
The error never showed up in our uwsgi logs ... | 52,826,181 | 140,801 | 1 | false | 2008-12-20T21:04:00.000 | 0 | 0 | 4 | 104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN? |
3 | 0 | 39 | We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:
(104, 'Connection reset by peer')
When I listen in with wireshark, the "good" and "bad" responses look very similar:
... | 1 | 0 | python,sockets,wsgi,httplib2,werkzeug | 0 | 1 | 383,738 | 11 | 0 | Don't use wsgiref for production. Use Apache and mod_wsgi, or something else.
We continue to see these connection resets, sometimes frequently, with wsgiref (the backend used by the werkzeug test server, and possibly others like the Django test server). Our solution was to log the error, retry the call in a loop, and... | 481,952 | 140,801 | 1 | false | 2008-12-20T21:04:00.000 | 0 | 0 | 4 | 104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN? |
3 | 0 | 39 | We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:
(104, 'Connection reset by peer')
When I listen in with wireshark, the "good" and "bad" responses look very similar:
... | 1 | 0 | python,sockets,wsgi,httplib2,werkzeug | 0 | 0.148885 | 383,738 | 3 | 0 | Normally, you'd get an RST if you do a close which doesn't linger (i.e. in which data can be discarded by the stack if it hasn't been sent and ACK'd) and a normal FIN if you allow the close to linger (i.e. the close waits for the data in transit to be ACK'd).
Perhaps all you need to do is set your socket to linger so t... | 384,415 | 140,801 | 1 | false | 2008-12-20T21:04:00.000 | 0 | 0 | 4 | 104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN? |
1 | 0 | 3 | Is there any way to send ARP packet on Windows without the use of another library such as winpcap?
I have heard that Windows XP SP2 blocks raw ethernet sockets, but I have also heard that raw sockets are only blocked for administrators. Any clarification here? | 1 | 0 | python,sockets,ethernet,arp | 0 | 0 | 395,846 | 0 | 0 | You could use the OpenVPN tap to send arbitrary packets as if you where using raw sockets. | 503,144 | 4,899 | 0 | false | 2008-12-28T04:52:00.000 | 0 | 0 | 2 | How do I send an ARP packet through python on windows without needing winpcap? |
1 | 0 | 6 | I am using XML minidom (xml.dom.minidom) in Python, but any error in the XML will kill the parser.
Is it possible to ignore them, like a browser for example?
I am trying to write a browser in Python, but it just throws an exception if the tags aren't fully compatible. | 1 | 0 | python,xml,minidom | 0 | 0.197375 | 399,980 | 3 | 0 | It should be noted that while HTML looks like XML it is not XML. XHTML is an XML form of HTML. | 400,669 | 4,564 | 0 | false | 2008-12-30T10:48:00.000 | 0 | 0 | 3 | Ignoring XML errors in Python |
3 | 0 | 18 | I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds sp... | 1 | 0 | python,web-services,rate-limiting | 0 | 0.033321 | 401,215 | 1 | 0 | SO I am assuming something simple like
import time
time.sleep(2)
will not work for waiting 2 seconds between requests | 401,826 | 17,294 | 1 | false | 2008-12-30T19:30:00.000 | 0 | 1 | 6 | How to limit rate of requests to web services in Python? |
3 | 0 | 18 | I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds sp... | 1 | 0 | python,web-services,rate-limiting | 0 | 0.033321 | 401,215 | 1 | 0 | Your rate limiting scheme should be heavily influenced by the calling conventions of the underlying code (syncronous or async), as well as what scope (thread, process, machine, cluster?) this rate-limiting will operate at.
I would suggest keeping all the variables within the instance, so you can easily implement multip... | 401,332 | 17,294 | 1 | false | 2008-12-30T19:30:00.000 | 0 | 1 | 6 | How to limit rate of requests to web services in Python? |
3 | 0 | 18 | I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds sp... | 1 | 0 | python,web-services,rate-limiting | 0 | 0.066568 | 401,215 | 2 | 0 | Queuing may be overly complicated. A simpler solution is to give your class a variable for the time the service was last called. Whenever the service is called (!1), set waitTime to delay - Now + lastcalltime. delay should be equal to the minimum allowable time between requests. If this number is positive, sleep fo... | 401,390 | 17,294 | 1 | false | 2008-12-30T19:30:00.000 | 0 | 1 | 6 | How to limit rate of requests to web services in Python? |
2 | 0 | 3 | I would like to write a program that will find bus stop times and update my personal webpage accordingly.
If I were to do this manually I would
Visit www.calgarytransit.com
Enter a stop number. ie) 9510
Click the button "next bus"
The results may look like the following:
10:16p Route 154
10:46p Route 154
11:... | 1 | 0 | python,c,text,webpage | 0 | 0 | 419,260 | 0 | 0 | As long as the layout of the web page your trying to 'scrape' doesnt regularly change, you should be able to parse the html with any modern day programming language. | 419,273 | 24,102 | 0 | false | 2009-01-07T05:14:00.000 | 0 | 0 | 8 | Grabbing text from a webpage |
2 | 0 | 3 | I would like to write a program that will find bus stop times and update my personal webpage accordingly.
If I were to do this manually I would
Visit www.calgarytransit.com
Enter a stop number. ie) 9510
Click the button "next bus"
The results may look like the following:
10:16p Route 154
10:46p Route 154
11:... | 1 | 0 | python,c,text,webpage | 0 | 0.024995 | 419,260 | 1 | 0 | That site doesnt offer an API for you to be able to get the appropriate data that you need. In that case you'll need to parse the actual HTML page returned by, for example, a CURL request . | 419,271 | 24,102 | 0 | false | 2009-01-07T05:14:00.000 | 0 | 0 | 8 | Grabbing text from a webpage |
1 | 0 | 1 | How to get the text of selected item from a drop down box element in html forms? (using python)
How can I store the value to a variable, when I select one item from the drop down box using mouse? (ie. without using a submit button)
This is for a application which I am doing in app engine which only supports Python. | 1 | 0 | javascript,python,html,google-app-engine,drop-down-menu | 0 | 0 | 419,908 | 0 | 0 | The problem with using onchange is that not all users are using a mouse. If you have a combo-box and change the value with the keyboard, you'd never be able to get past the first value without the form submitting.
~Cyrix | 7,284,763 | 13,168 | 1 | false | 2009-01-07T11:05:00.000 | 0 | 0 | 4 | Getting selected value from drop down box in a html form without submit |
1 | 0 | 1 | I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ? | 1 | 0 | java,python,image,ms-word | 0 | 0 | 428,308 | 0 | 0 | You want to do this in Java or Python. Try OpenOffice.
In OpenOffice, you can insert Java or Python code as a "Makro".
I'm sure there will be a possibility to change the image URLs. | 430,717 | 1,351 | 0 | false | 2009-01-09T14:46:00.000 | 0 | 0 | 4 | How to programmatically change urls of images in word documents |
2 | 0 | 3 | I have a python application that relies on a file that is downloaded by a client from a website.
The website is not under my control and has no API to check for a "latest version" of the file.
Is there a simple way to access the file (in python) via a URL and check it's date (or size) without having to download it to t... | 1 | 0 | python,http | 0 | 1 | 428,895 | 6 | 0 | Take into account that 'last-modified' may not be present:
>>> from urllib import urlopen
>>> f=urlopen('http://google.com/')
>>> i=f.info()
>>> i.keys()
['set-cookie', 'expires', 'server', 'connection', 'cache-control', 'date', 'content-type']
>>> i.getdate('date')
(2009, 1, 10, 16, 17, 8, 0, 1, 0)
>>> i.getheader('d... | 431,411 | 12,198 | 0 | false | 2009-01-09T17:11:00.000 | 0 | 0 | 6 | How can I get the created date of a file on the web (with Python)? |
2 | 0 | 3 | I have a python application that relies on a file that is downloaded by a client from a website.
The website is not under my control and has no API to check for a "latest version" of the file.
Is there a simple way to access the file (in python) via a URL and check it's date (or size) without having to download it to t... | 1 | 0 | python,http | 0 | 1 | 428,895 | 7 | 0 | There is no reliable way to do this. For all you know, the file can be created on the fly by the web server and the question "how old is this file" is not meaningful. The webserver may choose to provide Last-Modified header, but it could tell you whatever it wants. | 428,951 | 12,198 | 0 | false | 2009-01-09T17:11:00.000 | 0 | 0 | 6 | How can I get the created date of a file on the web (with Python)? |
1 | 0 | 5 | I need to poll a web service, in this case twitter's API, and I'm wondering what the conventional wisdom is on this topic. I'm not sure whether this is important, but I've always found feedback useful in the past.
A couple scenarios I've come up with:
The querying process starts every X seconds, eg a cron job runs a p... | 1 | 0 | python,twitter,polling | 0 | 0 | 430,226 | 0 | 1 | You should have a page that is like a Ping or Heartbeat page. The you have another process that "tickles" or hits that page, usually you can do this in your Control Panel of your web host, or use a cron if you have a local access. Then this script can keep statistics of how often it has polled in a database or some dat... | 430,245 | 5,380 | 0 | false | 2009-01-10T00:10:00.000 | 0 | 0 | 2 | Best way to poll a web service (eg, for a twitter app) |
2 | 0 | 12 | I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me.
Also, would using Twisted even have a benefit over rolling my own server with select.select()? | 1 | 1 | python,networking,twisted | 0 | 0.039979 | 441,849 | 1 | 0 | Just adding an answer to re-iterate other posters - it'll be worth it to use Twisted. There's no reason to write yet another TCP server that'll end up working not as well as one using twisted would. The only reason would be if writing your own is much faster, developer-wise, but if you just bite the bullet and learn tw... | 442,079 | 12,949 | 0 | false | 2009-01-14T03:51:00.000 | 0 | 0 | 5 | Good Python networking libraries for building a TCP server? |
2 | 0 | 12 | I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me.
Also, would using Twisted even have a benefit over rolling my own server with select.select()? | 1 | 1 | python,networking,twisted | 0 | 1 | 441,849 | 6 | 0 | The standard library includes SocketServer and related modules which might be sufficient for your needs. This is a good middle ground between a complex framework like Twisted, and rolling your own select() loop. | 441,863 | 12,949 | 0 | false | 2009-01-14T03:51:00.000 | 0 | 0 | 5 | Good Python networking libraries for building a TCP server? |
2 | 0 | 25 | I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities.
I'd like to create a web page served from one of my systems that would merely present a few... | 1 | 0 | python,windows,web-services,cgi | 0 | 0 | 448,837 | 0 | 0 | When setting this up, please be careful to restrict access to the scripts that take some action on your web server. It is not sufficient to place them in a directory where you just don't publish the URL, because sooner or later somebody will find them.
At the very least, put these scripts in a location that is password... | 449,199 | 38,798 | 1 | false | 2009-01-15T22:58:00.000 | 0 | 0 | 9 | How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage? |
2 | 0 | 25 | I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities.
I'd like to create a web page served from one of my systems that would merely present a few... | 1 | 0 | python,windows,web-services,cgi | 0 | 0.022219 | 448,837 | 1 | 0 | A simple cgi script (or set of scripts) is all you need to get started. The other answers have covered how to do this so I won't repeat it; instead, I will stress that using plain text will get you a long way. Just output the header (print("Content-type: text/plain\n") plus print adds its own newline to give you the ne... | 449,062 | 38,798 | 1 | false | 2009-01-15T22:58:00.000 | 0 | 0 | 9 | How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage? |
2 | 0 | 6 | I'm new to web services and as an introduction I'm playing around with the Twitter API using the Twisted framework in python. I've read up on the different formats they offer, but it's still not clear to me which one I should use in my fairly simple project.
Specifically the practical difference between using JSON or X... | 1 | 0 | python,xml,json,twitter,twisted | 0 | 0.26052 | 453,158 | 4 | 1 | RSS and Atom are XML formats.
JSON is a string which can be evaluated as Javascript code. | 453,160 | 8,204 | 0 | false | 2009-01-17T11:19:00.000 | 0 | 0 | 3 | What is the practical difference between xml, json, rss and atom when interfacing with Twitter? |
2 | 0 | 6 | I'm new to web services and as an introduction I'm playing around with the Twitter API using the Twisted framework in python. I've read up on the different formats they offer, but it's still not clear to me which one I should use in my fairly simple project.
Specifically the practical difference between using JSON or X... | 1 | 0 | python,xml,json,twitter,twisted | 0 | 0.066568 | 453,158 | 1 | 1 | I would say the amount of data being sent over the wire is one factor. XML data stream will be bigger than JSON for the same data. But you can use whatever you know more/have more experience.
I would recommend JSON, as it's more "pythonic" than XML. | 453,164 | 8,204 | 0 | false | 2009-01-17T11:19:00.000 | 0 | 0 | 3 | What is the practical difference between xml, json, rss and atom when interfacing with Twitter? |
1 | 0 | 2 | I have a "manager" process on a node, and several worker processes. The manager is the actual server who holds all of the connections to the clients. The manager accepts all incoming packets and puts them into a queue, and then the worker processes pull the packets out of the queue, process them, and generate a result.... | 1 | 1 | python,sockets,twisted,multiprocess | 0 | 1.2 | 460,068 | 3 | 0 | It sounds like you might need to keep a reference to the transport (or protocol) along with the bytes the just came in on that protocol in your 'event' object. That way responses that came in on a connection go out on the same connection.
If things don't need to be processed serially perhaps you should think about se... | 460,245 | 829 | 0 | true | 2009-01-20T03:43:00.000 | 0 | 0 | 1 | Python/Twisted - Sending to a specific socket object? |
3 | 0 | 2 | This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?
I was thinking of maybe summing a dictionary that uses the current ... | 1 | 0 | python | 0 | 1.2 | 464,314 | 1 | 0 | When you say the last minute, do you mean the exact last seconds or the last full minute from x:00 to x:59? The latter will be easier to implement and would probably give accurate results. You have one prev variable holding the value of the hits for the previous minute. Then you have a current value that increments eve... | 464,347 | 303 | 0 | true | 2009-01-21T07:14:00.000 | 0 | 0 | 3 | Python - Hits per minute implementation? |
3 | 0 | 2 | This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?
I was thinking of maybe summing a dictionary that uses the current ... | 1 | 0 | python | 0 | 0.066568 | 464,314 | 1 | 0 | For what it's worth, your implementation above won't work if you don't receive a packet every second, as the next second entry won't necessarily be reset to 0.
Either way, afaik the "correct" way to do this, ala logs analysis, is to keep a limited record of all the queries you receive. So just chuck the query, time rec... | 464,329 | 303 | 0 | false | 2009-01-21T07:14:00.000 | 0 | 0 | 3 | Python - Hits per minute implementation? |
3 | 0 | 2 | This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?
I was thinking of maybe summing a dictionary that uses the current ... | 1 | 0 | python | 0 | 0.197375 | 464,314 | 3 | 0 | A common pattern for solving this in other languages is to let the thing being measured simply increment an integer. Then you leave it to the listening client to determine intervals and frequencies.
So you basically do not let the socket server know about stuff like "minutes", because that's a feature the observer calc... | 464,322 | 303 | 0 | false | 2009-01-21T07:14:00.000 | 0 | 0 | 3 | Python - Hits per minute implementation? |
1 | 0 | 17 | while learning some basic programming with python, i found web.py. i
got stuck with a stupid problem:
i wrote a simple console app with a main loop that proccesses items
from a queue in seperate threads. my goal is to use web.py to add
items to my queue and report status of the queue via web request. i
got this running... | 1 | 0 | python,multithreading,web-services,web.py | 0 | 0.049958 | 500,935 | 1 | 0 | Wouldn't is be simpler to re-write your main-loop code to be a function that you call over and over again, and then call that from the function that you pass to runsimple...
It's guaranteed not to fully satisfy your requirements, but if you're in a rush, it might be easiest. | 501,570 | 7,054 | 1 | false | 2009-02-01T14:47:00.000 | 0 | 0 | 4 | Using web.py as non blocking http-server |
1 | 0 | 3 | I've written several scripts that make use of the gdata API, and they all (obviously) have my API key and client ID in plain-text. How am I supposed to distribute these? | 1 | 0 | python,gdata-api | 0 | 0 | 513,806 | 0 | 0 | If we assume that you want clients to use their own keys I'd recommend putting them in a configuration file which defaults to an (invalid) sentinel value.
If on the other hand you want the script to use your key the best you can do is obfuscate it. After all, if your program can read it then an attacker (with a debugge... | 513,838 | 306 | 0 | false | 2009-02-04T23:06:00.000 | 0 | 1 | 2 | How to distribute script using gdata-python-client? |
2 | 0 | 21 | I'd like to write a python library to wrap a REST-style API offered by a particular Web service. Does anyone know of any good learning resources for such work, preferably aimed at intermediate Python programmers?
I'd like a good article on the subject, but I'd settle for nice, clear code examples.
CLARIFICATION: What I... | 1 | 0 | python,web-services,api,rest | 0 | 0.07983 | 517,237 | 2 | 0 | My favorite combination is httplib2 (or pycurl for performance) and simplejson. As REST is more "a way of design" then a real "protocol" there is not really a reusable thing (that I know of). On Ruby you have something like ActiveResource. And to be honest, even that would just expose some tables as a webservice, where... | 518,161 | 15,114 | 0 | false | 2009-02-05T18:29:00.000 | 0 | 1 | 5 | HOWTO: Write Python API wrapper? |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 23