~charm-helpers/charm-helpers/devel

« back to all changes in this revision

Viewing changes to charmhelpers/contrib/storage/linux/utils.py

  • Committer: Stuart Bishop
  • Date: 2014-11-25 16:06:34 UTC
  • mfrom: (158.2.46 fix-configure_sources)
  • Revision ID: stuart@stuartbishop.net-20141125160634-wo9uarwrv20ew23y
[stub, r=niedbalski,tvansteenburgh] The Return of Python 3 Support

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    # sometimes sgdisk exits non-zero; this is OK, dd will clean up
31
31
    call(['sgdisk', '--zap-all', '--mbrtogpt',
32
32
          '--clear', block_device])
33
 
    dev_end = check_output(['blockdev', '--getsz', block_device])
 
33
    dev_end = check_output(['blockdev', '--getsz',
 
34
                            block_device]).decode('UTF-8')
34
35
    gpt_end = int(dev_end.split()[0]) - 100
35
36
    check_call(['dd', 'if=/dev/zero', 'of=%s' % (block_device),
36
37
                'bs=1M', 'count=1'])
47
48
        it doesn't.
48
49
    '''
49
50
    is_partition = bool(re.search(r".*[0-9]+\b", device))
50
 
    out = check_output(['mount'])
 
51
    out = check_output(['mount']).decode('UTF-8')
51
52
    if is_partition:
52
53
        return bool(re.search(device + r"\b", out))
53
54
    return bool(re.search(device + r"[0-9]+\b", out))