def start(): args = parse_args() if args.action == 'runserver': processname = 'celeryd' for line in os.popen("ps xa"): fields = line.split() pid = fields[0] stat = fields[2] process = fields[4] if stat == "Sl": try: line.index(processname) # Kill the Process. Change signal.SIGHUP to signal.SIGKILL if you like os.kill(int(pid), signal.SIGKILL) break except ValueError: pass for line in os.popen("ps xa"): fields = line.split() pid = fields[0] stat = fields[2] process = fields[4] try: line.index(processname) # Kill the Process. Change signal.SIGHUP to signal.SIGKILL if you like os.kill(int(pid), signal.SIGKILL) break except ValueError: pass subprocess.Popen(["python", "celery_manage.py", "celeryd"], env=os.environ) if args.ip_address: app.run(host=args.ip_address, debug=args.debug) else: app.run(debug=args.debug) if args.action == 'test': test_runner.run() if args.action == "generate-test-data": if args.file: image_handler.process_file(args.file) else: image_handler.process_file("test_file_upload.mha")
def process_file(filename): print("Starting to process file") image_handler.process_file(filename)