Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 import os
00021 import getpass
00022 import subprocess
00023 from threading import Thread
00024
00025 from include.constants import MAP_SERVER_PORT, ROSBRIDGE_PORT
00026
00027 MAP_SERVER_PROCESS = None
00028
00029 mapserver_path = os.path.dirname(os.path.abspath(__file__)).replace("include", "")
00030 print(mapserver_path)
00031 start_command = "node mapserver.js " + str(MAP_SERVER_PORT) + " " + str(ROSBRIDGE_PORT)
00032
00033
00034 class MapServer:
00035 @staticmethod
00036 def load():
00037
00038 MapThread = Thread(target=_launchMapServer)
00039 MapThread.daemon = True
00040 MapThread.start()
00041
00042
00043 def _launchMapServer():
00044
00045 if(MAP_SERVER_PORT):
00046 if not os.path.exists(os.path.join(mapserver_path, 'node_modules')):
00047 text = "---------------------------------------------------------------------------------------\n"
00048 text += "---------------------------------------------------------------------------------------\n"
00049 text += "FIROS is going to install mapserver's dependencies, to do this it will need root access\n"
00050 text += "---------------------------------------------------------------------------------------\n"
00051 text += "---------------------------------------------------------------------------------------"
00052 print text
00053 os.system("cd {} && sudo npm install && sudo chown -R {} node_modules".format(mapserver_path, getpass.getuser()))
00054 subprocess.Popen(["node", mapserver_path + "mapserver.js", str(MAP_SERVER_PORT), str(ROSBRIDGE_PORT)])