Skip to content

Commit

Permalink
Better way of detecting VM.
Browse files Browse the repository at this point in the history
  • Loading branch information
WillyPillow committed Jul 29, 2020
1 parent b634c7c commit 0e8e8d9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions qubesadmin/tools/qvm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@
CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qvm-template')

def qubes_release():
try:
os_id = subprocess.check_output(['lsb_release', '-si'],
encoding='UTF-8').strip()
if os_id == 'Qubes':
return subprocess.check_output(['lsb_release', '-sr'],
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()
if os.path.exists('/usr/share/qubes/marker-vm'):
with open('/usr/share/qubes/marker-vm', 'r') as f:
# Get last line (in the format `x.x`)
return f.readlines()[-1].strip()
return subprocess.check_output(['lsb_release', '-sr'],
encoding='UTF-8').strip()

parser = argparse.ArgumentParser(description='Qubes Template Manager')
parser.add_argument('operation', type=str)
Expand Down

0 comments on commit 0e8e8d9

Please sign in to comment.