Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

daemon.py 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import os
  2. import daemon
  3. from argv.checkpoints import arg_checkpoints, set_arg_checkpoints, check_arg_checkpoints
  4. from argv.common import arg_debug, arg_help, arg_version
  5. from argv.run import arg_json_folder_name, arg_json_args, arg_n_core, arg_gpu, arg_cpu, arg_preferences, \
  6. arg_color_transfer, arg_ignore_size, arg_auto_resize_crop, arg_auto_resize, \
  7. arg_auto_rescale
  8. from argv.run.config import set_arg_preference, set_gpu_ids
  9. def init_daemon_sub_parser(subparsers):
  10. daemon_parser = subparsers.add_parser(
  11. 'daemon',
  12. description="Running dreampower on daemon mode.",
  13. help="Running dreampower on daemon mode.",
  14. add_help=False
  15. )
  16. daemon_parser.set_defaults(func=daemon.main)
  17. # conflicts handler
  18. processing_mod = daemon_parser.add_mutually_exclusive_group()
  19. scale_mod = daemon_parser.add_mutually_exclusive_group()
  20. # add daemon arguments
  21. arg_input(daemon_parser)
  22. arg_output(daemon_parser)
  23. arg_auto_rescale(scale_mod)
  24. arg_auto_resize(scale_mod)
  25. arg_auto_resize_crop(scale_mod)
  26. arg_ignore_size(daemon_parser)
  27. arg_color_transfer(daemon_parser)
  28. arg_preferences(daemon_parser)
  29. arg_cpu(processing_mod)
  30. arg_gpu(processing_mod)
  31. arg_checkpoints(daemon_parser)
  32. arg_n_core(daemon_parser)
  33. arg_json_args(daemon_parser)
  34. arg_json_folder_name(daemon_parser)
  35. arg_help(daemon_parser)
  36. arg_debug(daemon_parser)
  37. arg_version(daemon_parser)
  38. return daemon_parser
  39. def set_args_daemon_parser(args):
  40. set_arg_checkpoints(args)
  41. set_arg_preference(args)
  42. set_gpu_ids(args)
  43. def check_args_daemon_parser(parser, args):
  44. check_arg_input(parser, args)
  45. check_arg_output(parser, args)
  46. check_arg_checkpoints(parser, args)
  47. def arg_input(parser):
  48. parser.add_argument(
  49. "-i",
  50. "--input",
  51. help="Path directory to watching.",
  52. required=True
  53. )
  54. def arg_output(parser):
  55. parser.add_argument(
  56. "-o",
  57. "--output",
  58. help="Path of directory where the transformed photo(s) will be saved.",
  59. required=True
  60. )
  61. def check_arg_input(parser, args):
  62. if not args.input:
  63. parser.error("-i, --input INPUT is required.")
  64. if not os.path.isdir(args.input):
  65. parser.error("Input {} directory doesn't exist.".format(args.input))
  66. def check_arg_output(parser, args):
  67. if not args.output:
  68. parser.error("-o, --output OUTPUT is required.")
  69. if not os.path.isdir(args.output):
  70. parser.error("Output {} directory doesn't exist.".format(args.output))