self.postoptparse()
- if os.geteuid() != 0 and args[0] != 'help':
- msger.error('root permission is required to continue, abort')
-
return self.cmd(args)
+ def precmd(self, argv): # check arguments before cmd
+ if argv[0] == 'help' or argv[0] == '?':
+ return argv
+ if len(argv) == 1:
+ return ['help', argv[0]]
+ elif len(argv) > 2:
+ raise errors.Usage("Extra arguments given")
+
+ if not os.path.exists(argv[1]):
+ raise errors.CreatorError("Can't find file: %s" % argv[1])
+
+ if os.geteuid() != 0:
+ raise msger.error("Root permission is required, abort")
+
+ return argv
+
def do_auto(self, subcmd, opts, *args):
"""${cmd_name}: auto detect image type from magic header
return None
- if not args:
- self.do_help(['help', subcmd])
- return None
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
- if not os.path.exists(args[0]):
- raise errors.CreatorError("Can't find the file: %s" % args[0])
-
with open(args[0], 'r') as rf:
first_line = rf.readline()
${cmd_option_list}
"""
- if not args:
- raise errors.Usage("need one argument as the path of ks file")
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
ksconf = args[0]
- if not os.path.exists(ksconf):
- raise errors.CreatorError("Can't find the file: %s" % ksconf)
-
recording_pkgs = []
if len(creatoropts['record_pkgs']) > 0:
recording_pkgs = creatoropts['record_pkgs']
${cmd_option_list}
"""
- if not args:
- raise errors.Usage("need one argument as the path of ks file")
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
ksconf = args[0]
- if not os.path.exists(ksconf):
- raise errors.CreatorError("Can't find the file: %s" % ksconf)
-
if creatoropts['arch'] and creatoropts['arch'].startswith('arm'):
msger.warning('livecd cannot support arm images, Quit')
return
${cmd_option_list}
"""
- if not args:
- raise errors.Usage("need one argument as the path of ks file")
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
ksconf = args[0]
- if not os.path.exists(ksconf):
- raise errors.CreatorError("Can't find the file: %s" % ksconf)
-
if creatoropts['arch'] and creatoropts['arch'].startswith('arm'):
msger.warning('liveusb cannot support arm images, Quit')
return
${cmd_option_list}
"""
- if not args:
- raise errors.Usage("need one argument as the path of ks file")
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
ksconf = args[0]
- if not os.path.exists(ksconf):
- raise errors.CreatorError("Can't find the file: %s" % ksconf)
-
recording_pkgs = []
if len(creatoropts['record_pkgs']) > 0:
recording_pkgs = creatoropts['record_pkgs']
${cmd_option_list}
"""
- if not args:
- raise errors.Usage("need one argument as the path of ks file")
-
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
ksconf = args[0]
- if not os.path.exists(ksconf):
- raise errors.CreatorError("Can't find the file: %s" % ksconf)
-
recording_pkgs = []
if len(creatoropts['record_pkgs']) > 0:
recording_pkgs = creatoropts['record_pkgs']