IP Address not displayed

325 views
Skip to first unread message

James Young

unread,
Jun 11, 2022, 8:25:40 AM6/11/22
to PicoChess
Ok I have had my PI 3000 for a couple of years and thought that the System IP address was just a place holder until I saw a video where someone demonstrated it actually works (SMH) all this time I have located the IP through DNS on my router initially...SO what is the secret to get my IP Address displayed on the Pi 3000.

TIA

RandyR

unread,
Jun 11, 2022, 12:49:25 PM6/11/22
to PicoChess
Not sure how your are wired up, but if PicoChess is running and the Pi is connected to the network, you should be able to use the buttons to access the System/information menu to see the ip address.

Randy

James Young

unread,
Jun 11, 2022, 5:39:12 PM6/11/22
to PicoChess
I tried wired and wireless and for as long as I had this box the system's IP address has never displayed no matter what version of code I run on the PI 3000. I just looking to see if there is an off-on switch in the code.

Randy Reade

unread,
Jun 11, 2022, 6:39:25 PM6/11/22
to pico...@googlegroups.com
How is your clock attached?

--
You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/zZzTUXJynkw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/c1e663c7-892b-4f0a-bd53-405a3f40e6edn%40googlegroups.com.

James Young

unread,
Jun 11, 2022, 7:47:01 PM6/11/22
to PicoChess
I am assuming when playing with the DGT board...Bluetooth

Randy Reade

unread,
Jun 11, 2022, 8:54:44 PM6/11/22
to pico...@googlegroups.com
I guess I'm just not understanding. I assume you don't have a DGTPi. Are you just running PicoChess on a Pi (which model?) connected to the DGT board via Bluetooth? And how is your DGT3000 clock connected? Are you using the clock cable to connect it to the board?

You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/8d24b567-28c7-43a0-8b5b-289be06cb317n%40googlegroups.com.

James Young

unread,
Jun 11, 2022, 9:08:25 PM6/11/22
to PicoChess

Randy Reade

unread,
Jun 12, 2022, 12:13:39 PM6/12/22
to pico...@googlegroups.com
Hmmm, that's strange. I'll check my DGTPi and see if it shows my ip address.

James Young

unread,
Jun 12, 2022, 12:16:49 PM6/12/22
to PicoChess
Even with a static address given NADA nothing shows up

RandyR

unread,
Jun 12, 2022, 2:01:50 PM6/12/22
to PicoChess
So I tested it using the latest v3 image and the ip address is displayed. But with the version that shipped with the DGTPi (v0.9l) it gives the 'no ip addr' text. The issue is with an outdated url which determines your geo-location, in the utilities.py file. If you want to fix it, use the nano editor via ssh:

cd /opt/picochess
sudo service picochess stop
sudo nano utilities.py

Use the arrow keys to scroll down to the 'def get_location():' code, somewhere after line 250 depending on your PicoChess version (Alt-C will display the line number location of the cursor at the bottom of the nano window).

Then change the url in the 'response =' line to this:

        response = urllib.request.urlopen('http://will6.de/freegeoip')

Don't change the indentation (8 spaces here) as Python is very particular bout this!  :^)
And notice the http not https.

Save your edits:

Ctrl-O
<enter>
Ctrl-X

And restart PicoChess:

sudo service picochess start

Randy

James Young

unread,
Jun 12, 2022, 2:15:15 PM6/12/22
to PicoChess
Already there now I am really confused
def get_location():
    """Return the location of the user and the external and interal ip adr."""
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('8.8.8.8', 80))
        int_ip = sock.getsockname()[0]
        sock.close()

        response = urllib.request.urlopen('http://will6.de/freegeoip')
        j = json.loads(response.read().decode())
        country_name = j['country_name'] + ' ' if 'country_name' in j else ''
        country_code = j['country_code'] + ' ' if 'country_code' in j else ''
        ext_ip = j['ip'] if 'ip' in j else None
        city = j['city'] + ', ' if 'city' in j else ''
        return (city + country_name + country_code).strip(), ext_ip, int_ip
    except:
        return '?', None, None


RandyR

unread,
Jun 12, 2022, 2:25:58 PM6/12/22
to PicoChess
If you put http://will6.de/freegeoip into a browser, does it show your location? Or just click on that link.

James Young

unread,
Jun 12, 2022, 3:14:55 PM6/12/22
to PicoChess
it does indeed and gives my External address as the ip

Randy Reade

unread,
Jun 12, 2022, 3:22:27 PM6/12/22
to pico...@googlegroups.com
Ok. So it's not hanging there.

Let's see if we can run the code that gets the internal IP address. We'll enter some commands into the python interpreter:

Using ssh again, launch python3:

python3

Then enter the following 5 individual commands at the >>> prompt:

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(('8.8.8.8', 80))
int_ip = sock.getsockname()[0]
print(int_ip)

Does it display the ip address of your DGTPi?




--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

RandyR

unread,
Jun 12, 2022, 3:26:21 PM6/12/22
to PicoChess
Ctrl-D gets you out of the interpreter.

James Young

unread,
Jun 12, 2022, 3:32:38 PM6/12/22
to PicoChess
I am on it, give me 10 minutes 

James Young

unread,
Jun 12, 2022, 3:37:11 PM6/12/22
to PicoChess
yes it comes back with my internal address

RandyR

unread,
Jun 12, 2022, 3:53:51 PM6/12/22
to PicoChess
What exactly do you see on the clock when you select the System/Information/IP adr menu?

James Young

unread,
Jun 12, 2022, 3:58:16 PM6/12/22
to PicoChess
NO IP ADDRESS

RandyR

unread,
Jun 12, 2022, 4:07:38 PM6/12/22
to PicoChess
Well, I'm out of ideas. Perhaps a bad image? Are you using one of mine? I would suggest the Lite image for the DGTPi.

James Young

unread,
Jun 12, 2022, 4:19:21 PM6/12/22
to PicoChess
I am indeed running the lite version and I have the desktop as well and the results are the same NO IP ADDRESS everything else appears to be fine. Thanks for trying Randy.. While I have you is there a list of all the Switches/options for the picochess.in examples tutor-comments = all? are there other variables not listed in the documentation?  I have seen in one file pi@picochess:  not sure what it is used for....I am just interested in all the available options ( the undocumented enhancement as we say in the IT world.

James Young

unread,
Jun 12, 2022, 4:25:48 PM6/12/22
to PicoChess
Also Shiv was working on bringing his server back online that populates the Book information for the Pico Web server, is there a setting I need to make to access the information or is it written in the code
?

RandyR

unread,
Jun 12, 2022, 4:30:41 PM6/12/22
to PicoChess
I think they are all documented in the picochess.ini file itself.

The book info will populate once Shiv fixes it. If there are any code changes, he'll let us know.

James Young

unread,
Jun 12, 2022, 4:34:48 PM6/12/22
to PicoChess
cool thanks again for your help!!! iF i find a solution for the System Ip i will let you know.

RandyR

unread,
Jun 12, 2022, 4:38:03 PM6/12/22
to PicoChess
Yes, it will be interesting to see what fixes it. Maybe someone else has an idea.

Good luck.

Randy

Marc Hamilton

unread,
Jun 13, 2022, 2:07:31 AM6/13/22
to PicoChess
ip.jpg

I'm getting the IP address displayed... Mark

Marc Hamilton

unread,
Jun 13, 2022, 2:20:21 AM6/13/22
to PicoChess
Same here... I get "No Ip Addr" when selecting the menu option
Message has been deleted

Scally

unread,
Jun 13, 2022, 6:12:45 AM6/13/22
to PicoChess
Hi,

Mine on V3 is working as designed, note no board is attached …

James Young

unread,
Jun 13, 2022, 7:06:28 AM6/13/22
to PicoChess
Board attached, not attached even with a statically configured address, the response is the same NO IP ADDRESS; I am curious, though, what is the difference between the standard Pi 3000 and yours, the limited edition?

Scally

unread,
Jun 13, 2022, 7:23:49 AM6/13/22
to PicoChess
There is no difference, I just bought the DGT3000 Limited Edition and swapped the tops to match my Revelation II. My base is customised too with built in speaker etc kindly provided by Wilhelm. There are many posts on here showing the build etc …

As to why you don’t see the IP address, I’m stumped too. Not that it should make any difference but have you tried an Ethernet cable directly from your router to your DGT Pi?

Al.

James Young

unread,
Jun 13, 2022, 7:45:40 AM6/13/22
to PicoChess

Correct wired and wireless 

RandyR

unread,
Jun 13, 2022, 10:14:38 AM6/13/22
to PicoChess
Jim/Marc,

Do you have the default entry 'location = auto' in your picochess.ini file and is your location shown in the web server interface?

Mark HL

unread,
Jun 13, 2022, 10:19:58 AM6/13/22
to pico...@googlegroups.com
I can answer that without looking.

No, I do not have it set to auto because I didn't want the PGN data to disclose my location. I have a manual entry of 'Washington USA' 
I'll set it to auto and see if it shows my IP.

Sent from my Samsung Tab S7

From: pico...@googlegroups.com <pico...@googlegroups.com> on behalf of RandyR <randy...@gmail.com>
Sent: Monday, June 13, 2022 7:14:38 AM
To: PicoChess <pico...@googlegroups.com>
Subject: Re: IP Address not displayed
 

Mark HL

unread,
Jun 13, 2022, 10:24:35 AM6/13/22
to pico...@googlegroups.com
Setting it back to 'auto' fixed it, I can now see the IP. 

Sent from my Samsung Tab S7

From: Mark HL <m371...@gmail.com>
Sent: Monday, June 13, 2022 7:19:55 AM
To: pico...@googlegroups.com <pico...@googlegroups.com>

RandyR

unread,
Jun 13, 2022, 10:30:29 AM6/13/22
to PicoChess
Mark, can you test 'Washington_USA'?

Mark HL

unread,
Jun 13, 2022, 10:32:58 AM6/13/22
to pico...@googlegroups.com
I don't understand the question. Should I hard code it into 'utilities.py' ?

Sent from my Samsung Tab S7

Sent: Monday, June 13, 2022 7:30:29 AM
You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/zZzTUXJynkw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/00ebfc2e-e482-43b7-a02f-f3044961bcc1n%40googlegroups.com.

Mark HL

unread,
Jun 13, 2022, 10:37:17 AM6/13/22
to pico...@googlegroups.com
Okay... you mean no spaces in the location data and change picochess.ini. I'll get back to you

Sent from my Samsung Tab S7

From: Mark HL <m371...@gmail.com>
Sent: Monday, June 13, 2022 7:32:55 AM

RandyR

unread,
Jun 13, 2022, 10:39:08 AM6/13/22
to PicoChess
Yeah, sorry I wasn't clear.

Mark HL

unread,
Jun 13, 2022, 10:42:26 AM6/13/22
to pico...@googlegroups.com
Yes, if I take the spaces out of the location data (Washington_USA versus Washington, USA) the IP address IS displayed. 

Thank you... 

Sent from my Samsung Tab S7

Sent: Monday, June 13, 2022 7:39:08 AM

To: PicoChess <pico...@googlegroups.com>
Subject: Re: IP Address not displayed
Yeah, sorry I wasn't clear.

--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

RandyR

unread,
Jun 13, 2022, 10:46:30 AM6/13/22
to PicoChess
Your initial post said 'Washington USA' not 'Washington, USA'. Did you have a comma in there?

RandyR

unread,
Jun 13, 2022, 10:50:45 AM6/13/22
to PicoChess
Hmmm, I tested Washington, USA and it works for me. Maybe a reboot is needed...

RandyR

unread,
Jun 13, 2022, 10:52:34 AM6/13/22
to PicoChess
Nope. Reboot made no difference. I still get the ip address. Is it possible you have the 'location =' entry in 2 places?

m371...@gmail.com

unread,
Jun 13, 2022, 10:58:04 AM6/13/22
to pico...@googlegroups.com

Okay this is a bit strange… I was not seeing my IP address until I changed the location entry to ‘auto’. However, I replaced the Micro SD card with another one with the exact same flash

and it IS showing my IP address with the location data entered as Washington, USA.

 

 

Sent from Mail for Windows

 

From: RandyR
Sent: Monday, June 13, 2022 7:52 AM
To: PicoChess
Subject: Re: IP Address not displayed

 

Nope. Reboot made no difference. I still get the ip address. Is it possible you have the 'location =' entry in 2 places?

On Monday, June 13, 2022 at 9:50:45 AM UTC-5 RandyR wrote:

Hmmm, I tested Washington, USA and it works for me. Maybe a reboot is needed...

On Monday, June 13, 2022 at 9:46:30 AM UTC-5 RandyR wrote:

Your initial post said 'Washington USA' not 'Washington, USA'. Did you have a comma in there?

On Monday, June 13, 2022 at 9:42:26 AM UTC-5 m371...@gmail.com wrote:

Yes, if I take the spaces out of the location data (Washington_USA versus Washington, USA) the IP address IS displayed. 

 

Thank you... 

 

Sent from my Samsung Tab S7

Sent: Monday, June 13, 2022 7:39:08 AM


To: PicoChess <pico...@googlegroups.com>
Subject: Re: IP Address not displayed

Yeah, sorry I wasn't clear.

--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

RandyR

unread,
Jun 13, 2022, 11:04:12 AM6/13/22
to PicoChess
There might be something wrong with the picochess.ini file. Perhaps copy over a clean, un-edited version of picochess.ini to that 'bad' sd card, then make the location change.

m371...@gmail.com

unread,
Jun 13, 2022, 11:05:50 AM6/13/22
to pico...@googlegroups.com

I just set the location back to ‘Washington, USA’ on the card that would previously not show the IP and it now shows it.   

 

 

Sent from Mail for Windows

 

From: RandyR
Sent: Monday, June 13, 2022 8:04 AM
To: PicoChess
Subject: Re: IP Address not displayed

 

There might be something wrong with the picochess.ini file. Perhaps copy over a clean, un-edited version of picochess.ini to that 'bad' sd card, then make the location change.

--

You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

RandyR

unread,
Jun 13, 2022, 11:08:49 AM6/13/22
to PicoChess
Did you by chance edit the picochess.ini file on Windows initially? I always use nano directly on the Pi.

RandyR

unread,
Jun 13, 2022, 11:45:07 AM6/13/22
to PicoChess
Jim, I think you cross-posted so I'll reply here.

You edit the same way I do so that shouldn't be the issue (although I usually use a Linux laptop to ssh in), but I still suspect some corruption in your picochess.ini file. When you get a chance, can you either burn a new Lite image, make no changes and connect using an ethernet cable, then test; or copy over a clean picochess.ini file from the image (perhaps using scp) then test? I'll attach the file just in case.
picochess.ini

James Young

unread,
Jun 13, 2022, 12:04:42 PM6/13/22
to PicoChess
Reimaged the box yesterday but did not check the IP address prior to making my ini changes. I have some spare SD cards, I will set it and run no updates and will get back to you as soon as the process is completed...standby

James Young

unread,
Jun 13, 2022, 12:25:49 PM6/13/22
to PicoChess
Steps taken

Imaged SD using Lite.img
used Win32Disklmager to load image
Cabled PI 3000
connected Pi Monitor
Powered on the box
Logged in
ran ip a command (has local address displayed) 
navigated to clock System/information/IP addr ( no IP address is displayed)



James Young

unread,
Jun 13, 2022, 12:34:46 PM6/13/22
to PicoChess
seen at login with newly imaged Sd

Linux picochess 5.10.92-v7+ #1514 SMP Mon Jan 17 17:36:39 GMT 2022 armv7l

James Young

unread,
Jun 13, 2022, 12:39:26 PM6/13/22
to PicoChess

RandyR

unread,
Jun 13, 2022, 1:18:24 PM6/13/22
to PicoChess
Thanks.

If you feel comfortable, can you edit the picochess.py file (make a backup first): 

cd /opt/picochess
sudo service picochess stop
sudo cp picochess.py picochess.py.bak
sudo nano picochess.py

Around line 779, comment out (##) a few lines:

    def display_ip_info():
##        nonlocal set_location
        """Fire an IP_INFO message with the IP adr."""
        location, ext_ip, int_ip = get_location()
       
##        if set_location == 'auto': ##molli
##            pass
##        else:
##            location = set_location

        info = {'location': location, 'ext_ip': ext_ip, 'int_ip': int_ip, 'version': version}
        DisplayMsg.show(Message.IP_INFO(info=info))

Save and reboot:

Ctrl-O
<enter>
Ctrl-X
sudo reboot

Test.

To go back to the original picochess.py:

cd /opt/picochess
sudo mv picochess.py.bak picochess.py

RandyR

unread,
Jun 13, 2022, 1:24:17 PM6/13/22
to PicoChess
Jim,

I just thought of something else. Does your location name have non-English characters or any accents, etc?

James Young

unread,
Jun 13, 2022, 2:19:22 PM6/13/22
to PicoChess
Just saw this will edit and get back to you

James Young

unread,
Jun 13, 2022, 2:54:50 PM6/13/22
to PicoChess

no change...is this a firmware issue? I mean I have not seen this box ever display and address

RandyR

unread,
Jun 13, 2022, 4:47:38 PM6/13/22
to PicoChess
Sorry, life called.

No. Updated firmware is stored on the SD card unless you have a Pi4. Let's see if the python code is failing. Run the 2 attached python files on the Pi, in the home folder. E.g.:

python3 test.py

Here is the code:

test.py:

import socket
import json
import urllib.request

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(('8.8.8.8', 80))
int_ip = sock.getsockname()[0]
sock.close()
response = urllib.request.urlopen('http://will6.de/freegeoip')
j = json.loads(response.read().decode())
country_name = j['country_name'] + ' ' if 'country_name' in j else ''
country_code = j['country_code'] + ' ' if 'country_code' in j else ''
ext_ip = j['ip'] if 'ip' in j else None
city = j['city'] + ', ' if 'city' in j else ''
print((city + country_name + country_code).strip(), ext_ip, int_ip)
 
test2.py:

import socket
import json
import urllib.request

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(('8.8.8.8', 80))
int_ip = sock.getsockname()[0]
sock.close()
response = urllib.request.urlopen('http://will6.de/freegeoip')
j = json.loads(response.read().decode())
country_name = j['country_name'] + ' ' if 'country_name' in j else ''
country_code = j['country_code'] + ' ' if 'country_code' in j else ''
ext_ip = j['IPv4'] if 'IPv4' in j else None

city = j['city'] + ', ' if 'city' in j else ''
print((city + country_name + country_code).strip(), ext_ip, int_ip)

What do you see?

test.py
test2.py

RandyR

unread,
Jun 13, 2022, 4:50:31 PM6/13/22
to PicoChess
You can use the interpreter as well.

James Young

unread,
Jun 13, 2022, 5:51:50 PM6/13/22
to PicoChess
is there a root login in the  sshd_config edit? trying to SCP the files over and I get permission denied

James Young

unread,
Jun 13, 2022, 5:55:10 PM6/13/22
to PicoChess
found it

James Young

unread,
Jun 13, 2022, 6:05:19 PM6/13/22
to PicoChess
pi@picochess:/home $ python3 test.py
Traceback (most recent call last):
  File "/home/test.py", line 13, in <module>

    city = j['city'] + ', ' if 'city' in j else ''
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

pi@picochess:/home $ python3 test2.py
Traceback (most recent call last):
  File "/home/test2.py", line 13, in <module>

    city = j['city'] + ', ' if 'city' in j else ''
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
pi@picochess:/home $

Randy Reade

unread,
Jun 13, 2022, 6:24:53 PM6/13/22
to pico...@googlegroups.com
Sounds like a problem converting quotes. The script shouldn't fail. Can you verify using nano? 

--
You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/zZzTUXJynkw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/ba8311df-ad95-4e84-93ee-31d8bd61713fn%40googlegroups.com.

James Young

unread,
Jun 13, 2022, 6:34:06 PM6/13/22
to PicoChess

James Young

unread,
Jun 13, 2022, 6:36:50 PM6/13/22
to PicoChess

James Young

unread,
Jun 13, 2022, 6:43:37 PM6/13/22
to PicoChess
should there be a bracket at the end or should the leading bracket be removed?

print((city + country_name + country_code).strip(), ext_ip, int_ip)

the rest of the code looks good

James Young

unread,
Jun 13, 2022, 6:59:34 PM6/13/22
to PicoChess
line 15 is resolved line 13 I can see nothing

Traceback (most recent call last):
  File "/home/test.py", line 13, in <module>
    city = j['city'] + ', ' if 'city' in j else ''
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    

city = j['city'] + ', ' if 'city' in j else '' (line from untility.py)

Randy Reade

unread,
Jun 13, 2022, 6:59:53 PM6/13/22
to pico...@googlegroups.com
No. But it looks like a few lines are wrapped. Check the country_name, country_code and print lines.

Randy Reade

unread,
Jun 13, 2022, 7:02:36 PM6/13/22
to pico...@googlegroups.com
Note that it isn't a double quote at the end, it's 2 single quotes.

Randy Reade

unread,
Jun 13, 2022, 7:04:40 PM6/13/22
to pico...@googlegroups.com
Ok. I looked again at the pics you sent and the quotes look ok. Just the word wrap seems suspect.

Randy Reade

unread,
Jun 13, 2022, 7:06:45 PM6/13/22
to pico...@googlegroups.com
And I just realized you are in the /home folder. I meant the home folder of the user pi, which is /home/pi. 😁

Randy Reade

unread,
Jun 13, 2022, 7:13:40 PM6/13/22
to pico...@googlegroups.com
Ok. I think the word wrap is just on the screen since the city line is line 13. I'll retest on the DGTPi in a bit and let you know if there is a problem with what I sent.

Might be worth using the interpreter in the meantime.

James Young

unread,
Jun 13, 2022, 7:18:33 PM6/13/22
to PicoChess
I think that is where they are see below

pi@picochess:~ $ cd /home
pi@picochess:/home $ ls
pi  test2.py  test.py
pi@picochess:/home $

James Young

unread,
Jun 13, 2022, 7:22:02 PM6/13/22
to PicoChess

Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
>>> print((city + country_name + country_code).strip(), ext_ip, int_ip)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'city' is not defined

James Young

unread,
Jun 13, 2022, 7:31:00 PM6/13/22
to PicoChess
city not defined, is there a variable missing?

Randy Reade

unread,
Jun 13, 2022, 7:34:46 PM6/13/22
to pico...@googlegroups.com
When you go here:


do you see the word 'city' in the string? If so, is there a city name after the : ?


You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/9c7c4e49-041e-4c0e-be2a-933dbf30341cn%40googlegroups.com.

Randy Reade

unread,
Jun 13, 2022, 7:36:43 PM6/13/22
to pico...@googlegroups.com
The files should be in the pi folder.

You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picochess/9c7c4e49-041e-4c0e-be2a-933dbf30341cn%40googlegroups.com.

James Young

unread,
Jun 13, 2022, 7:50:35 PM6/13/22
to PicoChess
ok moved them and waiting for responses it almost appears hung.
^CTraceback (most recent call last):
  File "/home/pi/test.py", line 8, in <module>

    response = urllib.request.urlopen('http://will6.de/freegeoip')
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 921, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.9/socket.py", line 831, in create_connection
    sock.connect(sa)
KeyboardInterrupt

James Young

unread,
Jun 13, 2022, 7:51:19 PM6/13/22
to PicoChess
Traceback (most recent call last):
  File "/usr/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 921, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.9/socket.py", line 843, in create_connection
    raise err

  File "/usr/lib/python3.9/socket.py", line 831, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "/home/pi/test2.py", line 8, in <module>

    response = urllib.request.urlopen('http://will6.de/freegeoip')
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

Randy Reade

unread,
Jun 13, 2022, 8:48:02 PM6/13/22
to pico...@googlegroups.com
Ok. Something is not right. I just used scp to transfer the files to the DGTPi and they both ran fine. Now, I'm using a Linux laptop so I know there isn't any change to the file by Windows before it is sent. I'm wondering if Windows is saving them in dos format when they need to be unicode (UTF-8). The command I used was:

scp test* pi@<ip address>:~/             <---- enter the ip address of your DGTPi

Then on the Pi:

cd ~
python3 test.py
python3 test2.py

Maybe I should try from Windows to see if that's the issue you are having.

Also, you didn't answer this:

When you go here:


do you see the word 'city' in the string? If so, is there a city name after the : ?


RandyR

unread,
Jun 13, 2022, 8:58:57 PM6/13/22
to PicoChess
I just tested using Powershell in Windows 11 and no errors.

Are you by chance using a NAT router?

James Young

unread,
Jun 13, 2022, 9:16:29 PM6/13/22
to PicoChess
"country_code":"US","country_name":"United States","city":null,"postal":null,"latitude":37.751,"longitude":-97.822,"IPv4":"75.46.236.166","state":null}

of course, everything is NAT from the private to the public address however in one case I do have a double NAT... I run servers behind a router that is behind my ISP's router. whether connected directly to the ISP router or not I still don't get the IP address displayed.
I have been using WinSCP to upload the files

James Young

unread,
Jun 13, 2022, 9:29:55 PM6/13/22
to PicoChess
what is the test* used for? I get the login cred's after login I get   test* no such file or directory

On Monday, June 13, 2022 at 8:48:02 PM UTC-4 RandyR wrote:

Randy Reade

unread,
Jun 13, 2022, 9:38:25 PM6/13/22
to pico...@googlegroups.com
I guess that's why it is failing. There's no null handling for the city name. Even when you enter a location in picochess.ini, the code in utilities.py still runs. It fails and you don't receive the internal ip address. It may require a different geo-locator site, or some different code to handle null returns.

test* will transfer all files beginning with test in the current folder, where scp is being run. Only useful if it only contains test.py and test2.py.

James Young

unread,
Jun 13, 2022, 9:46:19 PM6/13/22
to PicoChess
Well now we have the clue , it is curious that I would need special modifications ...I wonder how many others are not able to get the IP to display? Well, I am calling it night my friend, thank you VERY much for trying all day to help resolve this issue. Chat with later

Randy Reade

unread,
Jun 13, 2022, 9:50:54 PM6/13/22
to pico...@googlegroups.com
Ok, Jim.

I'll try to find some code that will handle 'null' from JSON.

Goodnight.

Randy

--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

Randy Reade

unread,
Jun 13, 2022, 10:12:22 PM6/13/22
to pico...@googlegroups.com
So, from what I've been reading, json.loads should handle the null value. I'll have to test the code to see if it's working properly using fake data that has null in it.

Something for tomorrow.

--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

Scally

unread,
Jun 14, 2022, 6:36:30 AM6/14/22
to PicoChess
Hi,

My location setting in my picochess.ini file:

# location = auto
location = Bermondsey, London

Al.

James Young

unread,
Jun 14, 2022, 7:10:36 AM6/14/22
to PicoChess
Hey Al

The location setting appears to not work at least not on my network but works when I am in Tampa. the ISP in Tampa is Spectrum, here at home it's AT&T. I can set it manually as you suggest but it does not resolve the "no IP address" which Randy is graciously working to resolve for perhaps many who are experiencing this issue.

Scally

unread,
Jun 14, 2022, 7:46:18 AM6/14/22
to PicoChess
I have to set my location manually as the automatic setting is miles from my real location.

Yours is the first problem of this type that I’ve heard of, silly question but have you got a VPN set that suppresses your IP address?

If not, I’m sure Randy will get to the bottom of your problem …

Best of luck …

Al.

RandyR

unread,
Jun 14, 2022, 3:34:19 PM6/14/22
to PicoChess
I think I have a solution.

The issue is in the code that determines the location. If the geo-location site is unable to determine a property (e.g., city, country or country code) it returns a null value. The Python 'json.loads' command correctly changes the null value (not allowed in Python) to None. But our PicoChess code creates some strings using the city name, country name and country code, concatenating them with spaces and commas. Well, if you try to concatenate with a 'None' value it will throw an exception. Our code's exception handler for this function will return a '?' for the location, and 'None' for the internal (network) and external ip addresses. This would be fine if the Pi is not connected to the internet (and Dirk's location variable in the picochess.ini file allows you to enter your own location to handle this instance, as well as poor geo-location, which Al mentioned above). But in the case where you ARE connected to the internet, any null value would prevent the ip address from showing via the System/Information/ip address menu.

Although there are probably better ways to code this (I'm definitely a newbie in Python) I have altered the get_location() function in utilities.py so it should show the internal ip address even if it can't determine your location name. Below is the new code which begins around line 263 in utilities.py (and I have attached the updated file to this post). Note that indentation is critical in Python (multiples of 4 spaces).

Jim, if you can test this on your system and let me know if it works, I can add it to my images. Please test with 'location = auto' and 'location = <whatever you want>' in the picochess.ini file. Also, check the display in the web server.

I would also be grateful if someone else could do the same tests to make sure it doesn't break your current system. I tested on my DGTPi with the Lite image installed and it works fine.

You can make a backup of utilities.py by entering the commands (via ssh):

cd /opt/picochess
sudo cp utilities.py utilities.py.bak

To copy the file from a PC to the Pi with a shell opened in the folder containing the new file. NOTE: this will overwrite a file of the same name in the pi home folder without warning:

scp utilities.py pi@<ip address>:~/

Then, ssh into the Pi and execute the following commands:

sudo service picochess stop
sudo cp /home/pi/utilities.py /opt/picochess
sudo chown root:root /opt/picochess/utilities.py
sudo chmod 755 /opt/picochess/utilities.py
sudo service picochess start

Of course, if someone has a better solution, please advise.

Randy

-------------------------------------------------------------

def get_location():
    """Return the location of the user and the external and interal ip adr."""
    try:

        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('8.8.8.8', 80))
        int_ip = sock.getsockname()[0]
        sock.close()
        response = urllib.request.urlopen('http://will6.de/freegeoip')
        j = json.loads(response.read().decode())

## Original Code (commented out) will fail if JSON returns None for string
## value since you cannot concatenate with None. New code tests for this - RR

#        country_name = j['country_name'] + ' ' if 'country_name' in j else ''
#        country_code = j['country_code'] + ' ' if 'country_code' in j else ''
#        city = j['city'] + ', ' if 'city' in j else ''

## Current geoip site uses 'IPv4' string vice 'ip' - RR

#        ext_ip = j['ip'] if 'ip' in j else None

        if j['country_name'] is not None :

            country_name = j['country_name'] + ' '
        else :
            country_name = 'country?'

        if j['country_code'] is not None :

            country_code = j['country_code'] + ' '
        else :
            country_code = ''

        if j['city'] is not None :

            city = j['city'] + ', '
        else :
            city = 'city?' + ', '


        ext_ip = j['IPv4'] if 'IPv4' in j else None

        return (city + country_name + country_code).strip(), ext_ip, int_ip
    except:
        return '?', None, None


-------------------------------------------------------------
utilities.py

James Young

unread,
Jun 14, 2022, 3:44:11 PM6/14/22
to PicoChess
I am on it, get back to you shortly

James Young

unread,
Jun 14, 2022, 3:59:49 PM6/14/22
to PicoChess
EUREKA!!! 
We have a go!!! NICE, nicely done Randy!!
On Tuesday, June 14, 2022 at 3:34:19 PM UTC-4 RandyR wrote:

RandyR

unread,
Jun 14, 2022, 4:01:48 PM6/14/22
to PicoChess
That's great, Jim. Thanks for the quick test.

Randy

James Young

unread,
Jun 14, 2022, 4:06:50 PM6/14/22
to PicoChess
Dude, THANK YOU!!!! For the diligence to resolve the issue.

James Young

unread,
Jun 14, 2022, 4:28:01 PM6/14/22
to PicoChess
Notes

Works wired and wireless and behind a double NAT network.
Auto location can not ID my city but does ID the United States as a part of the location
Manual Location no issues there

NO MORE "no IP address"

Marc Hamilton

unread,
Jun 14, 2022, 4:36:12 PM6/14/22
to PicoChess
Yeah, code change to utilities.py (still) works for me too. 

RandyR

unread,
Jun 14, 2022, 5:03:47 PM6/14/22
to PicoChess
Thanks, guys. I'll update my images.

Randy

Reply all
Reply to author
Forward
Message has been deleted
0 new messages