Advertisement
justnub

RUN.PY CODE

Dec 8th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. print("Growtopia Private server")
  2. addRed=False
  3. try:
  4. with open('C:\\Windows\\System32\\drivers\\etc\\hosts', 'r') as file:
  5. if "127.0.0.1 growtopia1.com" in file.read():
  6. print("Record growtopia1.com to localhost already found!")
  7. else:
  8. addRed=True;
  9. file.close()
  10. if addRed:
  11. with open('C:\\Windows\\System32\\drivers\\etc\\hosts', 'a') as file:
  12. file.write('\r\n127.0.0.1 growtopia1.com')
  13. print("Record growtopia1.com to localhost was added!")
  14. file.close()
  15. except:
  16. print("Windows hosts failed... Trying linux version (Maybe wine?)")
  17. try:
  18. with open('\\etc\\hosts', 'r+') as file:
  19. if "127.0.0.1 growtopia1.com" in file.read():
  20. print("Record growtopia1.com to localhost already found!")
  21. else:
  22. addRed=True;
  23. file.close()
  24. if addRed:
  25. with open('\\etc\\hosts', 'a') as file:
  26. file.write('\n127.0.0.1 growtopia1.com')
  27. print("Record growtopia1.com to localhost was added!")
  28. file.close()
  29. except:
  30. print("Unknown error while modifying hosts file???")
  31. print("Try run application as Administrator/Root or try to add host data manualy.")
  32. try:
  33. import subprocess
  34. subprocess.Popen([r"server.exe"])
  35. except:
  36. print("Server.exe not found? Move all files to same directory and relaunch or launch server.exe manually.")
  37. import sys
  38. httpd=None
  39. try:
  40. if sys.version_info[0] is 3:
  41. import http.server
  42. print("Launching HTTP server! (Python 3.x)")
  43. class ServerHandler(http.server.BaseHTTPRequestHandler):
  44. def do_POST(self):
  45. self.send_response(200)
  46. self.end_headers()
  47. self.wfile.write(str.encode("server|127.0.0.1\nport|17091\ntype|1\n#maint|Mainetrance message (Not used for now) -- Growtopia Noobs\n\nbeta_server|127.0.0.1\nbeta_port|17091\n\nbeta_type|1\nmeta|localhost\nRTENDMARKERBS1001"))
  48. server_address = ('', 80)
  49. httpd = http.server.HTTPServer(server_address, ServerHandler)
  50. print("HTTP server is running! Don't close this or GT will be unable to connect!")
  51. httpd.serve_forever()
  52. else:
  53. import SimpleHTTPServer
  54. import SocketServer
  55. print("Launching HTTP server! (Python 2.x)")
  56. class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  57. def do_POST(self):
  58. self.send_response(200)
  59. self.end_headers()
  60. self.wfile.write("server|127.0.0.1\nport|17091\ntype|1\n#maint|Mainetrance message (Not used for now) -- Growtopia Noobs\n\nbeta_server|127.0.0.1\nbeta_port|17091\n\nbeta_type|1\nmeta|localhost\nRTENDMARKERBS1001")
  61. #Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
  62. Handler = ServerHandler
  63. httpd = SocketServer.TCPServer(("", 80), Handler)
  64. print("HTTP server is running! Don't close this or GT will be unable to connect!")
  65. httpd.serve_forever()
  66. except:
  67. print("Port 80 is probably already used? Try close anything what can be running there or try run this app as Admin.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement