main.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. from optparse import OptionParser
  2. from src.oracle import oracle
  3. from src.user import user
  4. def main():
  5. parser = OptionParser()
  6. parser.add_option("-o", "--oracle", action="store_true", dest="oracle", default=False, help="if true -> orcle will be run")
  7. parser.add_option("-u", "--user", action="store_true", dest="user", default=False, help="if true -> user will be run")
  8. parser.add_option("-s", "--server", dest="server", default="127.0.0.1", help="destination Server for feed data to Oracles")
  9. parser.add_option("-d", "--data", dest="data", default="", help="Data to send to destination server for response")
  10. parser.add_option("-b", "--broadcast", dest="broadcast", default="255.255.255.255", help="Broad cast IP")
  11. parser.add_option("-p", "--broadcast-port", dest="broadcastPort", default=6666, help="Broad cast Port")
  12. # parser.add_option("-h", "--help",action="store_true", dest="help", default=False)
  13. (options, args) = parser.parse_args()
  14. if len(args) >= 1 or options.oracle + options.user != 1:
  15. print("\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")
  16. parser.print_help()
  17. return
  18. if(options.oracle):
  19. oracle.run(broadcast=options.broadcast, broadcastPort=options.broadcastPort)
  20. if(options.user):
  21. user.run(data=options.data, server=options.server, broadcast=options.broadcast, broadcastPort=options.broadcastPort)
  22. if __name__ == '__main__':
  23. main()