if not spec.name or not spec.version:
msger.error('can\'t get correct name or version from spec file.')
else:
- outdir = "%s/%s-%s-%s" % (outdir, spec.name, spec.upstreamversion, spec.release)
+ outdir = "%s/%s-%s-%s" % (outdir, spec.name, spec.upstreamversion,
+ spec.release)
shutil.rmtree(outdir, ignore_errors=True)
shutil.move(export_dir, outdir)
self._flines[lineno] = None
else:
# is it a section header?
- mo = self.SECTCRE.match(line)
- if mo:
- cursect = mo.group('header')
+ match = self.SECTCRE.match(line)
+ if match:
+ cursect = match.group('header')
# So sections can't start with a continuation line
optname = None
# no section header in the file?
elif cursect is None:
- raise MissingSectionHeaderError(self._fpname, lineno + 1, line)
+ raise MissingSectionHeaderError(self._fpname,
+ lineno + 1, line)
# an option line?
else:
- mo = self.OPTCRE.match(line)
- if mo:
- optname = mo.group('option')
+ match = self.OPTCRE.match(line)
+ if match:
+ optname = match.group('option')
optname = self.optionxform(optname.rstrip())
# Replace / remove options
if cursect == section and \
if catch != 3:
dev_null = os.open("/dev/null", os.O_WRONLY)
- if catch == 0:
- sout = dev_null
- serr = dev_null
- elif catch == 1:
- sout = subprocess.PIPE
- serr = dev_null
- elif catch == 2:
- sout = dev_null
- serr = subprocess.PIPE
- elif catch == 3:
- sout = subprocess.PIPE
- serr = subprocess.STDOUT
+ sout = [dev_null, subprocess.PIPE, dev_null, subprocess.PIPE][catch]
+ serr = [dev_null, dev_null, subprocess.PIPE, subprocess.STDOUT][catch]
try:
process = subprocess.Popen(cmdln_or_args, stdout=sout,
def quiet(cmdln_or_args):
return runtool(cmdln_or_args, catch=0)[0]
-def embed(cmdln_or_args):
- # embed shell script into python frame code
-
- if isinstance(cmdln_or_args, list):
- args = cmdln_or_args
- else:
- import shlex
- args = shlex.split(cmdln_or_args)
-
- try:
- sts = subprocess.call(args)
- except OSError, exc:
- if exc.errno == 2:
- # [Errno 2] No such file or directory
- msger.error('Cannot run command: %s, lost dependency?' % args[0])
- else:
- raise # relay
-
- return sts
import pycurl
import hashlib
import signal
+import xml.etree.ElementTree as ET
from collections import defaultdict
-# cElementTree can be standard or 3rd-party depending on python version
-try:
- from xml.etree import cElementTree as ET
-except ImportError:
- import cElementTree as ET
-
from gitbuildsys import errors, msger
from gbp.rpm.git import GitRepositoryError
if content:
with file(path, 'w+') as fobj:
fobj.write(content)
- except OSError, (e, msg):
+ except OSError, err:
raise errors.GbsError("Failed to create dir or file on %s: %s" % \
- (target_dir, msg))
+ (target_dir, str(err)))
self.path = path
def __del__(self):