Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from cleo import Command, CommandTester
from .. import CleoTestCase
class TestCommand(Command):
"""
Command testing.
test
{action : The action to execute.}
"""
def handle(self):
action = self.argument("action")
getattr(self, "_" + action)()
def _overwrite(self):
self.write("Processing...")
self.overwrite("Done!")
"""New Migration Command."""
import subprocess
from cleo import Command
class MakeMigrationCommand(Command):
"""
Makes a new migration.
migration
{name : Name of your migration}
{--t|--table=False : Table you are migrating for}
{--c|--create=False : Table you want to create with this migration}
"""
def handle(self):
name = self.argument('name')
if self.option('create') != 'False':
subprocess.call(['orator', 'make:migration', name,
'-p', 'databases/migrations', '--table', self.option('create'), '--create'])
elif self.option('table') != 'False':
"""Install Command."""
import os
import shutil
import subprocess
from cleo import Command
class InstallCommand(Command):
"""
Installs all of Masonite's dependencies.
install
"""
def handle(self):
subprocess.call(["pip3", "install", "-r", "requirements.txt"])
# create the .env file if it does not exist
if not os.path.isfile('.env'):
shutil.copy('.env-example', '.env')
subprocess.call(["craft", "key", "--store"])
class TabView:
def view(*args, **kwargs):
print("Unfortunately Tabview is not available on Windows.")
tabview = TabView()
from cleo import Command
from clevercsv.exceptions import NoDetectionResult
from clevercsv.wrappers import read_table
from ._utils import parse_int
class ViewCommand(Command):
"""
View the CSV file on the command line using TabView
view
{ path : The path to the CSV file }
{ --e|encoding= : Set the encoding of the CSV file }
{ --n|num-chars= : Limit the number of characters to read for
detection. This will speed up detection but may reduce accuracy. }
{ --t|transpose : Transpose the columns of the file before viewing. }
"""
help = """\
Use the view command to view a CSV file on the command line.
"""
def handle(self):
"""List Routes Command."""
from cleo import Command
from tabulate import tabulate
class RoutesCommand(Command):
"""
List out all routes of the application.
show:routes
"""
def handle(self):
from wsgi import container
web_routes = container.make('WebRoutes')
routes = [[
"Method",
"Path",
"Name",
"Domain",
"""Displays Information Command."""
import math
import os
import platform
import sys
import psutil
from cleo import Command
from tabulate import tabulate
from masonite.__version__ import __version__
class InfoCommand(Command):
"""
Displays environment info for debugging.
info
"""
def handle(self):
from masonite_cli.application import application
rows = []
rows.append(['System Information', self._get_system_info()])
mem = math.ceil(psutil.virtual_memory().total / 1024 / 1024 / 1024.0)
rows.append(['System Memory', str(mem) + ' GB'])
rows.append(['Python Version', self._get_python_info()])
rows.append(['Virtual Environment', self._check_virtual_environment()])
rows.append(['Masonite Version', __version__])
"""Migrate Reset Command."""
import os
import sys
from cleo import Command
from masonite.helpers.migrations import Migrations
class MigrateResetCommand(Command):
"""
Migrate reset.
migrate:reset
{--c|connection=default : The connection you want to run migrations on}
"""
def handle(self):
sys.path.append(os.getcwd())
migrations = Migrations(self.option('connection')).reset()
self.line("")
for notes in migrations._notes:
self.line(notes)
self.line("")
from cleo import Command
class FetchyCommandBase(Command):
@property
def fetchy(self):
return self.application.fetchy
# -*- coding: utf-8 -*-
from cleo import Command
class AboutCommand(Command):
"""
Short information about Poet.
about
"""
def handle(self):
self.line("""Poet - Package Management for Python
# -*- coding: utf-8 -*-
import os
import inflection
from cleo import Command
from .stubs import MODEL_DEFAULT_STUB
from ...utils import mkdir_p
class ModelMakeCommand(Command):
"""
Creates a new Model class.
make:model
{name : The name of the model to create.}
{--m|migration : Create a new migration file for the model.}
{--p|path= : Path to models directory}
"""
def handle(self):
name = self.argument("name")
singular = inflection.singularize(inflection.tableize(name))
directory = self._get_path()
filepath = self._get_path(singular + ".py")
if os.path.exists(filepath):