mapServer.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # MIT License
00004 #
00005 # Copyright (c) <2015> <Ikergune, Etxetar>
00006 #
00007 # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
00008 # (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
00009 # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
00010 # subject to the following conditions:
00011 #
00012 # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00013 #
00014 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00015 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
00016 # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00017 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018 
00019 # Import required Python code.
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         ## \brief Starts Map server thread
00038         MapThread = Thread(target=_launchMapServer)
00039         MapThread.daemon = True
00040         MapThread.start()
00041 
00042 
00043 def _launchMapServer():
00044     ## \brief If map_server is configured launches it
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)])


firos
Author(s): IƱigo Gonzalez, igonzalez@ikergune.com
autogenerated on Thu Jun 6 2019 17:51:04