using dhcp but IP is xx.xx.xx.0 - python

I am a newbie in fedora , and met this awful problem from I erase my /etc/sysconfig/ifcfg-enp0s25 by mistake.
And then my ip became an external ip xxx.xx.6.168.
To solve my ip to be an internal ip , I tried to rebuild the file by using # vi ifcfg-enp0s25 and insert:
DEVICE=enp0s25
NAME=enp0s25
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
then # service network restart
and my IP became:10.xx.xx.0
This IP could connect internal network successfully but get wrong to get own socket:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ldtp/__init__.py", line 593, in <module>
_populateNamespace(globals())
File "ldtp/__init__.py", line 247, in _populateNamespace
for method in client._client.system.listMethods():
File "/usr/lib64/python2.7/xmlrpclib.py", line 1243, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "ldtp/client.py", line 146, in request
self.send_content(h, request_body)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1459, in send_content
connection.endheaders(request_body)
File "/usr/lib64/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/usr/lib64/python2.7/httplib.py", line 897, in _send_output
self.send(msg)
File "/usr/lib64/python2.7/httplib.py", line 859, in send
self.connect()
File "/usr/lib64/python2.7/httplib.py", line 836, in connect
self.timeout, self.source_address)
File "/usr/lib64/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 113] No route to host
So how can I return to my past IP ??
Any advice is helpful!

I think there should be quite more informations in that file, check this page for further details. Hope this helps
Edit: since you can't visit the page i copied for you the example of that file, maybe here you will find some of the options you miss... maybe you had a static IP
HWADDR=REPLACE:WITH:YOUR:MAC:ADDRESS:HERE
TYPE=Ethernet
BOOTPROTO=none
IPADDR0=REPLACE.YOUR.IP.ADDRESS
PREFIX0=23
GATEWAY0=REPLACE.YOUR.GATEWAY.IP
DNS0=REPLACE.YOUR.DNS.IP
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
NAME=enp0s25
ONBOOT=yes
DOMAIN="REPLACE.YOUR.DOMAIN"
NM_CONTROLLED="no"

Related

HTTPS request with Python standard library

UPDATE: I managed to do a request with urllib2, but I'm still wondering what is happening here.
I would like to do a HTTPS request with Python.
This works fine with the requests module, but I don't want to use external dependencies, so I'd like to use the standard library.
httplib
When I follow this example I don't get a response. I get a timeout instead. I'm out of ideas as to what would cause this.
Code:
import requests
print requests.get('https://python.org')
from httplib import HTTPSConnection
conn = HTTPSConnection('www.python.org')
conn.request('GET', '/index.html')
print conn.getresponse()
Output:
<Response [200]>
Traceback (most recent call last):
File "test.py", line 6, in <module>
conn.request('GET', '/index.html')
File "C:\Python27\lib\httplib.py", line 1069, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1109, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 1065, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 892, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 854, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1282, in connect
HTTPConnection.connect(self)
File "C:\Python27\lib\httplib.py", line 831, in connect
self.timeout, self.source_address)
File "C:\Python27\lib\socket.py", line 575, in create_connection
raise err
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
urllib
This fails for a different (but possibly related) reason. Code:
import urllib
print urllib.urlopen("https://python.org")
Output:
Traceback (most recent call last):
File "test.py", line 10, in <module>
print urllib.urlopen("https://python.org")
File "C:\Python27\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Python27\lib\urllib.py", line 215, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 445, in open_https
h.endheaders(data)
File "C:\Python27\lib\httplib.py", line 1065, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 892, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 854, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1290, in connect
server_hostname=server_hostname)
File "C:\Python27\lib\ssl.py", line 369, in wrap_socket
_context=self)
File "C:\Python27\lib\ssl.py", line 599, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 828, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:727)
What is requests doing that makes it succeed where both of these libraries fail?
requests.get without timeout parameter mean no timeout at all.
httplib.HTTPSConnection accept parameter timeout in Python 2.6 and newer according to httplib docs. If your problem was caused by timeout, setting high enough timeout should help. Please try replacing:
conn = HTTPSConnection('www.python.org')
with:
conn = HTTPSConnection('www.python.org', timeout=300)
which will give 300 seconds (5 minutes) for processing.

connection error, from python in RCMES vagrant

I am trying to test python in RCMES vagrant, and I am getting connection error. can anyone please help to solve this
(OCW)vagrant#precise64:~/RCMES/test$ python test.py
Traceback (most recent call last):
File "test.py", line 49, in <module>
urllib.urlretrieve(FILE_LEADER + MODEL, MODEL)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/urllib.py", line 98, in urlretrieve
return opener.retrieve(url, filename, reporthook, data)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/urllib.py", line 350, in open_http
h.endheaders(data)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/httplib.py", line 897, in _send_output
self.send(msg)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/httplib.py", line 859, in send
self.connect()
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/httplib.py", line 836, in connect
self.timeout, self.source_address)
File "/home/vagrant/miniconda2/envs/OCW/lib/python2.7/socket.py", line 575, in create_connection
raise err
IOError: [Errno socket error] [Errno 110] Connection timed out

python2.7: [SSL: UNKNOWN_PROTOCOL] unknown protocol

I'm trying to install ROS from source.
When I execute the command of installation, I get such an error:
Traceback (most recent call last):
File "/home/zyh/ros_catkin_ws/install_isolated/share/ros/core/rosbuild/bin/download_checkmd5.py", line 126, in <module>
sys.exit(main())
File "/home/zyh/ros_catkin_ws/install_isolated/share/ros/core/rosbuild/bin/download_checkmd5.py", line 73, in main
urllib.urlretrieve('https://github.com/assimp/assimp/archive/v3.1.1.zip', dest)
File "/usr/lib/python2.7/urllib.py", line 98, in urlretrieve
return opener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 443, in open_https
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 1038, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 882, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 844, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1263, in connect
server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 363, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 611, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 840, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:661)
/home/zyh/ros_catkin_ws/install_isolated/share/mk/download_unpack_build.mk:37: recipe for target 'build/assimp-3.1.1/unpacked' failed
make[3]: *** [build/assimp-3.1.1/unpacked] Error 1
I don't know how to solve this issue. Maybe it's because I worked behind a proxy? If so, how to make urllib.urlretrieve work behind the proxy?
Add proxy settings to your global environment to see if it fixes the problem.
sudo gedit /etc/environment
Then add these two lines
http_proxy=http://your_proxy.com:443
https_proxy=https://your_proxy.com:443

My python script that i had tested and was working fine. Suddenly starts getting connection error

I wrote a few lines of python script to get links from my small site. I tested it, used it and was working fine but suddenly it starts generating connection error. I tried to use it on another site, it still generate same problem. I'm new to python, though. Help please!!! Thanks in advance
Part of the code and error message is as follow:
>>>import urllib,sgmllib
>>> f=urllib.urlopen("http://www.example.com")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Python27\lib\urllib.py", line 208, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 345, in open_http
h.endheaders(data)
File "C:\Python27\lib\httplib.py", line 991, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 844, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 806, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 787, in connect
self.timeout, self.source_address)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
IOError: [Errno socket error] [Errno 10061] No connection could be made becausethe target machine actively refused it
>>>
Thank you Johan, Shashank, bmhkim for your contributions.
I just figured out the cause of the problem now and the solution. It was caused by the proxy setting of the host running the code. So, resetting the proxy solve it.

wordpress with python on proxy server

This is a code for posting on a blog. It is my first try. I dont know what is the error in it. I am using proxy server and the error I'm getting is connection to server failed.
Can anyone help me out pleaseeeeeeeeee :/
import wordpresslib
# dummy data to be on safe side
data = "Post content, just ensuring data is not empty"
url='http://agneesa.wordpress.com/wordpress/xmlrpc.php'
# insert correct username and password
wp=wordpresslib.WordPressClient(url,'agnsa','pan#13579')
wp.selectBlog(0)
post=wordpresslib.WordPressPost()
post.title='try'
post.description=data
idPost=wp.newPost(post,True)
here is the traceback
here is the traceback file
Traceback (most recent call last):
File "C:\Python27\Lib\example.py", line 34, in <module>
post.categories = (wp.getCategoryIdFromName('Python'),)
File "C:\Python27\Lib\wordpresslib.py", line 332, in getCategoryIdFromName
for c in self.getCategoryList():
File "C:\Python27\Lib\wordpresslib.py", line 321, in getCategoryList
self.user, self.password)
File "C:\Python27\Lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\Lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\Lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\Lib\xmlrpclib.py", line 1292, in single_request
self.send_content(h, request_body)
File "C:\Python27\Lib\xmlrpclib.py", line 1439, in send_content
connection.endheaders(request_body)
File "C:\Python27\Lib\httplib.py", line 954, in endheaders
self._send_output(message_body)
File "C:\Python27\Lib\httplib.py", line 814, in _send_output
self.send(msg)
File "C:\Python27\Lib\httplib.py", line 776, in send
self.connect()
File "C:\Python27\Lib\httplib.py", line 757, in connect
self.timeout, self.source_address)
File "socket.py", line 571, in create_connection
raise err
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
From the looks of your site, the url you posted returns a 404 (not actually there). However, this does seem ready to receive POST requests: http://agneesa.wordpress.com/xmlrpc.php
I suggest you try checking that URL for accuracy.
This is what I get when I try your code with your original URL:
xmlrpclib.ProtocolError: <ProtocolError for \
agneesa.wordpress.com/wordpress/xmlrpc.php: 404 Not Found>
This is what I get when I try it with the modified URL:
wordpresslib.WordPressException: \
<WordPressException 403: 'Bad login/pass combination.'>
... obviously because thats not your real account info. In a nutshell, its possible your proxy could also be contributing to problems if its not set up to properly forward the request, but without us knowing specifics about your proxy config, there is no way to know for sure.

Categories