Пример #1
0
    def generate(self, output):

        banner(f"Creating {output}", c="&")

        files = []
        for entry in self.docs.entries:

            if entry.kind in ["section", "header"]:
                url = entry.url
                path = entry.path
                basename = entry.basename
                local = entry.destination
                files.append(local)

        banner("Finding Contents")

        print("Number of included Sections:", len(self.docs.entries))

        banner("Creating Command")

        files = " ".join(files)

        # metadata["stylesheet"] = path_expand(metadata["stylesheet"])
        title = self.metadata["title"]

        dirs = []
        for section in self.docs.entries:
            if section["kind"] == "section":
                # pprint(section)
                path = section["path"]
                dirs.append(path_expand(f"./dest/book/{path}"))
        dirs = set(dirs)
        # dirs = find_image_dirs(directory='./dest')

        if output in ["pdf"]:
            create_metadata(self.metadata,
                            "./dest/book/metadata.txt",
                            kind="latex")
        else:
            create_metadata(self.metadata,
                            "./dest/book/metadata.txt",
                            kind="epub")

        from cloudmesh.common.Shell import Shell
        r = Shell.cat("./dest/book/metadata.txt")
        if self.verbose:
            banner(r)

        create_css(self.metadata, "./dest/book/epub.css")

        directories = (":".join(dirs))
        metadata = path_expand("./dest/book/metadata.txt")
        filename = self.metadata["filename"]

        for file in ["report.bib", "references.bib"]:
            try:
                copyfile(file, f"dest/{file}")
            except:
                pass
        cat_bibfiles("./dest", "./dest/all.bib")

        bib = path_expand("./dest/all.bib")
        csl = path_expand("./dest/book/ieee-with-url.csl")

        bibfile = f" --metadata link-citations=true --bibliography={bib} --csl={csl}"
        all_bibs = readfile("./dest/all.bib")
        css_style = pkg_resources.resource_filename(
            "bookmanager", 'template/epub/ieee-with-url.csl')

        copyfile(css_style, path_expand("./dest/book/ieee-with-url.csl"))

        if "@" not in all_bibs:
            bibfile = ""

        for f in [
                'template/latex/listings-setup.tex',
                'template/latex/eisvogel.latex', 'template/empty.md'
        ]:
            source = pkg_resources.resource_filename("bookmanager", f)
            _filename = os.path.basename(source)
            copyfile(source, f"dest/{_filename}")

        options = "--toc --toc-depth=6  --number-sections -F pandoc-crossref --citeproc --from markdown-smart"
        resources = f"--resource-path={directories}"
        markdown = "--verbose  --filter pandoc-crossref --citeproc -f markdown+emoji+smart --indented-code-classes=bash,python,yaml"
        pdf_options = "--verbose -f markdown+emoji+smart --listings --indented-code-classes=bash,python,yaml" \
                      " --include-in-header ./dest/listings-setup.tex --template ./dest/eisvogel "

        # GGGG markdown = "--verbose -f markdown+emoji --indented-code-classes=bash,python,yaml"
        # fonts = '-V mainfonts="DejaVu Sans"'
        pdffonts = ''

        embed = [
            "DejaVuSerif-Bold.ttf", "DejaVuSerif-BoldItalic.ttf",
            "DejaVuSerif-Italic.ttf", "DejaVuSerif.ttf",
            "DejaVuSerifCondensed-Bold.ttf",
            "DejaVuSerifCondensed-BoldItalic.ttf",
            "DejaVuSerifCondensed-Italic.ttf", "DejaVuSerifCondensed.ttf"
        ]
        embed = [
            "OpenSans-Bold.ttf",
            "OpenSans-BoldItalic.ttf",
            "OpenSans-Emoji.ttf",
            "OpenSans-ExtraBold.ttf",
            "OpenSans-ExtraBoldItalic.ttf",
            "OpenSans-Italic.ttf",
            "OpenSans-Light.ttf",
            "OpenSans-LightItalic.ttf",
            "OpenSans-Regular.ttf",
            "OpenSans-Semibold.ttf",
            "OpenSans-SemiboldItalic.ttf",
            "OpenSansEmoji.ttf",
        ]

        # ignoring font embedding
        epubfonts = ''
        #for font in embed:
        #    epubfonts = epubfonts + f' --epub-embed-font=fonts/{font}'

        if output in ["epub"]:

            epub = path_expand(f"./dest/{filename}")
            # noinspection PyPep8
            command = f'cd dest/book; pandoc {options} {markdown} ' \
                      f' {epubfonts} {resources} {bibfile} ' \
                      f' -o {epub} {files}' \
                      f' {metadata}'
            if self.verbose:
                self.print_command(command)

        elif output == "pdf":

            create_metadata(self.metadata,
                            "./dest/book/metadata.txt",
                            kind="latex")

            pdf = path_expand(f"./dest/{filename}").replace(".epub", ".pdf")
            tex = path_expand(f"./dest/{filename}").replace(".epub", ".tex")
            md = path_expand(f"./dest/{filename}").replace(".epub", ".md")
            metadata = "./dest/book/metadata.txt"

            # path= Path("../../bookmanager/bookmanager/template/latex/eisvogel").resolve()
            book = "-V titlepage=true"
            #latex = f"--template {path} --pdf-engine=xelatex"
            # latex = f"--pdf-engine=pdflatex --indented-code-classes=bash,python,yaml"
            latex = f"--pdf-engine=pdflatex --indented-code-classes=bash,python,yaml"

            command = f'pandoc' \
                      f' {files} ' \
                      f' --to=markdown > {md}'
            self.print_command(command)
            os.system(command)

            content = readfile(md)
            content = content \
                .replace("µ","micro") \
                .replace(":cloud:","\\faGithub")\
                .replace(":o2:","\\faBug")\
                .replace("\\lstinline!\\faBug!","\\faBug")
            writefile(md, content)

            command = f'pandoc -s {options} {pdf_options} {pdffonts}' \
                      f' {bibfile} {latex} {book} {resources} ' \
                      f' {md} ' \
                      f' {metadata} --from=markdown -o {pdf}'

        elif output == "html":
            metadata = "./dest/metadata.txt"
            options = "--toc --number-sections"
            command = f'pandoc {options} -o ./dest/book.html {files}'

        elif output == "docx":
            metadata = "./dest/metadata.txt"
            options = "--toc --number-sections"
            command = f'pandoc {options} -o ./dest/book.docx {files}'

        elif output in ["md", "markdown"]:
            metadata = "./dest/metadata.txt"
            options = "--toc --number-sections -f markdown+smart"
            command = f'pandoc {options} -o ./dest/book.md {files}'

        elif output in ["tex"]:
            metadata = "./dest/metadata.txt"
            options = "--toc --number-sections"
            command = f'pandoc {options} -o ./dest/book.tex {files}'
        else:
            raise ValueError(
                f"this output format is not yet supported: {output}")

        if self.verbose:
            banner("COMMAND")
            self.print_command(command)
        os.system(command)
        try:
            os.system("sync")
        except:
            pass
Пример #2
0
    def do_vbox(self, args, arguments):
        """
        ::

          Usage:
            vbox version [--format=FORMAT]
            vbox image list [--format=FORMAT]
            vbox image find KEYWORDS...
            vbox image add NAME
            vbox image delete NAME
            vbox vm list [--format=FORMAT] [-v]
            vbox vm delete NAME
            vbox vm config [NAME]
            vbox vm ip [NAME] [--all]
            vbox vm create [NAME] ([--memory=MEMORY] [--image=IMAGE] [--script=SCRIPT] | list)
            vbox vm boot [NAME] ([--memory=MEMORY] [--image=IMAGE] [--port=PORT] [--script=SCRIPT] | list)
            vbox vm ssh [NAME] [-e COMMAND]
        """

        arguments.format = arguments["--format"] or "table"
        arguments.verbose = arguments["-v"]
        arguments.all = arguments["--all"]

        print(arguments)

        if arguments.version:
            versions = {
                "vbox": {
                    "attribute": "Vagrant Version",
                    "version": cm4.vbox.version(),
                },
                "cloudmesh-vbox": {
                    "attribute": "cloudmesh vbox Version",
                    "version": __version__
                }
            }
            _LIST_PRINT(versions, arguments.format)

        elif arguments.image and arguments.list:
            l = VboxProvider.list_images()

            _LIST_PRINT(l, arguments.format, order=["name", "provider", "date"])

        elif arguments.image and arguments.add:
            try:
                l = VboxProvider.add_image(arguments.NAME)
                print(l)
            except Exception as e:
                print(e)
            return ""

        elif arguments.image and arguments.delete:
            try:
                l = VboxProvider.delete_image(arguments.NAME)
                print(l)
            except Exception as e:
                print(e)
            return ""


        elif arguments.image and arguments.find_image:

            VboxProvider.find_image(arguments.KEYWORDS)
            return ""

        elif arguments.vm and arguments.list:

            l = VboxProvider().nodes()
            _LIST_PRINT(l,
                        arguments.format,
                        order=["name", "state", "id", "provider", "directory"])
            return ""

        elif arguments.create and arguments.list:

            result = Shell.cat("{NAME}/Vagrantfile".format(**arguments))
            if result is not None:
                print(result)
            return ""

        elif arguments.create:

            d = defaults()

            arguments.memory = arguments["--memory"] or d.memory
            arguments.image = arguments["--image"] or d.image
            arguments.script = arguments["--script"] or d.script

            server = VboxProvider()
            server.create(
                name=arguments.NAME,
                memory=arguments.memory,
                image=arguments.image,
                script=arguments.script)

        elif arguments.config:

            # arguments.NAME
            d = VboxProvider().info(name=arguments.NAME)

            result = Printer.attribute(d, output=arguments.format)

            print(result)

        elif arguments.ip:

            data = []
            result = VboxProvider().execute(arguments.NAME, "ifconfig")
            if result is not None:
                lines = result.splitlines()[:-1]
                for line in lines:
                    if "inet addr" in line:
                        line = line.replace("inet addr", "ip")
                        line = ' '.join(line.split())
                        _adresses = line.split(" ")
                        address = {}
                        for element in _adresses:
                            attribute, value = element.split(":")
                            address[attribute] = value
                        data.append(address)
            if arguments.all:
                d = {}
                i = 0
                for e in data:
                    d[str(i)] = e
                    i = i + 1
                result = Printer.attribute(d, output=arguments.format)
                print(result)
            else:
                for element in data:
                    ip = element['ip']
                    if ip == "127.0.0.1" or ip.startswith("10."):
                        pass
                    else:
                        print(element['ip'])


        elif arguments.boot:

            d = defaults()

            arguments.memory = arguments["--memory"] or d.memory
            arguments.image = arguments["--image"] or d.image
            arguments.script = arguments["--script"] or d.script
            arguments.port = arguments["--port"] or d.port

            node = VboxProvider().boot(
                name=arguments.NAME,
                memory=arguments.memory,
                image=arguments.image,
                script=arguments.script,
                port=arguments.port)

        elif arguments.delete:

            result = VboxProvider().delete(name=arguments.NAME)
            print(result)

        elif arguments.ssh:

            if arguments.COMMAND is None:
                os.system("cd {NAME}; vbox ssh {NAME}".format(**arguments))
            else:
                result = VboxProvider().execute(arguments.NAME, arguments.COMMAND)
                if result is not None:
                    lines = result.splitlines()[:-1]
                    for line in lines:
                        print(line)

        else:

            print("use help")

        result = ""
        return result
Пример #3
0
    def do_vbox(self, args, arguments):
        """
        ::

          Usage:
            vbox version [--output=OUTPUT]
            vbox image list [--output=OUTPUT]
            vbox image find KEYWORDS...
            vbox image add NAME
            vbox image delete NAME
            vbox vm info NAME
            vbox vm list [--output=OUTPUT] [-v]
            vbox vm delete NAME
            vbox vm ip [NAME] [--all]
            vbox vm create [NAME] ([--memory=MEMORY] [--image=IMAGE] [--port=PORT] [--script=SCRIPT]  | list)
            vbox vm boot [NAME] ([--memory=MEMORY] [--image=IMAGE] [--port=PORT] [--script=SCRIPT] | list)
            vbox vm ssh [NAME] [-e COMMAND]
        """

        arguments.output = arguments["--output"] or "table"
        arguments.verbose = arguments["-v"]
        arguments.all = arguments["--all"]

        #
        # ok
        #
        def list_images():
            images = Provider().images()
            _LIST_PRINT(images,
                        arguments.output,
                        order=["name", "provider", "version"])

        #
        # ok
        #
        # noinspection PyShadowingNames
        def image_command(func):
            try:
                images = func(arguments.NAME)
                print(images)
                images()
            except Exception as e:
                print(e)
            return ""

        #
        # ok
        #
        if arguments.version:
            p = Provider()

            versions = {
                "cm": {
                    "attribute": "cm",
                    "description": "Cloudmesh vbox Version",
                    "version": __version__
                },
                "vbox": {
                    "attribute": "vbox",
                    "description": "Vagrant Version",
                    "version": p.version()
                }
            }
            result = Printer.write(
                versions,
                order=["attribute", "version", "description"],
                output=arguments.output)
            print(result)

        #
        # ok
        #
        elif arguments.image and arguments.list:
            list_images()
        #
        # ok
        #
        elif arguments.image and arguments.delete:
            image_command(Provider().delete_image)
        #
        # ok
        #
        elif arguments.image and arguments.put:
            image_command(Provider().add_image)

        #
        # ok
        #
        elif arguments.image and arguments.find:
            Provider().find_image(arguments.KEYWORDS)
            return ""

        #
        # ok, but only vagrant details
        #
        elif arguments.vm and arguments.list:

            provider = Provider().vagrant_nodes()
            _LIST_PRINT(provider,
                        arguments.output,
                        order=["name", "state", "id", "provider", "directory"])
            return ""

        #
        # unclear: this function is unclear
        #
        elif arguments.create and arguments.list:

            result = Shell.cat("{NAME}/Vagrantfile".format(**arguments))
            if result is not None:
                print(result)
            return ""

        elif arguments.create:

            d = defaults()

            print("LLLL", d)

            arguments.memory = arguments["--memory"] or d.memory
            arguments.image = arguments["--image"] or d.image
            arguments.script = arguments["--script"] or d.script
            arguments.port = arguments["--port"] or d.port

            server = Provider()
            server.create(**arguments)

        elif arguments.info:

            # arguments.NAME
            d = Provider().info(name=arguments.NAME)

            result = Printer.write(d, output=arguments.output)

            print(result)

        elif arguments.ip:

            data = []
            result = Provider().execute(arguments.NAME, "ifconfig")
            if result is not None:
                lines = result.splitlines()[:-1]
                for line in lines:
                    if "inet addr" in line:
                        line = line.replace("inet addr", "ip")
                        line = ' '.join(line.split())
                        _adresses = line.split(" ")
                        address = {}
                        for element in _adresses:
                            attribute, value = element.split(":")
                            address[attribute] = value
                        data.append(address)
            if arguments.all:
                d = {}
                i = 0
                for e in data:
                    d[str(i)] = e
                    i = i + 1
                result = Printer.attribute(d, output=arguments.output)
                print(result)
            else:
                for element in data:
                    ip = element['ip']
                    if ip == "127.0.0.1" or ip.startswith("10."):
                        pass
                    else:
                        print(element['ip'])

        elif arguments.boot:

            d = defaults()

            pprint(d)

            arguments.memory = arguments["--memory"] or d.memory
            arguments.image = arguments["--image"] or d.image
            arguments.script = arguments["--script"] or d.script
            arguments.port = arguments["--port"] or d.port

            node = Provider().boot(name=arguments.NAME,
                                   memory=arguments.memory,
                                   image=arguments.image,
                                   script=arguments.script,
                                   port=arguments.port)

        elif arguments.delete:

            result = Provider().delete(name=arguments.NAME)
            print(result)

        elif arguments.ssh:

            if arguments.COMMAND is None:
                os.system("cd {NAME}; vbox ssh {NAME}".format(**arguments))
            else:
                result = Provider().execute(arguments.NAME, arguments.COMMAND)
                if result is not None:
                    lines = result.splitlines()[:-1]
                    for line in lines:
                        print(line)

        else:

            print("use help")

        result = ""
        return result
Пример #4
0
    def do_robot(self, args, arguments):
        """
        ::

          Usage:
                robot welcome
                robot osx install
                robot osx driver
                robot image fetch
                robot probe [--format=FORMAT]
                robot flash erase [--dryrun]
                robot flash python [--dryrun]
                robot test
                robot run PROGRAM
                robot credentials set SSID USERNAME PASSWORD
                robot put (credentials | cred)
                robot list (credentials | cred)
                robot login
                robot set PORT NOT IMPLEMENTED
                robot ls [PATH]
                robot put [-o] SOURCE [DESTINATION]
                robot get PATH
                robot rm PATH
                robot rmdir PATH
                robot dance FILE IPS
                robot inventory list [--cat] [--path=PATH] [ID]
                robot inventory export FILENAME
                robot reset
                
          Arguments:
              FILE   a file name

          Options:
              -f      specify the file
        """

        # pprint(arguments)

        # "wget http://micropython.org/resources/firmware/esp8266-20170108-v1.8.7.bin"

        arguments.dryrun = arguments["--dryrun"]

        def _run(command):
            print(command)
            if arguments.dryrun:
                print(command)
            else:
                os.system(command)

        def _continue(msg):
            if not arguments.dryrun:
                c = yn_choice(msg, default='y')

        if arguments.welcome:
            print(self.Banner.show())

        elif arguments.login:

            p = Probe()
            Console.error(
                "If you do not see a >>> please press the reset button.")
            print(p)

            data = {'tty': p.tty, 'baudrate': "115200"}

            # if 'tty.SLAB_USBtoUART' in p.tty:
            #    data["baudrate"] = "9600"
            # else:
            #    data["baudrate"] = "115200"

            os.system(
                "picocom --imap lfcrlf -b {baudrate} {tty}".format(**data))

        elif arguments.flash and arguments.erase:

            p = Probe()
            print(p.tty)
            print("Please press the right buttons")

            _continue("continue?")
            command = "esptool.py --port {} erase_flash".format(p.tty)
            _run(command)

        elif arguments.flash and arguments.python:

            p = Probe()
            print(p.tty)
            print("Please press the right buttons")

            _continue("continue?")

            d = {
                "baud": str(9600 * 6),
                "dir": ".",
                "image": "esp8266-20170108-v1.8.7.bin",
                "port": p.tty
            }

            if 'tty.SLAB_USBtoUART' in p.tty:
                d["baud"] = str(460800)

            command = "esptool.py --port {port} --baud {baud} write_flash --flash_size=detect -fm dio 0x00000 {image}".format(
                **d)
            _run(command)
            # "esptool.py --port /dev/tty.wchusbserial1410 --baud 9600 write_flash --flash_size=detect -fm dio 0x00000 esp8266-20170108-v1.8.7.bin"

        elif arguments.osx and arguments.install:

            o = sys.platform

            print(o)

            if sys.platform == 'darwin':
                if Shell.command_exists("brew"):
                    pass
                else:
                    os.system(
                        '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
                    )

                os.system("pip install pyserial")
                #
                # INSTALLING COMMANDS WITH BREW
                #
                for package in ["lua", "picocom", "wget"]:
                    try:
                        print("installing command", package)
                        r = Shell.which(package)
                        if r is None:
                            r = Brew.install(package)
                        else:
                            print("    [OK]", package, "already installed")
                    except Exception as e:
                        print("Error", e, type(e))
                #
                # INSTALLING LIBRARIES WITH BREW
                #
                # libusb-compat
                for package in ["libusb", "mosquitto"]:
                    try:
                        print("installing", package)
                        r = Brew.install(package)
                        if r is None:
                            r = Brew.install(package)
                        else:
                            Console.error(
                                package +
                                " package already installed. skipping.")
                    except Exception as e:
                        print("Error", e, type(e))
                #
                # INSTALLING CASK LIBRARIES AND COMMANDS WITH BREW
                #
                # libusb-compat
                for package in ["adafruit-arduino",
                                "pycharm-ce"]:  # "aquamacs"
                    try:
                        print("installing", package)

                        os.system("brew cask install {}".format(package))

                    except Exception as e:
                        print("Error", e, type(e))

            if sys.platform == 'linux':
                Console.error(
                    "Linux not yet supported. Install lua and picocom.")
            return ""

        elif arguments.osx and arguments.driver:

            os.system(
                "brew tap mengbo/ch340g-ch34g-ch34x-mac-os-x-driver https://github.com/mengbo/ch340g-ch34g-ch34x-mac-os-x-driver"
            )
            os.system("brew cask install wch-ch34x-usb-serial-driver")

        elif arguments.probe:

            output_format = arguments["--format"] or "table"
            try:
                p = Probe()
                d = p.probe()

                print(Printer.attribute(d, output=output_format))

            except Exception as e:

                Error.traceback(error=e, debug=True, trace=True)

            return ""

        elif arguments.image and arguments.fetch:

            try:

                if os.path.isfile("esp8266-20170108-v1.8.7.bin"):
                    print("... image already downloaded")
                else:
                    os.system(
                        "wget http://micropython.org/resources/firmware/esp8266-20170108-v1.8.7.bin"
                    )

                    # g = Git()
                    # r = g.fetch()

            except Exception as e:

                Error.traceback(error=e, debug=True, trace=True)

            return ""

        elif arguments.run:

            p = Probe()
            d = {"port": p.tty, "program": arguments.PROGRAM}
            os.system("ampy --port {port} run {program}".format(**d))

        elif arguments.test:

            p = Probe()
            d = {"port": p.tty}
            test = textwrap.dedent("""
            n=3
            print('Count to', n)
            for i in range(1, n+1):
                print(i)
            """)
            with open("test.py", "w") as f:
                f.write(test)
            os.system("ampy --port {port} run test.py".format(**d))

        elif arguments.reset:

            p = Probe()
            d = {"port": p.tty}
            test = textwrap.dedent("""
            import machine
            machine.reset()
            """)
            with open("tmp-reset.py", "w") as f:
                f.write(test)
            os.system("ampy --port {port} run tmp-reset.py".format(**d))
            os.remove("tmp-reset.py")

        elif arguments.credentials and arguments.set:
            try:
                net = Network(ssid=arguments.SSID,
                              username=arguments.USERNAME,
                              password=arguments.PASSWORD)

            except Exception as e:
                Error.traceback(e)

        elif (arguments.credentials or arguments.cred) and arguments.put:
            try:
                filename = path_expand("~/.cloudmesh/robot/credentials.txt")
                p = Probe()
                #   print (p.tty)
                ampy = Ampy(p.tty)
                ampy.put(filename, "credentials.txt", False)
            except Exception as e:
                Error.traceback(e)
                sys.exit(1)

        elif arguments.put:
            try:
                t = StopWatch()
                t.start("put")

                size = os.path.getsize(arguments.SOURCE)

                optimize = arguments["-o"]
                p = Probe()
                ampy = Ampy(p.tty)
                ampy.put(arguments.SOURCE,
                         dest=arguments.DESTINATION,
                         optimize=optimize)
                t.stop("put")
                t.print("Time:", "put")
                print("Rate:", "{0:.2f}".format(size / t.get("put") / 1024),
                      "KB/s")
            except Exception as e:
                Error.traceback(e)

        elif arguments.credentials and arguments.list:
            try:
                p = Probe()
                ampy = Ampy(p.tty)
                filename = path_expand(
                    "~/.cloudmesh/robot/credentials.txt.robot")
                ampy.get("credentials.txt", filename)
                r = Shell.cat(filename)
                print(r)
                os.remove(filename)
            except Exception as e:
                Error.traceback(e)

        elif arguments.ls:
            try:
                p = Probe()
                ampy = Ampy(p.tty)
                r = ampy.ls()
                print(r)
            except Exception as e:
                Error.traceback(e)

        elif arguments.rm:
            try:
                p = Probe()
                ampy = Ampy(p.tty)
                ampy.rm(arguments.PATH)
            except Exception as e:
                Error.traceback(e)

        elif arguments.rmdir:
            try:
                p = Probe()
                ampy = Ampy(p.tty)
                ampy.rmdir(arguments.PATH)
            except Exception as e:
                Error.traceback(e)

        elif arguments.mkdir:
            try:
                p = Probe()
                ampy = Ampy(p.tty)
                ampy.mkdir(arguments.PATH)
            except Exception as e:
                Error.traceback(e)

        elif arguments.dance:

            pprint(arguments)

            from cloudmesh.robot.turtles import Car, Cars
            import turtle

            iplist = Parameter.expand(arguments.IPS)

            print(iplist)

            ips = []
            i = 1
            for ip in iplist:
                spec = [i, ip]
                ips.append(spec)
                i = i + 1
            print("IPS", ips)

            try:

                colors = [
                    'blue', 'red', 'green', 'oragne', 'gray', 'brown', 'cyan',
                    'pink', 'purple', 'tomato'
                ]

                cars = Cars(ips)

                print(cars)
                cars.read_dance(arguments.FILE)

                wn = turtle.Screen()  # creates a graphics window

                # def a():
                for i in range(0, len(ips)):
                    car = Car(i + 1, "robi" + str(i + 1), ips[i], colors[i])
                    cars.add(car)

                cars.run()

                wn.exitonclick()

            except Exception as e:
                Error.traceback(e)

        elif arguments.inventory and arguments.export:

            filename = arguments.FILENAME
            inventory = NetworkInventory(
                path_expand('~/.cloudmesh/robot/inventory.txt'))
            inventory.export(filename)

        elif arguments.inventory:

            def load_inventory(path):
                with open(path) as stream:
                    try:
                        d = yaml.safe_load(stream)
                    except Exception as e:
                        print("problem loading file", e)

                for id in d:
                    d[id]['id'] = str(id)
                return d

            path = path_expand(arguments["--path"]
                               or "~/.cloudmesh/robot/inventory.txt")

            print(path)

            if not os.path.isfile(path):
                print("ERROR: file does not exist")
                sys.exit(1)

            if arguments.ID:
                d = load_inventory(path)
                if arguments["--cat"]:
                    result = d[int(arguments.ID)]

                else:
                    result = Printer.attribute(d[int(arguments.ID)])
                print(result)

            elif arguments["--cat"]:
                with open(path) as stream:
                    try:
                        content = stream.read()
                        print(content)
                    except Exception as e:
                        print("problem loading file", e)

            else:

                d = load_inventory(path)
                table = Printer.dict(
                    d, order=['id', 'name', 'ip', 'mac', 'chipid'])

                print(table)
        '''