Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# POSSIBILITY OF SUCH DAMAGE.
# Author Tully Foote/tfoote@willowgarage.com
from __future__ import with_statement
from linux_helpers import *
import os
import rosdep.base_rosdep
###### Arch SPECIALIZATION #########################
def pacman_detect(p):
return subprocess.call(['pacman', '-Q', p], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
class Arch(rosdep.base_rosdep.RosdepBaseOS):
def check_presence(self):
filename = "/etc/arch-release"
if os.path.exists(filename):
return True
return False
def get_version(self):
return ""
# arch didn't have a version parsing in cpp version
try:
filename = "/etc/issue"
if os.path.exists(filename):
with open(filename, 'r') as fh:
os_list = fh.read().split()
if os_list[0] == "Linux" and os_list[1] == "Arch":
def strip_detected_packages(self, packages):
return [p for p in packages if self.rpm_detect(p)]
def generate_package_install_command(self, packages, default_yes):
if not packages:
return "#No Packages to install"
if default_yes:
return "#Packages\nsudo yum -y install " + ' '.join(packages)
else:
return "#Packages\nsudo yum install " + ' '.join(packages)
###### Fedora SPECIALIZATION #########################
class Fedora(roslib.os_detect.Fedora, YumInstall, rosdep.base_rosdep.RosdepBaseOS):
"""This class provides the Rosdep OS API for by combining the Fedora
OSDetect API and the YumInstall API
"""
pass
###### END Fedora SPECIALIZATION ########################
###### Rhel SPECIALIZATION #########################
class Rhel(roslib.os_detect.Rhel, YumInstall, rosdep.base_rosdep.RosdepBaseOS):
"""This class provides the Red Hat Enterprise Linux Rosdep OS API
for by combining the RHEL OSDetect API and the YumInstall API
"""
pass
###### END Rhel SPECIALIZATION ########################
return (std_out.count("") == 1)
# Check equery for existence and compatibility (gentoolkit 0.3)
def equery_available():
if not os.path.exists("/usr/bin/equery"):
return False
cmd = ['equery', '-V']
pop = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = pop.communicate()
return "0.3." == stdout[8:12]
###### Gentoo SPECIALIZATION #########################
class Gentoo(roslib.os_detect.Gentoo, rosdep.base_rosdep.RosdepBaseOS):
def strip_detected_packages(self, packages):
if equery_available():
return [p for p in packages if equery_detect(p)]
else:
return packages
def generate_package_install_command(self, packages, default_yes):
if equery_available():
return "#Packages\nsudo emerge " + ' '.join(packages)
else:
return "#Packages\nsudo emerge -u " + ' '.join(packages)
# Tingfan Wu tingfan@gmail.com
import os
import roslib.os_detect
import rosdep.base_rosdep
###### Cygwin SPECIALIZATION #########################
def port_detect(p):
import subprocess
cmd = ['cygcheck', '-c', p]
pop = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(std_out, std_err) = pop.communicate()
return (std_out.count("OK") > 0)
class Cygwin(roslib.os_detect.Cygwin, rosdep.base_rosdep.RosdepBaseOS):
def strip_detected_packages(self, packages):
return [p for p in packages if not port_detect(p)]
def generate_package_install_command(self, packages, default_yes):
return "#Packages\napt-cyg -m ftp://sourceware.org/pub/cygwinports install " + ' '.join(packages)
###### END Cygwin SPECIALIZATION ########################
if __name__ == '__main__':
print "cygwin installed?", Cygwin().check_presence()
print "test port_detect(true)", port_detect('cygwin');
print "version", Cygwin().get_version()
def __init__(self, packages, command = "rosdep", robust = False):
os_list = [debian.RosdepTestOS(), debian.Debian(), debian.Ubuntu(), debian.Mint(), opensuse.OpenSuse(), redhat.Fedora(), redhat.Rhel(), arch.Arch(), osx.Osx(), gentoo.Gentoo(), cygwin.Cygwin(), freebsd.FreeBSD()]
# Make sure that these classes are all well formed.
for o in os_list:
if not isinstance(o, rosdep.base_rosdep.RosdepBaseOS):
raise RosdepException("Class [%s] not derived from RosdepBaseOS"%o.__class__.__name__)
# Detect the OS on which this program is running.
self.osi = roslib.os_detect.OSDetect(os_list)
self.yc = YamlCache(self.osi.get_name(), self.osi.get_version(), self.osi.get_os().installers)
self.packages = packages
rp = roslib.packages.ROSPackages()
self.rosdeps = rp.rosdeps(packages)
self.robust = robust
# Author Tully Foote/tfoote@willowgarage.com
import os
import rosdep.base_rosdep
from rosdep.linux_helpers import *
###### Macports SPECIALIZATION #########################
def port_detect(p):
cmd = ['port', 'installed', p]
pop = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(std_out, std_err) = pop.communicate()
return (std_out.count("(active)") > 0)
class Macports(rosdep.base_rosdep.RosdepBaseOS):
def check_presence(self):
filename = "/usr/bin/sw_vers"
if os.path.exists(filename):
return True
return False
def get_version(self):
return "macports" # macports is a rolling release and isn't versionsed
def get_name(self):
return "macports"
def strip_detected_packages(self, packages):
return [p for p in packages if not port_detect(p)]
def generate_package_install_command(self, packages, default_yes):
import os
import rosdep.base_rosdep
from rosdep.linux_helpers import *
import roslib.os_detect
###### Macports SPECIALIZATION #########################
def port_detect(p):
cmd = ['port', 'installed', p]
pop = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(std_out, std_err) = pop.communicate()
return (std_out.count("(active)") > 0)
class Osx(roslib.os_detect.Osx, rosdep.base_rosdep.RosdepBaseOS):
def __init__(self):
self.installers = {}
self.installers['pip'] = rosdep.installers.PipInstaller
self.installers['macports'] = rosdep.installers.MacportsInstaller
self.installers['default'] = rosdep.installers.MacportsInstaller
self.installers['source'] = rosdep.installers.SourceInstaller
def strip_detected_packages(self, packages):
return [p for p in packages if not port_detect(p)]
def generate_package_install_command(self, packages, default_yes):
if len(packages) < 1:
return "#No packages to install"
return "#Packages\nsudo port install " + ' '.join(packages)
interacting with rosdep. This defines all Ubuntu sepecific
methods, including detecting the OS/Version number. As well as
how to check for and install packages."""
def __init__(self):
self.installers = {}
self.installers['apt'] = rosdep.installers.AptInstaller
self.installers['pip'] = rosdep.installers.PipInstaller
self.installers['source'] = rosdep.installers.SourceInstaller
self.installers['default'] = rosdep.installers.AptInstaller
pass
###### END UBUNTU SPECIALIZATION ########################
###### Mint SPECIALIZATION #########################
class Mint(rosdep.base_rosdep.RosdepBaseOS):
""" This is an implementation of a standard interface for
interacting with rosdep. Mint is closely coupled to Ubuntu, it
will masquerade as ubuntu for the purposes of rosdep. """
def __init__(self):
self.mint_detector = roslib.os_detect.Mint()
self.version_map = {'11':'11.04',
'10':'10.10',
'9':'10.04',
'8':'9.10',
'7':'9.04',
'6':'8.10',
'5':'8.04'}
self.installers = {}
self.installers['apt'] = rosdep.installers.AptInstaller