Fix lgp script after clcommands migration

closes #67555

authorJulien Cristau <julien.cristau@logilab.fr>
changesetb100f7bd6da0
branchdefault
phasepublic
hiddenno
parent revision#3f9a7a7c0291 utils: use debian.{deb822,changelog} to parse debian packaging files
child revision#f89fa716fe17 Get rid of cvslog docs
files modified by this revision
lgp/script.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1306471479 -7200
# Fri May 27 06:44:39 2011 +0200
# Node ID b100f7bd6da0a7768986981bebc2cf503144bd44
# Parent 3f9a7a7c02914f8a92d270d32861e65e18586ab1
Fix lgp script after clcommands migration

closes #67555

diff --git a/lgp/script.py b/lgp/script.py
@@ -57,35 +57,37 @@
1      def _set_package_format(self):
2          pass
3 
4      def run(self, args):
5 
6 -        #  command, = glob.glob(os.path.join(SCRIPTS_DIR, self.config.command))
7 -        if len(self.arguments)==0:
8 +        if not self.config.command and len(args)==0:
9              commands = dict(self.options)['command']['choices']
10              logging.info('available command(s): %s', commands)
11 -        else:
12 -            commands = [c for c in glob.glob(os.path.join(SCRIPTS_DIR, self.config.command))
13 -                        if os.path.basename(c)==self.config.command]
14 +            sys.exit()
15 +
16 +        if not self.config.command:
17 +            self.config.command = args[0]
18 +            args = args[1:]
19 +
20 +        commands = [c for c in glob.glob(os.path.join(SCRIPTS_DIR, self.config.command))
21 +                    if os.path.basename(c)==self.config.command]
22 
23          if not commands:
24              raise LGPException("command '%s' not found. Please check commands in %s"
25                                 % (self.config.command, SCRIPTS_DIR))
26 -        if len(self.arguments)==0:
27 -            sys.exit()
28 
29          for arch in self.get_architectures():
30              for distrib in self.distributions:
31                  for command in commands:
32                      image = self.get_basetgz(distrib, arch)
33 
34                      cmd = self.cmd % (image, distrib, arch, self.setarch_cmd, self.sudo_cmd,
35                                        self.pbuilder_cmd, CONFIG_FILE, HOOKS_DIR, command,
36 -                                      ' '.join(self.arguments))
37 +                                      ' '.join(args))
38 
39                      logging.info("execute script '%s' with arguments: %s",
40 -                                 command, ' '.join(self.arguments))
41 +                                 command, ' '.join(args))
42                      logging.debug("run command: %s", cmd)
43                      try:
44                          check_call(cmd, stdout=sys.stdout, shell=True,
45                                     env={'DIST': distrib, 'ARCH': arch, 'IMAGE': image})
46                      except CalledProcessError, err: