try:
quality = job['data']['fields']['quality']
except KeyError:
quality='2222'
except TypeError:
quality='1111'
else:
if quality == '':
quality='33333'
else:
quality = job['data']['fields']['quality']
my_file = open(os.path.join(pathToTmpDir, 'quality.json'), 'w')
my_file.write(quality)
my_file.close()