Fix network credentials dialog issues
This commit is contained in:
parent
8c43ef6633
commit
fc29bd30b8
1 changed files with 29 additions and 25 deletions
|
@ -682,25 +682,28 @@ def sourcesXML():
|
||||||
except: pass
|
except: pass
|
||||||
etree.ElementTree(root).write(xmlpath)
|
etree.ElementTree(root).write(xmlpath)
|
||||||
|
|
||||||
def passwordsXML():
|
|
||||||
|
|
||||||
|
def passwordsXML():
|
||||||
# To add network credentials
|
# To add network credentials
|
||||||
path = xbmc.translatePath("special://userdata/").decode('utf-8')
|
path = xbmc.translatePath("special://userdata/").decode('utf-8')
|
||||||
xmlpath = "%spasswords.xml" % path
|
xmlpath = "%spasswords.xml" % path
|
||||||
logMsg('Path to passwords.xml: %s' % xmlpath, 1)
|
logMsg('passwordsXML', 'Path to passwords.xml: %s' % xmlpath, 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xmlparse = etree.parse(xmlpath)
|
xmlparse = etree.parse(xmlpath)
|
||||||
except: # Document is blank or missing
|
except: # Document is blank or missing
|
||||||
root = etree.Element('passwords')
|
root = etree.Element('passwords')
|
||||||
|
skipFind = True
|
||||||
else:
|
else:
|
||||||
root = xmlparse.getroot()
|
root = xmlparse.getroot()
|
||||||
|
skipFind = False
|
||||||
|
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
credentials = settings('networkCreds')
|
credentials = settings('networkCreds')
|
||||||
if credentials:
|
if credentials:
|
||||||
# Present user with options
|
# Present user with options
|
||||||
option = dialog.select("Modify/Remove network credentials", ["Modify", "Remove"])
|
option = dialog.select(
|
||||||
|
"Modify/Remove network credentials", ["Modify", "Remove"])
|
||||||
|
|
||||||
if option < 0:
|
if option < 0:
|
||||||
# User cancelled dialog
|
# User cancelled dialog
|
||||||
|
@ -714,8 +717,9 @@ def passwordsXML():
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if path.find('.//from').text == "smb://%s/" % credentials:
|
if path.find('.//from').text == "smb://%s/" % credentials:
|
||||||
paths.remove(path)
|
paths.remove(path)
|
||||||
logMsg("EMBY", "Successfully removed credentials for: %s"
|
logMsg("passwordsXML",
|
||||||
% credentials, 1)
|
"Successfully removed credentials for: %s"
|
||||||
|
% credentials, 1)
|
||||||
etree.ElementTree(root).write(xmlpath)
|
etree.ElementTree(root).write(xmlpath)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -723,11 +727,11 @@ def passwordsXML():
|
||||||
|
|
||||||
settings('networkCreds', value="")
|
settings('networkCreds', value="")
|
||||||
xbmcgui.Dialog().notification(
|
xbmcgui.Dialog().notification(
|
||||||
heading='PlexKodiConnect',
|
heading='PlexKodiConnect',
|
||||||
message="%s removed from passwords.xml" % credentials,
|
message="%s removed from passwords.xml" % credentials,
|
||||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||||
time=1000,
|
time=1000,
|
||||||
sound=False)
|
sound=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif option == 0:
|
elif option == 0:
|
||||||
|
@ -741,7 +745,7 @@ def passwordsXML():
|
||||||
heading="Network credentials",
|
heading="Network credentials",
|
||||||
line1= (
|
line1= (
|
||||||
"Input the server name or IP address as indicated in your plex library paths. "
|
"Input the server name or IP address as indicated in your plex library paths. "
|
||||||
'For example, the server name: \\\\SERVER-PC\\path\\ is "SERVER-PC".'))
|
'For example, the server name: \\\\SERVER-PC\\path\\ or smb://SERVER-PC/path is "SERVER-PC".'))
|
||||||
server = dialog.input("Enter the server name or IP address")
|
server = dialog.input("Enter the server name or IP address")
|
||||||
if not server:
|
if not server:
|
||||||
return
|
return
|
||||||
|
@ -751,21 +755,21 @@ def passwordsXML():
|
||||||
if not user:
|
if not user:
|
||||||
return
|
return
|
||||||
# Network password
|
# Network password
|
||||||
password = dialog.input(
|
password = dialog.input("Enter the network password",
|
||||||
heading="Enter the network password",
|
'', # Default input
|
||||||
default='',
|
xbmcgui.INPUT_ALPHANUM,
|
||||||
type=xbmcgui.INPUT_ALPHANUM,
|
xbmcgui.ALPHANUM_HIDE_INPUT)
|
||||||
option=xbmcgui.ALPHANUM_HIDE_INPUT)
|
|
||||||
|
|
||||||
logMsg('Done asking for user credentials', 1)
|
# Add elements. Annoying etree bug where findall hangs forever
|
||||||
# Add elements
|
if skipFind is False:
|
||||||
for path in root.findall('.//path'):
|
skipFind = True
|
||||||
logMsg('Running in loop', 1)
|
for path in root.findall('.//path'):
|
||||||
if path.find('.//from').text.lower() == "smb://%s/" % server.lower():
|
if path.find('.//from').text.lower() == "smb://%s/" % server.lower():
|
||||||
# Found the server, rewrite credentials
|
# Found the server, rewrite credentials
|
||||||
path.find('.//to').text = "smb://%s:%s@%s/" % (user, password, server)
|
path.find('.//to').text = "smb://%s:%s@%s/" % (user, password, server)
|
||||||
break
|
skipFind = False
|
||||||
else:
|
break
|
||||||
|
if skipFind:
|
||||||
# Server not found, add it.
|
# Server not found, add it.
|
||||||
path = etree.SubElement(root, 'path')
|
path = etree.SubElement(root, 'path')
|
||||||
etree.SubElement(path, 'from', attrib={'pathversion': "1"}).text = "smb://%s/" % server
|
etree.SubElement(path, 'from', attrib={'pathversion': "1"}).text = "smb://%s/" % server
|
||||||
|
|
Loading…
Add table
Reference in a new issue