TypeError with server.init

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
LarryTru
Posts: 26
Joined: Wed Aug 06, 2014 5:46 am

TypeError with server.init

Post by LarryTru » Mon Nov 02, 2015 6:41 am

Hello,

I want to change the default userid and password for the ftp and telnet services.

I tried (via REPL) this example lifted directly from the Quick Reference page:

Code: Select all

from network import server

# init with new user, password and seconds timeout
server = server.init(login=('user', 'password'), timeout=60)
but I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument num/types mismatch
The server page specifies:
server.init(*, login=('micro', 'python'), timeout=300)
I'm not sure what the wildcard is supposed to signify here; something important?


I tried to go to the source code to investigate, but could't locate it after a few minutes of looking. Probably right under my nose, but effectively invisible to me at this time.

Any help appreciated!

Thx,

Larry

LarryTru
Posts: 26
Joined: Wed Aug 06, 2014 5:46 am

Re: TypeError with server.init

Post by LarryTru » Mon Nov 02, 2015 6:47 am

BTW, I am using v1.1.0

Larry

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: TypeError with server.init

Post by danicampora » Mon Nov 02, 2015 11:26 am

Hi Larry,

The init method is an instance method, so you need to construct the object first (see the constructor reference).

Cheers,
Daniel

LarryTru
Posts: 26
Joined: Wed Aug 06, 2014 5:46 am

Re: TypeError with server.init

Post by LarryTru » Tue Nov 03, 2015 3:41 am

So, the example on the quick reference page is wrong and needs to be corrected I assume?

I'm still confused about exactly what is happening with this class and methods. Does creating and initializing a server object with the server class create a new server or does it "connect" to the one that is already running in WiPy?

Thx,

Larry

LarryTru
Posts: 26
Joined: Wed Aug 06, 2014 5:46 am

Re: TypeError with server.init

Post by LarryTru » Tue Nov 03, 2015 6:48 am

FYI, I was able to get the Telnet and FTP services to use my own userid and password.

I used this code in boot.py to do it:

Code: Select all

# Import Server Class
from network import server

# Initialize Telnet & FTP services with credentials
srvr_obj = server()
srvr_obj.init(login=('MyUserID', 'MyPassword'), timeout=600)
The documentation for this on the "Quick Reference" page is definitely wrong and I'm still not sure if this is modifying the pre-existing services or creating new ones. But it does work.

Post Reply