How to use mirage - 10 common examples

To help you get started, we’ve selected a few mirage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shotastage / mirage-django-lts / mirage / scaffold / launch.py View on Github external
os.chdir(django_path)
        except:
            log("Failed to move Django project directory.", withError = True,
                errorDetail = "Config directory: " + str(os.getcwd()) + "/" + mfile.get_django(Category.django_path))
            return

        try:
            try:
                devnull = open('/dev/null', 'w')
                server = subprocess.Popen(shlex.split("mi internal_server_launch"), stdout=devnull, stderr=devnull)
            except:
                log("Failed to launch server!", withError = True)

            log("Launching shell...")
            log("Server listening started on http://127.0.0.1:5050")
            log("Ctl + C to exit scaffold.")
            time.sleep(1)
            webbrowser.open("http://127.0.0.1:5050")
            server.wait()
    
        except KeyboardInterrupt:
            server.kill()
github shotastage / mirage-django-lts / mirage / package / package.py View on Github external
limitations under the License.
"""

import os

try: # pip >= 10
    from pip._internal.utils.misc import get_installed_distributions
except ImportError:  # pip < 10
    from pip import get_installed_distributions

from mirage.flow import Workflow
from mirage.command import command
from mirage import system as mys


class DjangoPackageWorkFlow(Workflow):

    def constructor(self):
        
        self._action = self._option
        self._packages = self._values

    def main(self):
        mys.log("Mirage package manager...")

    def _init(self):
        ignore_packages = ["setuptools", "pip", "python"]
        already_pip = get_installed_distributions(local_only = True, skip = ignore_packages)


    def _install(self, package_name):
        mys.log("Installing package " + package_name + " ...")
github shotastage / mirage-django-lts / mirage / command.py View on Github external
def command(command, withOutput = False):

    warning.warn("command.command will be deprecated on next release!", warning.PendingDeprecationWarning)

    separated_cmds = command.split(" ")

    if withOutput:
        try:
            check_output(separated_cmds, stderr=STDOUT)
        except:
            log("Failed to exec " + command + "!", withError = True)
            return

    else:
        try:
            check_output(separated_cmds, stderr=DEVNULL)
        except:
            log("Failed to exec " + command + "!", withError = True)
            return
github shotastage / mirage-django-lts / mirage / proj / old_api.py View on Github external
def get_project_name():
    warning.warn("get_project_name will be deprecated on next release.", warning.PendingDeprecationWarning)
    current_dir = os.getcwd()
    directories = os.listdir(".")
    app_name = "FAILED TO GET"
    
    if in_project():

        for directory in directories:
            try:
                os.chdir(directory)

                if os.path.isfile("settings.py"):
                    app_name = str(os.getcwd()).split("/")[-1]

                os.chdir(current_dir)
            except:
                pass
github shotastage / mirage-django-lts / mirage / projectstartup / angular_app_create.py View on Github external
return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput = True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(self._project_name), withError = True,
                    errorDetail = "Please remove duplication of Django project namespace.")
            return

        version      = mys.log("App version", withInput = True, default = "0.0.1")
        author       = mys.log("Author name", withInput = True)
        email        = mys.log("Email",       withInput = True)
        git_url      = mys.log("Git URL",     withInput = True)
        license_name = mys.log("License",     withInput = True)
        license_url  = mys.log("License Url", withInput = True)
        description  = mys.log("Description", withInput = True)
        copyrightor  = mys.log("Copyrightor", withInput = True, default = author)




        self._create_new_django_app()

        # Create logging instance
        logger = mys.Progress()

        with proj.InDir("./" + self._project_name):
github shotastage / mirage-django-lts / mirage / projectstartup / angular_app_create.py View on Github external
def main(self):

        # Check
        try:
            self._check_before()
        except:
            return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput = True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(self._project_name), withError = True,
                    errorDetail = "Please remove duplication of Django project namespace.")
            return

        version      = mys.log("App version", withInput = True, default = "0.0.1")
        author       = mys.log("Author name", withInput = True)
        email        = mys.log("Email",       withInput = True)
        git_url      = mys.log("Git URL",     withInput = True)
        license_name = mys.log("License",     withInput = True)
        license_url  = mys.log("License Url", withInput = True)
github shotastage / mirage-django-lts / mirage / touch / touch.py View on Github external
start_year = mys.log("Start year", withInput = True)

        try:
            copyrights = Config().get(Category.copyright, Detail.copyright_copyrigtors)
        except:
            copyrights = mys.log("Copyrights", withInput = True)

        try:
            licensename = Config().get(Category.project_basic, Detail.project_license)
        except:
            licensename = mys.log("License name", withInput = True)

        try:
            license_url = Config("secret").get(Category.private_profile, Detail.private_license_url)
        except:
            license_url = mys.log("License doc URL", withInput = True)


        try:
            with open(str(self._fname), "w") as f:

                # When copyrights is list, copyright_source raises TypeError: unhashable type: 'list'
                if [ext for ext in [".py", ".rb", ".sh"] if ext in self._fname]:
                    f.write(
                        copyright_source.copyright_script_style_doc(proj_name, self._fname, your_name,
                                                   start_year, tuple(copyrights), licensename, license_url)
                    )
                elif [ext for ext in [".scss", ".js", ".ts", ".swift", ".c"] if ext in self._fname]:
                    f.write(
                        copyright_source.copyright_c_style_doc(proj_name, self._fname, your_name,
                                                   start_year, tuple(copyrights), licensename, license_url)
                    )
github shotastage / mirage-django-lts / mirage / generate / app.py View on Github external
def _install_app(self, name):

        try:
            master_app = self.__detect_master_app()
        except:
            mys.log("Failed to detect master app.", withError = True)


        mys.log("Installing app...")

        with proj.InDir(master_app):
            if os.path.isdir("environment"):
                with proj.InDir("./environment"):
                    self.__insert_app_path(name, "common.py")

            elif os.path.isdir("settings"):
                with proj.InDir("./settings"):
                    self.__insert_app_path(name, "common.py")

            else:
                if os.path.isfile("settings.py"):
                    self.__insert_app_path(name, "settings.py")
github shotastage / mirage-django-lts / mirage / miragefile / conf.py View on Github external
def _get_copyright(self, detail):

        if detail == Detail.copyright_start_year:
            return self._data["project"]["copyright"]["start_year"]
        elif detail == Detail.copyright_copyrigtors:
            return self._data["project"]["copyright"]["copyrightors"]
        else:
            mys.log("The config information named " + detail + " does not exist!", withError = True) 
            raise MiragefileUnknownError
github shotastage / mirage-django-lts / mirage / projectstartup / react_app_create.py View on Github external
except:
            return

        # Input information
        mys.log("Please type your new Django application information.")

        # Check namespace
        try:
            self._project_name = mys.log("Project name", withInput = True)
            self._check_namesapce(self._project_name)
        except:
            mys.log("Project \"{0}\" is already exists.".format(self._project_name), withError = True,
                    errorDetail = "Please remove duplication of Django project namespace.")
            return

        version      = mys.log("App version", withInput = True, default = "0.0.1")
        author       = mys.log("Author name", withInput = True)
        email        = mys.log("Email",       withInput = True)
        git_url      = mys.log("Git URL",     withInput = True)
        license_name = mys.log("License",     withInput = True)
        license_url  = mys.log("License Url", withInput = True)
        description  = mys.log("Description", withInput = True)
        copyrightor  = mys.log("Copyrightor", withInput = True, default = author)




        self._create_new_django_app()

        # Create logging instance
        logger = mys.Progress()