Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def assert_file_hash(filename, md5sum):
md5 = hashlib.md5()
with open(filename,'rb') as f:
for chunk in iter(lambda: f.read(8192), ''):
md5.update(chunk)
if md5sum != md5.hexdigest():
raise rosdep.core.RosdepException("md5sum check on %s failed. Expected %s got %s"%(filename, md5sum, md5.hexdigest()))
except yaml.scanner.ScannerError as ex:
raise rosdep.core.RosdepException("Failed to parse yaml in %s: Error: %s"%(contents, ex))
if "ROSDEP_DEBUG" in os.environ:
print "Downloaded manifest:\n{{{%s\n}}}\n"%self.manifest
self.install_command = self.manifest.get("install-script", "#!/bin/bash\n#no install-script specificd")
self.check_presence_command = self.manifest.get("check-presence-script", "#!/bin/bash\n#no check-presence-script\nfalse")
self.exec_path = self.manifest.get("exec-path", ".")
self.depends = self.manifest.get("depends", [])
self.tarball = self.manifest.get("uri")
if not self.tarball:
raise rosdep.core.RosdepException("uri required for source rosdeps")
self.alternate_tarball = self.manifest.get("alternate-uri")
self.tarball_md5sum = self.manifest.get("md5sum")
def get_installer(self, mode):
"""
Return the correct installer for a given OS from the
self.installer dict.
"""
try:
if not mode in self.installers:
raise rosdep.core.RosdepException("Invalid installation mode %s for %s"%(mode, self.get_name()))
return self.installers[mode]
except NameError as ex:
raise rosdep.core.RosdepException("Invalid installation mode %s for %s"%(mode, self.get_name()))
def get_installer(self, mode):
"""
Return the correct installer for a given OS from the
self.installer dict.
"""
try:
if not mode in self.installers:
raise rosdep.core.RosdepException("Invalid installation mode %s for %s"%(mode, self.get_name()))
return self.installers[mode]
except NameError as ex:
raise rosdep.core.RosdepException("Invalid installation mode %s for %s"%(mode, self.get_name()))
missing_packages = r.satisfy()
if not missing_packages:
return 0
else:
print("The following rosdeps are not installed but are required", missing_packages)
return 1
elif command == "install":
error = r.install(options.include_duplicates, options.default_yes)
if error:
print("rosdep install ERROR:\n%s"%error, file=sys.stderr)
return 1
else:
print("All required rosdeps installed successfully")
return 0
except core.RosdepException as e:
print("ERROR: %s"%e, file=sys.stderr)
return 1
try:
if command == "depdb":
print(r.depdb(verified_packages))
return 0
elif command == "what_needs":
print('\n'.join(r.what_needs(rdargs)))
return 0
elif command == "where_defined":
print(r.where_defined(rdargs))
return 0