Στις 5/7/2013 12:21 μμ, ο/η Dave Angel έγραψε:
On 07/05/2013 04:49 AM, Νίκος Gr33k wrote:
<SNIP>
I don't think running it via 'cli' would help much, since its a
cgi-script and ip addr function have no meaning calling them in plain
our of a cgi environment but here it is:
No idea how to parse "have no meaning calling them in plain our of a cgi
environment"
Python 3.3.2 (default, Jun 3 2013, 16:18:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> remadd = os.environ('REMOVE_ADDR')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '_Environ' object is not callable
But there were two problems with the code you faithfully copied from my
earlier post. One was already pointed out by feedthetroll, that I
accidentally changed REMOTE_ADDR to REMOVE_ADDR.
The other one is perhaps more subtle; I replaced square brackets with
parentheses.
So try again with:
>>> import os
>>> remadd = os.environ['REMOTE_ADDR']
I get an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/os.py", line 669, in __getitem__
value = self._data[self.encodekey(key)]
KeyError: b'REMOTE_ADDR'
but presumably your machine actually has such an environment variable.
Isn't that mistake something you could easily have caught? Or were you
just blindly pasting my bugs without understanding what I was trying to
do with refactoring?
Anyway, I can't see any reason why the rest of the sequence shouldn't
behave identically from a terminal as it does in CGI.
Yes i didnt see your typo and i have corrected it:
try:
remadd = os.environ('REMOTE_ADDR')
tuple3 = socket.gethostbyaddr(remadd)
host = tuple3[0]
except Exception as e:
host = repr(e)
Ima still receiving the same kind of erro as i did with cli as well.
You can view the error in the very first line here:
http://superhost.gr/?show=log&page=index.html
which yields: TypeError("'_Environ' object is not callable",)
--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list