1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-19 13:37:58 +01:00

Fix config behavior in case of empty args

This commit is contained in:
2021-06-05 17:09:02 +02:00
parent e8264c5c69
commit 3f8dec1f2d

10
box.py
View File

@@ -153,7 +153,7 @@ _boxpy() {
_ssh_identityfile _ssh_identityfile
;; ;;
--distro) --distro)
COMPREPLY=( $(compgen -W "ubuntu" -- ${cur}) ) COMPREPLY=( $(compgen -W "ubuntu fedora" -- ${cur}) )
;; ;;
--*) --*)
COMPREPLY=( ) COMPREPLY=( )
@@ -232,7 +232,7 @@ class Config:
def __init__(self, args, vbox=None): def __init__(self, args, vbox=None):
self.advanced = None self.advanced = None
self.distro = args.distro self.distro = None
self.cpus = None self.cpus = None
self.disk_size = None self.disk_size = None
self.hostname = None self.hostname = None
@@ -255,7 +255,7 @@ class Config:
setattr(self, attr, vm_info[attr]) setattr(self, attr, vm_info[attr])
# next, grab the cloud config file # next, grab the cloud config file
if args.config: if 'config' in args:
self.user_data = os.path.abspath(args.config) self.user_data = os.path.abspath(args.config)
else: else:
self.user_data = vm_info.get('user_data') self.user_data = vm_info.get('user_data')
@@ -273,7 +273,7 @@ class Config:
continue continue
setattr(self, attr, str(val)) setattr(self, attr, str(val))
if not self.version: if not self.version and self.distro:
self.version = DISTROS[self.distro]['default_version'] self.version = DISTROS[self.distro]['default_version']
# finally, figure out host name # finally, figure out host name
@@ -440,7 +440,7 @@ class VBoxManage:
encoding=sys.getdefaultencoding(), encoding=sys.getdefaultencoding(),
stderr=subprocess.DEVNULL) stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return None return {}
self.vm_info = {} self.vm_info = {}