main.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. from optparse import OptionParser
  2. from oracle.oracle import Oracle
  3. from user.user import User
  4. from command import install, comp
  5. import os
  6. from Utils import *
  7. def main():
  8. os.system("clear")
  9. parser = OptionParser()
  10. parser.add_option(
  11. "-i",
  12. "--installation",
  13. action="store_true",
  14. dest="installation",
  15. default=False,
  16. help="installation",
  17. )
  18. parser.add_option(
  19. "-o",
  20. "--oracle",
  21. action="store_true",
  22. dest="oracle",
  23. default=False,
  24. help="if true -> orcle will be run",
  25. )
  26. parser.add_option(
  27. "-u",
  28. "--user",
  29. action="store_true",
  30. dest="user",
  31. default=False,
  32. help="if true -> user will be run",
  33. )
  34. parser.add_option(
  35. "-s",
  36. "--server",
  37. dest="server",
  38. default="api.spacexdata.com",
  39. help="destination Server for feed data to Oracles",
  40. )
  41. parser.add_option(
  42. "-d",
  43. "--data",
  44. dest="data",
  45. default="474554202f76332f736869707320485454502f312e310d0a557365722d4167656e743a20576765742f312e32302e3320286d696e67773332290d0a4163636570743a202a2f2a0d0a4163636570742d456e636f64696e673a206964656e746974790d0a486f73743a206170692e737061636578646174612e636f6d0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a0d0a17",
  46. help="Data to send to destination server for response",
  47. )
  48. parser.add_option(
  49. "-b",
  50. "--broadcast",
  51. dest="broadcast",
  52. default="255.255.255.255",
  53. help="Broad cast IP",
  54. )
  55. parser.add_option(
  56. "-p",
  57. "--broadcast-port",
  58. dest="broadcastPort",
  59. default=6666,
  60. help="Broad cast Port",
  61. )
  62. parser.add_option("-c", "--compile", dest="compile", help="file compile")
  63. (options, args) = parser.parse_args()
  64. if len(args) >= 1 or (
  65. options.oracle + options.user != 1
  66. and not options.installation
  67. and not options.compile
  68. ):
  69. rBackPrint(
  70. "ERROR",
  71. "\n\n\tWhat do you want to run? Oracle or User? \n\n\tplease use -o OR -u. \n\n\tFor more Info you can use -h or --help or i can do it for you\n \n\t~~~ GOOD LUCK :) ~~~\n",
  72. )
  73. parser.print_help()
  74. return
  75. if options.compile:
  76. comp(options.compile)
  77. elif options.installation:
  78. install()
  79. elif options.oracle:
  80. Oracle(broadcast=options.broadcast,
  81. broadcastPort=options.broadcastPort)
  82. elif options.user:
  83. User(
  84. data=options.data,
  85. server=options.server,
  86. broadcast=options.broadcast,
  87. broadcastPort=options.broadcastPort,
  88. ).run()
  89. if __name__ == "__main__":
  90. main()