summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-03-20 20:19:50 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2019-03-21 00:55:26 +0530
commit04d3e55db7c5ddf3c25fd61dab16a192962defab (patch)
tree5e3b35b1114da45a40b35d5e254a6c8a5f4b2bd8
parent591bc3590417d9c904dab7cc5057969532271696 (diff)
cerbero: Use Path.glob() instead of `ls`
This is faster, especially on Windows, and also fixes these spammy warnings: Exception ignored when trying to write to the signal wakeup fd: BlockingIOError: [Errno 11] Resource temporarily unavailable
-rw-r--r--cerbero/utils/shell.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py
index d43cb77c..4cb92137 100644
--- a/cerbero/utils/shell.py
+++ b/cerbero/utils/shell.py
@@ -31,7 +31,7 @@ import glob
import shutil
import hashlib
import urllib.request, urllib.error, urllib.parse
-from pathlib import PurePath
+from pathlib import Path, PurePath
from distutils.version import StrictVersion
import cerbero.hacks
@@ -433,12 +433,13 @@ def _splitter(string, base_url):
def ls_files(files, prefix):
- if files == []:
- return files
- sfiles = check_call('ls %s' % ' '.join(files),
- prefix, True, False, False).split('\n')
- sfiles.remove('')
- return list(set(sfiles))
+ if not files:
+ return []
+ sfiles = set()
+ prefix = Path(prefix)
+ for f in ' '.join(files).split():
+ sfiles.update([i.relative_to(prefix).as_posix() for i in prefix.glob(f)])
+ return list(sfiles)
def ls_dir(dirpath, prefix):