Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 + " ...")
from mirage import system as mys
from mirage import proj
from mirage import fileable
from mirage.flow import Workflow
from mirage.workspace import storage
class DjangoCreateSuperUserWorkflow(Workflow):
def main(self):
with proj.MirageEnvironment(proj.MirageEnvironmentLevel.indjango):
os.system("python manage.py createsuperuser")
class DjangoManagePyWorkflow(Workflow):
def constructor(self):
self._cmd = self._option
def main(self):
if self._cmd == "superuser":
self.createsuperuser()
else:
self.excute_manage_cmd()
def createsuperuser(self):
self._cmd = "createsuperuser"
self.excute_manage_cmd()
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import shutil
import zipfile
import hashlib
from pathlib import Path
from mirage.flow import Workflow
from mirage import system as mys
from mirage import proj
class MirageTransferWorkflow(Workflow):
def constructor(self):
self._app = self._option
try:
self._to = self._values[0]
except:
self._to = mys.log("Trasfer to", withInput = True)
def main(self):
# Beta Warning
mys.log("This feature is now under Beta version.", withError=True)
# Logger instance
logger = mys.progress.Progress()
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from mirage.miragefile.conf import Config, Category, Detail
from mirage.flow import Workflow
from mirage import proj
from mirage import system as mys
from .templates import procfile, runtime
class DjangoHerokuConfigureWorkFlow(Workflow):
def main(self):
with proj.MirageEnvironment(proj.MirageEnvironmentLevel.inproject):
mys.log("Creating heroku configurations...")
self._create_heroku_configuation()
def _create_heroku_configuation(self):
with open("Procfile", "w") as pf:
pf.write(procfile.src(Config().get(Category.django, Detail.django_module)))
with open("runtime.txt", "w") as rf:
rf.write(runtime.src())
from mirage import project
from mirage import system as mys
from mirage.flow import Workflow
class DjangoConsoleWorkFlow(Workflow):
def main(self):
if project.in_project():
mys.log("Launching Django Python Shell")
os.system("python manage.py shell")
else:
mys.log("Current dir " + os.getcwd() + " is out of Django project!", withError = True)
class DjangoDBConsoleWorkFlow(Workflow):
def main(self):
if project.in_project():
mys.log("Launching Django Python Shell")
os.system("python manage.py dbshell")
else:
mys.log("Current dir " + os.getcwd() + " is out of Django project!", withError = True)
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import sys
import time
import shlex
import subprocess
import webbrowser
from mirage import proj
from mirage.flow import Workflow
from mirage import system as mys
class DjangoDebugServerWorkFlow(Workflow):
def main(self):
with proj.MirageEnvironment(proj.MirageEnvironmentLevel.indjango):
try:
os.system("python manage.py runserver")
except KeyboardInterrupt:
mys.log("Good bye!")
except:
mys.log("Failed to launch web browser!", withError = True)
class DjangoLaunchBrowserWorkflow(Workflow):
def constructor(self):
self._url = self._option
"""
from mirage.core import Void
from mirage.flow import Workflow
from mirage.help import description, description_long
class UsageShowWorkFlow(Workflow):
def main(self) -> Void:
if self._option == "--detail":
print(description_long.usage_doc())
else:
print(description.usage_doc())
class VersionShowWorkFlow(Workflow):
def main(self) -> Void:
print(description.version_doc())
"""
import os
import shutil
import sys
import time
import distutils
from mirage import system as mys
from mirage import proj
from mirage import fileable
from mirage.flow import Workflow
from mirage.workspace import storage
class DjangoCreateSuperUserWorkflow(Workflow):
def main(self):
with proj.MirageEnvironment(proj.MirageEnvironmentLevel.indjango):
os.system("python manage.py createsuperuser")
class DjangoManagePyWorkflow(Workflow):
def constructor(self):
self._cmd = self._option
def main(self):
if self._cmd == "superuser":
self.createsuperuser()
else:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
from mirage.flow import Workflow
from mirage.command import log, command
from mirage.generate.model_template import create_model_class
class DjangoModelMakeFlow(Workflow):
def main(self):
datatypes = """
Data Type: Rerating Fields:
string CharField
auto AutoField
auto64 BigAutoField
int64 BigIntegerField
binary BinaryField
bool BooleanField
char CharField
date DateField
datetime DateTimeField
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import shutil
from mirage import proj
from mirage import fileable
from mirage.flow import Workflow
from mirage import system as mys
from mirage.template import readme_md, gitignore, package_json
from mirage.miragefile import source
class MirageMinimumStartupWorkFlow(Workflow):
def constructor(self):
self._project_name = None
def main(self):
# Check
try:
self._check_before()
except:
return
# Input information
mys.log("Please type your new Django application information.")