- reason = args[0]
- sh = shell.Shell()
- # XXX: this should be abstracted away!
- if os.path.exists(".git/WIZARD_REPO"):
- util.chdir(sh.eval('git', 'config', 'remote.origin.url'))
- open('.scripts/blacklisted', 'w').write(reason + "\n")
+ # Directory information not transferred via command line, so this
+ # will not error due to the changed directory.
+ shell.drop_priviledges(".", options.log_file)
+ command.chdir_to_production()
+ production = deploy.ProductionCopy(".")
+ production.verify()
+ if options.delete:
+ try:
+ os.unlink(production.blacklisted_file)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ logging.warning("No-op: application was not blacklisted")
+ else:
+ raise
+ else:
+ open(production.blacklisted_file, 'w').write(args[0] + "\n")