# Build up a list of potentially new things
for name, f in files.items():
# Skip byhand elements
- if f["type"] == "byhand":
- continue
+# if f["type"] == "byhand":
+# continue
pkg = f["package"]
priority = f["priority"]
section = f["section"]
def check_status(files):
new = byhand = 0
for f in files.keys():
- if files[f]["type"] == "byhand":
+ if files[f].has_key("byhand"):
byhand = 1
elif files[f].has_key("new"):
new = 1
entry["new"] = 1
else:
dsc_file_exists = False
- for myq in ["Accepted", "Embargoed", "Unembargoed", "ProposedUpdates", "OldProposedUpdates"]:
+ for myq in ["Embargoed", "Unembargoed", "ProposedUpdates", "OldProposedUpdates"]:
if cnf.has_key("Dir::Queue::%s" % (myq)):
if os.path.exists(os.path.join(cnf["Dir::Queue::" + myq], dsc_filename)):
dsc_file_exists = True
# if in the pool or in a queue other than unchecked, reject
if (dbc.in_queue is None) \
or (dbc.in_queue is not None
- and dbc.in_queue.queue_name != 'unchecked'):
+ and dbc.in_queue.queue_name not in ["unchecked", "newstage"]):
self.rejects.append("%s file already known to dak" % base_filename)
except NoResultFound, e:
# not known, good
continue
# Look in some other queues for the file
- queues = ('Accepted', 'New', 'Byhand', 'ProposedUpdates',
+ queues = ('New', 'Byhand', 'ProposedUpdates',
'OldProposedUpdates', 'Embargoed', 'Unembargoed')
for queue in queues:
###########################################################################
def check_lintian(self):
+ """
+ Extends self.rejects by checking the output of lintian against tags
+ specified in Dinstall::LintianTags.
+ """
+
cnf = Config()
# Don't reject binary uploads
return
# Only check some distributions
- valid_dist = False
for dist in ('unstable', 'experimental'):
if dist in self.pkg.changes['distribution']:
- valid_dist = True
break
-
- if not valid_dist:
+ else:
return
+ # If we do not have a tagfile, don't do anything
tagfile = cnf.get("Dinstall::LintianTags")
if tagfile is None:
- # We don't have a tagfile, so just don't do anything.
return
# Parse the yaml file
sourcefile = file(tagfile, 'r')
sourcecontent = sourcefile.read()
sourcefile.close()
+
try:
lintiantags = yaml.load(sourcecontent)['lintian']
except yaml.YAMLError, msg:
# Try and find all orig mentioned in the .dsc
symlinked = self.ensure_orig()
- # Now setup the input file for lintian. lintian wants "one tag per line" only,
- # so put it together like it. We put all types of tags in one file and then sort
- # through lintians output later to see if its a fatal tag we detected, or not.
- # So we only run lintian once on all tags, even if we might reject on some, but not
- # reject on others.
- (fd, temp_filename) = utils.temp_filename()
+ # Setup the input file for lintian
+ fd, temp_filename = utils.temp_filename()
temptagfile = os.fdopen(fd, 'w')
for tags in lintiantags.values():
- for tag in tags:
- temptagfile.write("%s\n" % tag)
+ temptagfile.writelines(['%s\n' % x for x in tags])
temptagfile.close()
- # So now we should look at running lintian at the .changes file, capturing output
- # to then parse it.
- command = "lintian --show-overrides --tags-from-file %s %s" % (temp_filename, self.pkg.changes_file)
- (result, output) = commands.getstatusoutput(command)
+ try:
+ cmd = "lintian --show-overrides --tags-from-file %s %s" % \
+ (temp_filename, self.pkg.changes_file)
- # We are done with lintian, remove our tempfile and any symlinks we created
- os.unlink(temp_filename)
- for symlink in symlinked:
- os.unlink(symlink)
+ result, output = commands.getstatusoutput(cmd)
+ finally:
+ # Remove our tempfile and any symlinks we created
+ os.unlink(temp_filename)
- if (result == 2):
- utils.warn("lintian failed for %s [return code: %s]." % (self.pkg.changes_file, result))
- utils.warn(utils.prefix_multi_line_string(output, " [possible output:] "))
+ for symlink in symlinked:
+ os.unlink(symlink)
- parsed_tags = parse_lintian_output(output)
+ if result == 2:
+ utils.warn("lintian failed for %s [return code: %s]." % \
+ (self.pkg.changes_file, result))
+ utils.warn(utils.prefix_multi_line_string(output, \
+ " [possible output:] "))
def log(*txt):
if self.logger:
- self.logger.log([self.pkg.changes_file, "check_lintian"] + list(txt))
+ self.logger.log(
+ [self.pkg.changes_file, "check_lintian"] + list(txt)
+ )
+ # Generate messages
+ parsed_tags = parse_lintian_output(output)
self.rejects.extend(
generate_reject_messages(parsed_tags, lintiantags, log=log)
)
user_email_address = utils.whoami() + " <%s>" % (cnf["Dinstall::MyAdminAddress"])
self.Subst["__REJECTOR_ADDRESS__"] = user_email_address
self.Subst["__MANUAL_REJECT_MESSAGE__"] = reject_message
+ self.Subst["__REJECT_MESSAGE__"] = ""
self.Subst["__CC__"] = "Cc: " + cnf["Dinstall::MyEmailAddress"]
reject_mail_message = utils.TemplateSubst(self.Subst, rej_template)
# Write the rejection email out as the <foo>.reason file
################################################################################
def check_source_against_db(self, filename, session):
- """
- """
source = self.pkg.dsc.get("source")
version = self.pkg.dsc.get("version")
else:
# TODO: Record the queues and info in the DB so we don't hardcode all this crap
# Not there? Check the queue directories...
- for directory in [ "Accepted", "New", "Byhand", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
+ for directory in [ "New", "Byhand", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
if not Cnf.has_key("Dir::Queue::%s" % (directory)):
continue
in_otherdir = os.path.join(Cnf["Dir::Queue::%s" % (directory)], dsc_name)
source_epochless_version = re_no_epoch.sub('', source_version)
dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
found = False
- for q in ["Accepted", "Embargoed", "Unembargoed", "Newstage"]:
+ for q in ["Embargoed", "Unembargoed", "Newstage"]:
if cnf.has_key("Dir::Queue::%s" % (q)):
if os.path.exists(cnf["Dir::Queue::%s" % (q)] + '/' + dsc_filename):
found = True