Example #1
0
    def main(self) -> Void:
        mys.log("Checking mirage update...")

        with tempfile.TemporaryDirectory() as td:
            with InDir(td):
                sys.path.append(td)
                request.urlretrieve(self._url, "mg_version_check.py")

                try:
                    import mg_version_check
                except ImportError:
                    mys.log("Failed to get version information!",
                            withError=True,
                            errorDetail=mys.raise_error_message(
                                self.main, traceback.format_exc()))
                    return

                if ver == mg_version_check.__version__:
                    if ver == "0.1.9":
                        mys.log("New mirage framework tools available!")
                        mys.log(
                            "See, https://github.com/shotastage/mirage-django for detail."
                        )

                        mys.log("LTS Update available!", withError=True)
                        print("This version: {0}".format(ver))
                        print("Available version: {0}".format(
                            mg_version_check.__version__))
                else:
                    mys.log("LTS Update available!", withError=True)
                    print("This version: {0}".format(ver))
                    print("Available version: {0}".format(
                        mg_version_check.__version__))
Example #2
0
    def main(self):
        # Beta Warning
        mys.log("This feature is now under Beta version.", withError=True)

        # Logger instance

        logger = mys.progress.Progress()

        with proj.MirageEnvironment(proj.MirageEnvironmentLevel.indjango):

            # In advance checking.
            try:
                self._check(logger)
            except:
                return

            logger.write("Searching application %s..." % self._app,
                         withLazy=True)

            if Path(self._app).is_dir():
                mys.log(os.getcwd())
                shutil.copytree(self._app, os.path.join(self._to, self._app))
                logger.update("Completed!")
            else:
                logger.update("Can not detect application %s!" % self._app)
                mys.log("Failed to transfer app %s!" % self._app,
                        withError=True,
                        errorDetail=mys.raise_error_message(
                            "The application diresctory does not exists!"))
                return
Example #3
0
 def run(self) -> Void:
     for flow in self._flows:
         try:
             flow()
         except:
             mys.log("Something error has occured!",
                     withError=True,
                     errorDetail=mys.raise_error_message(flow))
             raise Exception
Example #4
0
 def query_execute(connection, cur, query):
     try:
         cur.execute(query)
     except sqlite3.Error as e:
         mys.log("SQLite3 error has occured!",
                 withError=True,
                 errorDetail=e.args[0])
     except:
         mys.log("Unknown error has occured!",
                 withError=True,
                 errorDetail=mys.raise_error_message(
                     MirageWorkspace.__write_persistence_file_meta))
Example #5
0
    def main(self):
        # ModelClass name:string+maxlen=40 no:integer+as_primary=True

        model_contents = ""

        for data in self._data:
            model_contents += "{0}\n".format(self._parse_data(data))

        # Write model file
        sys.log("Writing model...")

        try:
            with open("models.py", "a") as writing:
                writing.write(
                    create_model_class(self._model_name, model_contents))
        except:
            sys.log("Failed to create / overwrite models.py!",
                    withError=True,
                    errorDetail=sys.raise_error_message(self.main))
Example #6
0
    def main(self) -> Void:
        mys.log("Checking mirage update...")

        with tempfile.TemporaryDirectory() as td:
            with InDir(td):
                sys.path.append(td)
                request.urlretrieve(self._url, "mg_version_check.py")

                try:
                    import mg_version_check
                except ImportError:
                    mys.log("Failed to get version information!", withError=True,
                            errorDetail=mys.raise_error_message(self.main, traceback.format_exc()))
                    return

                if ver == mg_version_check.__version__:
                    mys.log("Up-to-date !")
                else:
                    mys.log("Update available!", withError=True)
                    print("This version: {0}".format(ver))
                    print("Available version: {0}".format(mg_version_check.__version__))
Example #7
0
    def _load_json(self, filename):
        if not os.path.exists(filename):
            mys.log("Failed to find Miragefile!", withError = True)
            raise FileNotFoundError

        with open(filename, "r") as jsonfile:
            try:
                return json.load(jsonfile)
            except:
                mys.log("Failed to load Miragefile!", withError = True, errorDetail = mys.raise_error_message(self._load_json))
                raise FileNotFoundError
Example #8
0
    def main(self):

        try:
            proj_name = Config().get(Category.project_basic,
                                     Detail.project_name)
        except:
            proj_name = mys.log("What's the project name?", withInput=True)

        try:
            your_name = Config("secret").get(Category.private_profile,
                                             Detail.private_name)
        except:
            your_name = mys.log("What's your name?", withInput=True)

        try:
            start_year = Config().get(Category.copyright,
                                      Detail.copyright_start_year)
        except:
            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))

        except:
            mys.log(
                "Failed to touch new python script \"" + self._fname + "\"!",
                withError=True,
                errorDetail=mys.raise_error_message(self.main,
                                                    traceback.format_exc()))

        return True