Merge pull request #153 from mikaelarguedas/litteral_errorcodes

use python defined error codes rather than hardcoded integers
This commit is contained in:
Dirk Thomas 2017-10-04 14:37:47 -07:00 committed by GitHub
commit 546d8b8e2d
1 changed files with 4 additions and 3 deletions

View File

@ -39,6 +39,7 @@ executables. These do not run in a ROS environment.
from __future__ import print_function from __future__ import print_function
import errno
import os import os
try: try:
from cStringIO import StringIO from cStringIO import StringIO
@ -256,7 +257,7 @@ class LocalProcess(pmon.Process):
try: try:
os.makedirs(log_dir) os.makedirs(log_dir)
except OSError as e: except OSError as e:
if e.errno == 13: if e.errno == errno.EACCES:
raise RLException("unable to create directory for log file [%s].\nPlease check permissions."%log_dir) raise RLException("unable to create directory for log file [%s].\nPlease check permissions."%log_dir)
else: else:
raise RLException("unable to create directory for log file [%s]: %s"%(log_dir, e.strerror)) raise RLException("unable to create directory for log file [%s]: %s"%(log_dir, e.strerror))
@ -331,9 +332,9 @@ class LocalProcess(pmon.Process):
self.popen = subprocess.Popen(self.args, cwd=cwd, stdout=logfileout, stderr=logfileerr, env=full_env, close_fds=True, preexec_fn=os.setsid) self.popen = subprocess.Popen(self.args, cwd=cwd, stdout=logfileout, stderr=logfileerr, env=full_env, close_fds=True, preexec_fn=os.setsid)
except OSError as e: except OSError as e:
self.started = True # must set so is_alive state is correct self.started = True # must set so is_alive state is correct
if e.errno == 8: #Exec format error if e.errno == errno.ENOEXEC: #Exec format error
raise pmon.FatalProcessLaunch("Unable to launch [%s]. \nIf it is a script, you may be missing a '#!' declaration at the top."%self.name) raise pmon.FatalProcessLaunch("Unable to launch [%s]. \nIf it is a script, you may be missing a '#!' declaration at the top."%self.name)
elif e.errno == 2: #no such file or directory elif e.errno == errno.ENOENT: #no such file or directory
raise pmon.FatalProcessLaunch("""Roslaunch got a '%s' error while attempting to run: raise pmon.FatalProcessLaunch("""Roslaunch got a '%s' error while attempting to run:
%s %s