Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems migrating a class from linux to windows - Urllib.request
    primarykey
    data
    text
    <p>I had this class that performed perfectly in Linux.</p> <pre><code>class UrlRequestor(object): def __init__(self, url, headers, data): self.url = url self.headers = headers self.request = urllib2.Request(url) self.data = data self.data = data if self.data: self.request.add_data(self.data) for headerName, headerContent in self.headers.iteritems(): self.request.add_header(headerName, headerContent) def open(self): self.content = urllib2.urlopen(self.request) def getHeader(self, headerName): return self.content.info().getheader(headerName) def getReturnData(self): return dict(json.loads(self.content.read())) def getRawReturn(self): return self.content.read()} </code></pre> <p>Which I have been trying to run on windows - with many errors including indentation I finally became stuck at this point.</p> <p>I am apparently missing a 'positional argument' for the add_data method. Although I believe this is a symptom of a larger problem.</p> <p>Here is the code as I have it.</p> <pre><code>class UrlRequestor(object): def __init__(self, url, headers, data): self.url = url self.headers = headers self.request = urllib2.Request(url) self.data = data self.data = data if self.data: self.request.add_data(self.data) for headerName, headerContent in self.headers.iteritems(): self.request.add_header(headerName, headerContent) def open(self): self.content = urllib2.urlopen(self.request) def getHeader(self, headerName): return self.content.info().getheader(headerName) def getReturnData(self): return dict(json.loads(self.content.read())) def getRawReturn(self): return self.content.read() </code></pre> <p>I don't mind reading, I don't mind point in the right direction. At this point I am pretty stumped, and a little pointing wouldn't hurt.</p> <p>Many thanks guys.</p> <p><em>EDIT</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>****</strong></p> <p>For future information check the python version, installed 2.7.3 and ran exactly same code as on linux without a problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload