Пример #1
0
    def _install_local_module(config):
        """Install a module from a local path."""
        installed = False
        config["path"] = os.path.expanduser(config["path"])

        installdir, _ = os.path.split(config["install_path"])
        if not os.path.isdir(installdir):
            os.makedirs(installdir, exist_ok=True)

        if os.path.isdir(config["path"]):
            shutil.copytree(config["path"], config["install_path"])
            installed = True

        if os.path.isfile(config["path"]):
            os.makedirs(config["install_path"], exist_ok=True)
            init_path = os.path.join(config["install_path"], "__init__.py")
            if file_is_ipython_notebook(config["path"]):
                convert_ipynb_to_script(config["path"], init_path)
            else:
                shutil.copyfile(config["path"], init_path)
            installed = True

        if not installed:
            _LOGGER.error("Failed to install from %s",
                          str(config["path"]))
Пример #2
0
    def _install_local_module(self, config):
        """Install a module from a local path.

        Args:
            config: dict of module config fields

        """
        installed = False
        config["path"] = os.path.expanduser(config["path"])

        installdir, _ = os.path.split(config["install_path"])
        if not os.path.isdir(installdir):
            os.makedirs(installdir, exist_ok=True)

        if os.path.isdir(config["path"]):
            shutil.copytree(config["path"], config["install_path"])
            installed = True

        if os.path.isfile(config["path"]):
            os.makedirs(config["install_path"], exist_ok=True)
            init_path = os.path.join(config["install_path"], "__init__.py")
            if file_is_ipython_notebook(config["path"]):
                convert_ipynb_to_script(config["path"], init_path)
            else:
                shutil.copyfile(config["path"], init_path)
            installed = True

        if not installed:
            _LOGGER.error("Failed to install from %s.", str(config["path"]))
        else:
            self.opsdroid.reload_paths.append(config["path"])
Пример #3
0
 def test_file_is_ipython_notebook(self):
     assert file_is_ipython_notebook("test.ipynb") is True
     assert file_is_ipython_notebook("test.py") is False
Пример #4
0
 def test_file_is_ipython_notebook(self):
     self.assertTrue(file_is_ipython_notebook('test.ipynb'))
     self.assertFalse(file_is_ipython_notebook('test.py'))
Пример #5
0
 def test_file_is_ipython_notebook(self):
     self.assertTrue(file_is_ipython_notebook('test.ipynb'))
     self.assertFalse(file_is_ipython_notebook('test.py'))