Better way of detecting VM.
This commit is contained in:
parent
b634c7c785
commit
0e8e8d98de
@ -20,17 +20,12 @@ PACKAGE_NAME_PREFIX = 'qubes-template-'
|
|||||||
CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qvm-template')
|
CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qvm-template')
|
||||||
|
|
||||||
def qubes_release():
|
def qubes_release():
|
||||||
try:
|
if os.path.exists('/usr/share/qubes/marker-vm'):
|
||||||
os_id = subprocess.check_output(['lsb_release', '-si'],
|
with open('/usr/share/qubes/marker-vm', 'r') as f:
|
||||||
encoding='UTF-8').strip()
|
# Get last line (in the format `x.x`)
|
||||||
if os_id == 'Qubes':
|
return f.readlines()[-1].strip()
|
||||||
return subprocess.check_output(['lsb_release', '-sr'],
|
return subprocess.check_output(['lsb_release', '-sr'],
|
||||||
encoding='UTF-8').strip()
|
encoding='UTF-8').strip()
|
||||||
except:
|
|
||||||
pass
|
|
||||||
with open('/usr/share/qubes/marker-vm', 'r') as f:
|
|
||||||
# Get last line (in the format `x.x`)
|
|
||||||
return f.readlines[-1].strip()
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Qubes Template Manager')
|
parser = argparse.ArgumentParser(description='Qubes Template Manager')
|
||||||
parser.add_argument('operation', type=str)
|
parser.add_argument('operation', type=str)
|
||||||
|
Loading…
Reference in New Issue
Block a user