本文整理汇总了Python中django.core.management.base.BaseCommand类的典型用法代码示例。如果您正苦于以下问题:Python BaseCommand类的具体用法?Python BaseCommand怎么用?Python BaseCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
"""
Creation of the ejabberd atuh bridge service.
:Parameters:
- `args`: all non-keyword arguments
- `kwargs`: all keyword arguments
"""
BaseCommand.__init__(self, *args, **kwargs)
try:
log_level = int(logging.DEBUG)
except:
log_level = logging.INFO
if os.access("/var/log/ejabberd/kauth.log", os.W_OK):
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(message)s',
filename="/var/log/ejabberd/kauth.log",
filemode='a')
else:
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(message)s',
stream=sys.stderr)
logging.warn(('Could not write to ' +
'/var/log/ejabberd/kauth.log' +
'. Falling back to stderr ...'))
logging.info(('ejabberd kauth process started' +' (more than one is common)'))
示例2: __init__
def __init__(self, *args, **kwargs):
self.verbosity = 0
self.stats = {}
self._ignore = []
BaseCommand.__init__(self, *args, **kwargs)
示例3: __init__
def __init__(self):
BaseCommand.__init__(self)
self.option_list += (
make_option("--queues", "-q", help="Queues to include (default: all). Use queue slugs"),
make_option("--verbose", "-v", action="store_true", default=False, help="Display a list of dates excluded"),
)
示例4: add_arguments
def add_arguments(self, parser):
BaseCommand.add_arguments(self, parser)
parser.add_argument('addrport', nargs='?',
help='Optional port number, or ipaddr:port')
# The below flags are for legacy compat.
# 2017-06-08 added addrport positional argument,
# because:
# - more consistent with runserver.
# - don't have to remember the name of the flags (is it --bind or --addr etc)
# - quicker to type
# - we don't need positional args for anything else
parser.add_argument(
'--addr', action='store', type=str, dest='addr', default=None,
help='The host/address to bind to (default: {})'.format(DEFAULT_ADDR))
ahelp = (
'Port number to listen on. Defaults to the environment variable '
'$PORT (if defined), or {}.'.format(DEFAULT_PORT)
)
parser.add_argument(
'--port', action='store', type=int, dest='port', default=None,
help=ahelp)
ahelp = (
'Run an SSL server directly in Daphne with a self-signed cert/key'
)
parser.add_argument(
'--dev-https', action='store_true', dest='dev_https', default=False,
help=ahelp)
示例5: __init__
def __init__(self, *args, **kwargs):
"""
Creation of the ejabberd atuh bridge service.
:Parameters:
- `args`: all non-keyword arguments
- `kwargs`: all keyword arguments
"""
BaseCommand.__init__(self, *args, **kwargs)
try:
log_level = int(settings.TUNNEL_EJABBERD_AUTH_GATEWAY_LOG_LEVEL)
except:
log_level = logging.INFO
# If we can write to the log do so, else fail back to the console
if os.access(settings.TUNNEL_EJABBERD_AUTH_GATEWAY_LOG, os.W_OK):
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(message)s',
filename=settings.TUNNEL_EJABBERD_AUTH_GATEWAY_LOG,
filemode='a')
else:
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(message)s',
stream=sys.stderr)
logging.warn(('Could not write to ' +
settings.TUNNEL_EJABBERD_AUTH_GATEWAY_LOG +
'. Falling back to stderr ...'))
logging.info(('ejabberd_auth_bridge process started' +
' (more than one is common)'))
示例6: __init__
def __init__(self):
BaseCommand.__init__(self)
self.style = no_style()
# Keep a count of the installed objects and ontologies
self.count = [0, 0]
self.models = set()
self.verbosity, self.show_traceback, self.fail_gracefully = 1, False, False
示例7: __init__
def __init__(self, *args, **kwargs):
class NiceContext(Context):
"""
Same as the real context class, but override some methods in order to gain
nice colored output.
"""
def __init__(s, *args, **kwargs):
kwargs['insert_debug_symbols'] = self.insert_debug_symbols
Context.__init__(s, *args, **kwargs)
def compile_media_callback(s, compress_tag, media_files):
"""
When the compiler notifies us that compiling of this file begins.
"""
if compress_tag:
print self.colored('Compiling media files from', 'yellow'),
print self.colored(' "%s" ' % compress_tag.path, 'green'),
print self.colored(' (line %s, column %s)" ' % (compress_tag.line, compress_tag.column), 'yellow')
else:
print self.colored('Compiling media files', 'yellow')
for m in media_files:
print self.colored(' * %s' % m, 'green')
def compile_media_progress_callback(s, compress_tag, media_file, current, total, file_size):
"""
Print progress of compiling media files.
"""
print self.colored(' (%s / %s):' % (current, total), 'yellow'),
print self.colored(' %s (%s bytes)' % (media_file, file_size), 'green')
self.NiceContext = NiceContext
BaseCommand.__init__(self, *args, **kwargs)
示例8: __init__
def __init__(self):
BaseCommand.__init__(self)
self.found = 0
self.no_match = 0
from_coord = SpatialReference(900913)
to_coord = SpatialReference(4326)
self.trans = CoordTransform(from_coord, to_coord)
self.rtrans = CoordTransform(to_coord, from_coord)
示例9: __init__
def __init__(self):
BaseCommand.__init__(self)
self.option_list += (
make_option(
'--queues', '-q',
help='Queues to include (default: all). Use queue slugs'),
)
示例10: __init__
def __init__(self, *args, **kwargs):
self.verbosity = 0
self.file_consumer = None
self.mail_fetcher = None
BaseCommand.__init__(self, *args, **kwargs)
示例11: __init__
def __init__(self, *args, **kwargs):
self.logger = logging.getLogger(__name__)
BaseCommand.__init__(self, *args, **kwargs)
self.username = settings.MAIL_POLLING["username"]
self.password = settings.MAIL_POLLING["password"]
self.host = settings.MAIL_POLLING["host"]
示例12: __init__
def __init__(self):
BaseCommand.__init__(self)
self.option_list += (
make_option(
'--quiet', '-q',
default=False,
action='store_true',
help='Hide all command output'),
)
示例13: __init__
def __init__(self, *largs, **kwargs):
BaseCommand.__init__(self, *largs, **kwargs)
from django.conf import settings
self.cascade = False
if settings.DATABASE_ENGINE:
self.cascade = settings.DATABASE_ENGINE.find('postgresql') >= 0
elif settings.DATABASES:
db_settings = settings.DATABASES.get('default')
self.cascade = db_settings.get('ENGINE').find('postgresql') >= 0
示例14: __init__
def __init__(self, *args, **kwargs):
BaseCommand.__init__(self, *args, **kwargs)
self.local_enabled = False
# Change this to True to log requests for debug *logs may include passwords*
self.LOGGING_ENABLED = False
if get_config("JABBER_LOCAL_ENABLED",None).value == "1":
self.local_enabled = True
self.local_user = get_config("JABBER_FROM_JID", False).value.split('@')[0]
self.local_pass = get_config("JABBER_FROM_PASSWORD", False).value
self.space_char = get_config("JABBER_LOCAL_SPACE_CHAR", False).value
示例15: __init__
def __init__(self):
BaseCommand.__init__(self)
self.option_list += (
make_option(
'--quiet', '-q',
default=False,
action='store_true',
help='Hide details about each queue/message as they are processed'),
)