def check_job_path(jobs_dir, job):
if 'path' not in job:
raise Exception('job does not have the "path" attribute: %s' % job)
if not isinstance(job['path'], basestring):
raise Exception('"path" attribute is not a string: %s' % job)
# check that 'path' is rooted in the same directory as the .vcsjob file
if job['path'].startswith('/'):
raise Exception('job path is not relative: %s' % job['path'])
path = os.path.normpath(os.path.join(jobs_dir, job['path']))
if not path.startswith(jobs_dir):
raise Exception('job path is not inside the job tree: %s' % path)
# also check that the job exists and is runnable
if not os.path.isfile(path):
raise Exception('no such file: %s' % path)
if not os.access(path, os.X_OK):
raise Exception('file is not executable: %s' % path)
if 'profiles' not in job:
job['profiles'] = None
评论列表
文章目录