Exemple #1
0
    def uninstall(self, root="/", sudo="/usr/bin/sudo", Provider=None):
        """ Uninstall the job definition from the system.

        :param root: Override the root to uninstall from, useful for testing.
        :type root: str
        :param sudo: Override which sudo is used, useful for testing or for making
            it use gksudo instead.
        :type sudo: str
        :param provider: Override to use your own generator function for the system
            file preparation.
        :type provider: Provider
        """
        if Provider is None:
            Provider = providers.detect_provider()
        p = Provider(root, self)
        installation_files = p.generate_uninstall()

        if len(installation_files) == 0:
            print "Job not found, nothing to remove."
        else:
            print "Preparing to remove the following paths:"
            for filename in sorted(installation_files.keys()):
                print "  %s" % filename

            self._call_mutate(sudo, installation_files)
Exemple #2
0
    def install(self, root="/", sudo="/usr/bin/sudo", Provider=None):
        """ Install the job definition to the system.

        :param root: Override the root to install to, useful for testing.
        :type root: str
        :param sudo: Override which sudo is used, useful for testing or for making
            it use gksudo instead.
        :type sudo: str
        :param provider: Override to use your own generator function for the system
            file preparation.
        :type provider: Provider
        """
        # This is a recipe of files and their contents which is pickled up and
        # passed to a sudo process so that it can create the actual files,
        # without needing a ROS workspace or any other environmental setup.
        if Provider is None:
            Provider = providers.detect_provider()
        p = Provider(root, self)
        installation_files = p.generate_install()

        print "Preparing to install files to the following paths:"
        for filename in sorted(installation_files.keys()):
            print "  %s" % filename

        self._call_mutate(sudo, installation_files)
        p.post_install()
Exemple #3
0
def main():
    """ Implementation of the ``install`` script."""

    args = get_argument_parser().parse_args()

    pkg, pkgpath = args.pkgpath[0].split('/', 1)
    job_name = args.job or pkg.split('_', 1)[0]

    # Any unspecified arguments are on the args object as None. These are filled
    # in by the Job constructor when passed as Nones.
    j = robot_upstart.Job(name=job_name,
                          interface=args.interface,
                          user=args.user,
                          workspace_setup=args.setup,
                          rosdistro=args.rosdistro,
                          master_uri=args.master,
                          log_path=args.logdir,
                          systemd_after=args.systemd_after)

    for this_pkgpath in args.pkgpath:
        pkg, pkgpath = this_pkgpath.split('/', 1)
        if not pkg:
            print(
                "Unable to locate package your job launch is in."
                " Installation aborted. " + DESC_PKGPATH +
                "\npkgpath passed: {}.".format(pkgpath))
            return 1

        found_path = find_in_workspaces(project=pkg,
                                        path=pkgpath,
                                        first_match_only=True)
        if not found_path:
            print "Unable to locate path %s in package %s. Installation aborted." % (
                pkgpath, pkg)
            return 1

        if os.path.isfile(found_path[0]):
            # Single file, install just that.
            j.add(package=pkg, filename=pkgpath)
        else:
            # Directory found, install everything within.
            j.add(package=pkg, glob=os.path.join(pkgpath, "*"))

    if args.augment:
        j.generate_system_files = False
    if args.wait:
        j.roslaunch_wait = True

    provider = providers.detect_provider()
    if args.provider == 'upstart':
        provider = providers.Upstart
    if args.provider == 'systemd':
        provider = providers.Systemd
    if args.symlink:
        j.symlink = True

    j.install(Provider=provider)

    return 0