|
25 | 25 | from collections import OrderedDict |
26 | 26 | from pathlib import Path |
27 | 27 |
|
| 28 | + |
28 | 29 | if sys.platform != "win32": |
29 | 30 | import subprocess |
30 | 31 | else: |
|
33 | 34 | ctypes.windll.shcore.SetProcessDpiAwareness(0) |
34 | 35 | ctypes.windll.user32.SetProcessDPIAware() |
35 | 36 |
|
36 | | -version = "v24.11.1" |
| 37 | +version = "v24.12.1" |
| 38 | +# v24.12.1 - Much improved handling of unresponsive servers. |
37 | 39 | # v24.11.1 - Save playlist to file. Also shift to different version number scheme. |
38 | 40 | # v2.1.0 - Gently handle attempting to run with no server. Add 'delete debug log'. |
39 | 41 | # v2.0.9 - Finally get scale factors working. Renamed menus. Browse help.html. |
40 | 42 |
|
41 | | - |
42 | 43 | client = musicpd.MPDClient() # create client object |
43 | 44 |
|
44 | 45 | # confparse is for general use for normal text strings. |
@@ -400,14 +401,20 @@ def connext(): ## Checks connection, then connects if necessary. |
400 | 401 | if err2var == 'Already connected': |
401 | 402 | cxstat = 1 |
402 | 403 | pass |
403 | | - if 'WinError' in str(err2var) or 'Not connected' in str(err2var): |
404 | | - messagebox.showinfo("Server Down","The server you selected is not responding. Edit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.") |
405 | | - cxstat = 0 |
406 | | - configurator("Double-check all the IP addresses. OK sends you to edit mmc4w.ini.") |
407 | 404 | else: |
408 | | - logger.debug("D1| Second level errvar: {}".format(err2var)) |
409 | | - cxstat = 0 |
410 | | - endWithError("The server you selected is not responding.\nEdit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.") |
| 405 | + cstat = 0 |
| 406 | + # if 'WinError' in str(err2var) or 'Not connected' in str(err2var): |
| 407 | + # messagebox.showinfo("Server Down","The server you selected is not responding. Edit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.") |
| 408 | + # cxstat = 0 |
| 409 | + #configurator("Double-check all the IP addresses. OK sends you to edit mmc4w.ini.") |
| 410 | + # else: |
| 411 | + # logger.debug("D1| Final terminal error: {}".format(err2var)) |
| 412 | + # cxstat = 0 |
| 413 | + # configurator("Double-check all the IP addresses. OK sends you to edit mmc4w.ini.") |
| 414 | + |
| 415 | + #endWithError("The server you selected is not responding.\nEdit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.") |
| 416 | + #configurator("The server you selected is not responding.\nEdit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.") |
| 417 | + # messagebox.showinfo("Server Not Responding","Server\n" + serverip + "\nis not responding.\nSelect a different one.") |
411 | 418 | return cxstat |
412 | 419 |
|
413 | 420 |
|
@@ -950,9 +957,11 @@ def plupdate(): |
950 | 957 | def displaytext1(msg): |
951 | 958 | text1.delete("1.0", 'end') |
952 | 959 | text1.insert("1.0", msg) |
| 960 | + text1.update() |
953 | 961 |
|
954 | 962 | def displaytext2(msg2): |
955 | 963 | text1.insert(tk.END, msg2) |
| 964 | + text1.update() |
956 | 965 |
|
957 | 966 | def albarttoggle(): |
958 | 967 | global aatgl,artw,aartvar |
@@ -1522,26 +1531,40 @@ def SrvrWindow(swaction): |
1522 | 1531 | if swaction == 'output': |
1523 | 1532 | srvrwtitle = "MPD Server Outputs" |
1524 | 1533 | srvrw = TlSbBWin(window, srvrwtitle, tsbinilist) |
| 1534 | + |
1525 | 1535 | def rtnplsel(ipvar): |
1526 | | - global serverip,firstrun,lastpl |
1527 | | - client.close() |
| 1536 | + global serverip,firstrun,lastpl,cxstat |
| 1537 | + cxstat = connext() |
| 1538 | + if cxstat == 1: |
| 1539 | + client.close() |
1528 | 1540 | selection = srvrw.listbx.curselection()[0] |
1529 | | - msg = ipvar |
| 1541 | + msg = "Attempting " + iplist[selection] |
1530 | 1542 | displaytext1(msg) |
1531 | 1543 | serverip = iplist[selection] |
1532 | 1544 | confparse.read(mmc4wIni) |
1533 | | - connext() |
1534 | | - confparse.set("serverstats","lastsrvr",serverip) |
1535 | | - with open(mmc4wIni, 'w') as SLcnf: |
1536 | | - confparse.write(SLcnf) |
1537 | | - # srvrw.destroy() |
1538 | | - logger.debug("serverip: {}".format(serverip)) |
1539 | | - lastpl = 'Joined Server Queue' |
1540 | | - confparse.set('serverstats','lastsetpl',lastpl) |
1541 | | - with open(mmc4wIni, 'w') as SLcnf: |
1542 | | - confparse.write(SLcnf) |
1543 | | - logger.info('0) Connected to server {}.'.format(serverip)) |
1544 | | - getcurrsong() |
| 1545 | + currsrvr = confparse.get("serverstats","lastsrvr") |
| 1546 | + cxstat = connext() |
| 1547 | + # print('cxstat is: {}'.format(cxstat)) |
| 1548 | + if cxstat == 1: |
| 1549 | + srvrw.destroy() |
| 1550 | + msg = iplist[selection] |
| 1551 | + displaytext1(msg) |
| 1552 | + confparse.set("serverstats","lastsrvr",serverip) |
| 1553 | + with open(mmc4wIni, 'w') as SLcnf: |
| 1554 | + confparse.write(SLcnf) |
| 1555 | + logger.debug("serverip: {}".format(serverip)) |
| 1556 | + lastpl = 'Joined Server Queue' |
| 1557 | + confparse.set('serverstats','lastsetpl',lastpl) |
| 1558 | + with open(mmc4wIni, 'w') as SLcnf: |
| 1559 | + confparse.write(SLcnf) |
| 1560 | + logger.info('0) Connected to server {}.'.format(serverip)) |
| 1561 | + getcurrsong() |
| 1562 | + else: |
| 1563 | + tried = serverip |
| 1564 | + serverip = currsrvr |
| 1565 | + srvrw.destroy() |
| 1566 | + messagebox.showinfo("Server Not Responding","Server\n" + tried + "\nis not responding.\nSelect a different one.") |
| 1567 | + |
1545 | 1568 |
|
1546 | 1569 | def outputtggl(outputvar): |
1547 | 1570 | selection = srvrw.listbx.curselection()[0] |
@@ -1899,8 +1922,13 @@ def eo2(): |
1899 | 1922 | artw.overrideredirect(True) |
1900 | 1923 | elif firstrun == '0' and tbarini == '1': |
1901 | 1924 | artw.overrideredirect(False) |
1902 | | -getcurrsong() |
1903 | | -getoutputs() |
| 1925 | +#cxstat = connext() |
| 1926 | +if cxstat == 1: |
| 1927 | + getcurrsong() |
| 1928 | + getoutputs() |
| 1929 | +else: |
| 1930 | + messagebox.showinfo("Select a Server", serverip + " is not responding.\nSelect a different one.") |
| 1931 | + SrvrWindow('server') |
1904 | 1932 | if abp == '1': |
1905 | 1933 | if buttonvar == 'play': |
1906 | 1934 | browserplayer() |
|
0 commit comments