mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Improve browsing for path on Windows
This commit is contained in:
parent
bc017fb010
commit
6c8b425fb3
1 changed files with 21 additions and 10 deletions
|
@ -1203,6 +1203,18 @@ def user_page(user_id=None, user=None):
|
||||||
def browse_path(path=None, include_hidden=False, filter_ext=''):
|
def browse_path(path=None, include_hidden=False, filter_ext=''):
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
|
if os.name == 'nt' and path.lower() == 'my computer':
|
||||||
|
drives = ['%s:\\' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]
|
||||||
|
for drive in drives:
|
||||||
|
out = {
|
||||||
|
'key': base64.b64encode(drive.encode('UTF-8')),
|
||||||
|
'path': drive,
|
||||||
|
'title': drive,
|
||||||
|
'type': 'folder',
|
||||||
|
'icon': 'folder'
|
||||||
|
}
|
||||||
|
output.append(out)
|
||||||
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -1217,16 +1229,15 @@ def browse_path(path=None, include_hidden=False, filter_ext=''):
|
||||||
}
|
}
|
||||||
output.append(out)
|
output.append(out)
|
||||||
elif os.name == 'nt':
|
elif os.name == 'nt':
|
||||||
drives = ['%s:\\' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]
|
parent_path = 'My Computer'
|
||||||
for drive in drives:
|
out = {
|
||||||
out = {
|
'key': base64.b64encode(parent_path.encode('UTF-8')),
|
||||||
'key': base64.b64encode(drive.encode('UTF-8')),
|
'path': parent_path,
|
||||||
'path': drive,
|
'title': parent_path,
|
||||||
'title': drive,
|
'type': 'folder',
|
||||||
'type': 'folder',
|
'icon': 'level-up-alt'
|
||||||
'icon': 'level-up-alt'
|
}
|
||||||
}
|
output.append(out)
|
||||||
output.append(out)
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for d in sorted(dirs):
|
for d in sorted(dirs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue