def debug(args): port = int(args.port) data_path = utility.abspath(args.json) utility.check_file(data_path) app.config["DATA_PATH"] = data_path app.config["SECRET_KEY"] = "development key" app.run(debug=True, port=port)
def start(args): port = int(args.port) log_path = args.logfilepath lock_path = args.lockfile data_path = utility.abspath(args.json) utility.check_file(data_path) app.config["DATA_PATH"] = data_path app.config["SECRET_KEY"] = "development key" if not op.exists(lock_path): dc = DaemonContext(pidfile=PIDLockFile(lock_path), stderr=open(log_path, "w+"), working_directory=ROOT) with dc: app.run(port=port) else: raise exception.DataProcessorError("Server already stands.")
def test_check_file(self): tempfile = os.path.join(self.tempdir, "foo") relative_path = os.path.relpath(tempfile) with self.assertRaises(DataProcessorError): utility.check_file(tempfile) open(tempfile, "a").close() self.assertEqual(utility.check_file(tempfile), tempfile) self.assertEqual(utility.check_file(relative_path), tempfile) dir_path = os.path.join(self.tempdir, "bar") relative_path = os.path.relpath(dir_path) with self.assertRaises(DataProcessorError): utility.check_file(dir_path) os.mkdir(dir_path) with self.assertRaises(DataProcessorError): utility.check_file(dir_path) with self.assertRaises(DataProcessorError): utility.check_file(relative_path)