I wanted to connect to a extender for a Wi-Fi project, but I don't know if I can connect to an extender using the Fabric module for Python...
I was trying to connect to a server using it's name, but I'm sure that the name is wrong, but I don't know if I'm connecting wrong. Here is my code:
from fabric import Connection
node = Connection('KIN-AP23')
letsgo = node.run('help')
I don't know how to connect since I got this error:
Traceback (most recent call last):
File "main.py", line 5, in <module>
letsgo = node.run('help')
File "<decorator-gen-3>", line 2, in run
File "/home/runner/FLIPPER1/venv/lib/python3.8/site-packages/fabric/connection.py", line 29, in opens
self.open()
File "/home/runner/FLIPPER1/venv/lib/python3.8/site-packages/fabric/connection.py", line 636, in open
self.client.connect(**kwargs)
File "/home/runner/FLIPPER1/venv/lib/python3.8/site-packages/paramiko/client.py", line 349, in connect
to_try = list(self._families_and_addresses(hostname, port))
File "/home/runner/FLIPPER1/venv/lib/python3.8/site-packages/paramiko/client.py", line 203, in _families_and_addresses
addrinfos = socket.getaddrinfo(
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
I know for sure that's not the right name but is there any extra stuff I have to do, if so tell me, if not still tell me how to do it!
Related
When I was trying out a tutorial in the internet, I failed to connect to the mqtt broker - anyone can help me on that?
import paho.mqtt.client as mqtt
broker_url = "mqtt.eclipse.org"
broker_port = 1883
client = mqtt.Client()
client.connect(broker_url, broker_port)
print(client)
Traceback (most recent call last):
File "C:\Workspace\FI Systemintegration\Python\MitarbeiterVerwaltung\rpi\connect.py", line 6, in <module>
client.connect(broker_url, broker_port)
File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\site-packages \paho\mqtt\client.py", line 914, in connect
return self.reconnect()
File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\site-packages \paho\mqtt\client.py", line 1044, in reconnect
sock = self._create_socket_connection()
File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\site-packages \paho\mqtt\client.py", line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\socket.py", line 824, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
The service does not exist at mqtt.eclipse.org. It was either used only as an example or the service is no longer available.
You should use another MQTT instance, maybe run a local instance instead.
I'm trying to traverse an ftp directory using FTPwalker, however I cannot connect.
The current call is being used:
walker = ftpwalker(server_name="hostname", url="ftp://username:password#hostname")
However walker.check_state() gives:
>> walker.check_state()
Find leading...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 100, in check_state
self.path_not_exit(False)
File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 157, in path_not_exit
self.m_walker.Process_dispatcher(False)
File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 82, in Process_dispatcher
leadings = self.find_leading_dirs(self.root)
File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 37, in find_leading_dirs
files, dirs = self.run_object.find_leading(top)
File "/usr/lib/python3.4/site-packages/FTPwalker/traverse.py", line 75, in find_leading
conn = ftplib.FTP(self.server_url)
File "/usr/lib64/python3.4/ftplib.py", line 118, in __init__
self.connect(host)
File "/usr/lib64/python3.4/ftplib.py", line 153, in connect
source_address=self.source_address)
File "/usr/lib64/python3.4/socket.py", line 498, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib64/python3.4/socket.py", line 537, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
Is the url parameter entered here in the correct format? Pinging the hostname works.
While the parameter is misleadingly named url, the official example shows pretty clearly, that the value should actually be a plain hostname:
from FTPwalker.runwalker import ftpwalker
walker = ftpwalker("Uniprot", "ftp.uniprot.org")
walker.check_state()
In the the end, the value goes to ftplib.FTP.connect, which takes "hostname".
I need to create simple code that will upload a .csv file to an FTP server. The code is below.
import ftplib
import os
import sys
sourceFilePath = '/home/user/dir/'
filename = 'testing.csv'
destinationDirectory = 'anotherDirectory'
server = 'ftp://12.123.12.234'
username = 'aUser'
password = 'passwd1234'
myFTP = ftplib.FTP(server, username, password)
myFTP.cwd('/anotherDirectory/')
myFTP.storbinary('STOR '+filename, open(filename,'rb'))
myFTP.quit()
However, when I run the code, I get the following error:
Traceback (most recent call last):
File "./UploadToFTP.py", line 20, in <module>
File "./UploadToFTP.py", line 13, in uploadFileFTP
myFTP = ftplib.FTP(server, username, password)
File "/usr/lib64/python2.6/ftplib.py", line 119, in __init__
self.connect(host)
File "/usr/lib64/python2.6/ftplib.py", line 134, in connect
self.sock = socket.create_connection((self.host, self.port),
self.timeout)
File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -3] Temporary failure in name resolution
Has anyone seen this before? It seems rather generic to me and doesn't tell me much. So far as other code I've seen performing this same task, I don't have any currently visible errors. Any help would be appreciated.
The host argument of ftplib.FTP constructor is a hostname/IP address, not a URL.
So this is wrong:
server = 'ftp://12.123.12.234'
It should be:
server = '12.123.12.234'
If your URL contains a custom port, see Python ftplib - specify port.
I'm learning Python and I tried using the FTPLib module for Python with this code:
import ftplib
connect = ftplib.FTP('ftp://www.website.com')
connect.login = ('username', 'password')
data = []
connect.dir(data.append)
connect.quit()
for line in data:
print line
(I'm aware that the website, username and password is incorrect, I used my website data which I don't want to share) I received the following error after running the code:
Traceback (most recent call last):
File "ftp.py", line 3, in <module>
ftp = FTP('ftp://www.website.com') # connect to host, default port
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 120, in __init__
self.connect(host)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 135, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Just to clarify, I'm using Python 2.7 on a Mac. I don't think there is anymore details I could share. Thank you for your help!
Thanks Joel Hinz, I just needed to remove 'ftp://' from my hostname. Thanks!
I am working on file transfer in python. I've been searching a lot but still haven't found a simple demo of a working ftp client-server using pyftpdlib. I think this library is very useful but I don't know how to start using it.
Thank you so much for any help!
EDIT:
OK, I followed the tutorial. My goal is to be able to send/receive files within local machine first.
I run the basic_ftpd.py and get this:
[I 14-07-09 15:08:27] >>> starting FTP server on 127.0.0.1:2121, pid=7000 <<<
[I 14-07-09 15:08:27] poller: <class 'pyftpdlib.ioloop.Select'>
[I 14-07-09 15:08:27] masquerade (NAT) address: None
[I 14-07-09 15:08:27] passive ports: None
Then I run winnt_ftpd.py and I get error:
Traceback (most recent call last):
File "***\lib\winnt_ftpd.py", line 41, in <module>
from pyftpdlib.authorizers import WindowsAuthorizer
ImportError: cannot import name WindowsAuthorizer
Let's assume that I want to send some file in C:/share and in local address I think it should be 127.0.0.1:2121 or localhost:2121. Then from client side I want to get directory listing:
import ftplib
ftp = ftplib.FTP("127.0.0.1:2121")
ftp.login("user", "12345")
data = []
ftp.dir(data.append)
ftp.quit()
for line in data:
print "-", line
But this is not working, I get following error:
Traceback (most recent call last):
File "C:\Users\***\src\client1.py", line 8, in <module>
ftp = ftplib.FTP("127.0.0.1:2121")
File "C:\Python27\lib\ftplib.py", line 117, in __init__
self.connect(host)
File "C:\Python27\lib\ftplib.py", line 132, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout)
File "C:\Python27\lib\socket.py", line 551, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
EDIT:
I changed
ftp = ftplib.FTP("127.0.0.1:2121")
to
ftp = ftplib.FTP("127.0.0.1")
Then I get this error:
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
Any suggestion?
What about trying this:
conn = ftplib.FTP()
conn.connect('127.0.0.1', 2121)
conn.login('user','12345')
the FTP() constructor accept only the hostname or IP address, instead if you pass nothing and then you configure all with connect() you can pass a tuple with (IP, port)
This should make the trick