Skip to content

Commit 8ae5562

Browse files
authored
Merge pull request bit-team#959 from belsander/master
CLI fixes for docker
2 parents b51bc28 + a1a1d73 commit 8ae5562

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

common/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def terminalSize():
194194
return [24, 80]
195195

196196
def frame(msg, size = 32):
197-
ret = ' ' + '' * size + '\n'
198-
ret += ' ' + msg.center(size) + '\n'
199-
ret += ' ' + '' * size + ''
197+
ret = ' +' + '-' * size + '+\n'
198+
ret += ' |' + msg.center(size) + '|\n'
199+
ret += ' +' + '-' * size + '+'
200200
return ret
201201

202202
class RestoreDialog(object):

common/test/test_backintime.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ def test_local_snapshot_is_successful(self):
7777
7878
(INFO: Update to config version \d+
7979
)?
80-
┌────────────────────────────────┐
81-
Check/prepair snapshot path
82-
└────────────────────────────────┘
80+
\+--------------------------------\+
81+
| Check/prepair snapshot path |
82+
\+--------------------------------\+
8383
Check/prepair snapshot path: done
8484
85-
┌────────────────────────────────┐
86-
Check config
87-
└────────────────────────────────┘
85+
\+--------------------------------\+
86+
| Check config |
87+
\+--------------------------------\+
8888
Check config: done
8989
9090
Config .*test/config profile 'Main profile' is fine.''', re.MULTILINE))

common/tools.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,14 @@ def checkXServer():
449449
Returns:
450450
bool: ``True`` if X11 server is running
451451
"""
452-
proc = subprocess.Popen(['xdpyinfo'],
453-
stdout = subprocess.DEVNULL,
454-
stderr = subprocess.DEVNULL)
455-
proc.communicate()
456-
return proc.returncode == 0
452+
if which('xdpyinfo') is not None:
453+
proc = subprocess.Popen(['xdpyinfo'],
454+
stdout = subprocess.DEVNULL,
455+
stderr = subprocess.DEVNULL)
456+
proc.communicate()
457+
return proc.returncode == 0
458+
else:
459+
return False
457460

458461
def preparePath(path):
459462
"""
@@ -934,9 +937,22 @@ def uuidFromDev(dev):
934937
"""
935938
if dev and os.path.exists(dev):
936939
dev = os.path.realpath(dev)
937-
for uuid in os.listdir(DISK_BY_UUID):
938-
if dev == os.path.realpath(os.path.join(DISK_BY_UUID, uuid)):
939-
return uuid
940+
if os.path.exists(DISK_BY_UUID):
941+
for uuid in os.listdir(DISK_BY_UUID):
942+
if dev == os.path.realpath(os.path.join(DISK_BY_UUID, uuid)):
943+
return uuid
944+
else:
945+
c = re.compile(b'.*\sUUID="([^"]*)".*')
946+
try:
947+
# If device does not exist, blkid will exit with a non-zero code
948+
blkid = subprocess.check_output(['blkid', dev],
949+
stderr = subprocess.DEVNULL)
950+
uuid = c.findall(blkid)
951+
if uuid:
952+
return uuid[0].decode('UTF-8')
953+
except:
954+
pass
955+
940956
c = re.compile(b'.*?ID_FS_UUID=(\S+)')
941957
try:
942958
udevadm = subprocess.check_output(['udevadm', 'info', '--name=%s' % dev],

0 commit comments

Comments
 (0)