def paths(self):
s3 = boto3.client('s3')
pathattrib = [a.attrib['path'].strip() for a in self.dom.getroottree().iterfind('//*[@path]')]
pathnodes = [a.text.strip() for a in self.dom.getroottree().iterfind('//Path')]
errors = []
for p in pathattrib+pathnodes:
if re.match('^([A-Za-z]:|/)', p):
errors.append("Invalid absolute path detected: '{}'".format(p))
else:
# Now make sure the files really exist
filekey = os.path.join(self.projroot, p.replace("\\","/"))
try:
s3.head_object(Bucket=self.bucket, Key=filekey)
except ClientError, e:
errors.append("File not found on repository: {}".format(filekey))
if len(errors) > 0:
self.validators.append(ValidatorResult("Path Checking", "FAIL", errors))
else:
self.validators.append(ValidatorResult("Path Checking", "PASS"))
评论列表
文章目录