mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -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=''):
|
||||
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):
|
||||
return output
|
||||
|
||||
|
@ -1217,16 +1229,15 @@ def browse_path(path=None, include_hidden=False, filter_ext=''):
|
|||
}
|
||||
output.append(out)
|
||||
elif os.name == 'nt':
|
||||
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': 'level-up-alt'
|
||||
}
|
||||
output.append(out)
|
||||
parent_path = 'My Computer'
|
||||
out = {
|
||||
'key': base64.b64encode(parent_path.encode('UTF-8')),
|
||||
'path': parent_path,
|
||||
'title': parent_path,
|
||||
'type': 'folder',
|
||||
'icon': 'level-up-alt'
|
||||
}
|
||||
output.append(out)
|
||||
|
||||
for root, dirs, files in os.walk(path):
|
||||
for d in sorted(dirs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue