Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def make_api(api_name: str, model):
f"class {api_name.capitalize()}View(Resource):\n"
f" pass")

with open(f'api/__init__.py', 'a+') as f:
with open('api/__init__.py', 'a+') as f:
f.write(
f'from api.{api_name} import {api_name.capitalize()}View\n')
f.write(
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def celery(queues, logfile, concurrency, worker_max_tasks_per_child):

if queues:
config.update(queues=queues.split(','))
logger.info("worker is listening to queues: {}".format(queues))
logger.info(f"worker is listening to queues: {queues}")
else:
logger.info("worker is listening to ALL queues")

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def {command_name}():
pass
''')

with open(f'cli/__init__.py', 'a+') as f:
with open('cli/__init__.py', 'a+') as f:
f.write(
f'from .cmd_{command_name} import *\n')

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class {model_name.capitalize()}(Model, IDMixin):
pass
''')

with open(f'models/__init__.py', 'a+') as f:
with open('models/__init__.py', 'a+') as f:
f.write(
f'from models.{model_name} import {model_name.capitalize()}\n')

Expand Down
19 changes: 11 additions & 8 deletions config/static_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@



class Config():


class Config:
# STATIC CONFIG--------------------------------------------

REDIS_DOMAIN = 'redis://{}:6379'.format(REDIS_HOST)
AUTH_REDIS_URL = 'redis://{}:6379/0'.format(REDIS_HOST)
REDIS_DOMAIN = f'redis://{REDIS_HOST}:6379'
AUTH_REDIS_URL = f'redis://{REDIS_HOST}:6379/0'


CELERY_BROKER_URL = '{}/{}'.format(REDIS_DOMAIN, 1)
CELERY_BROKER_URL = f'{REDIS_DOMAIN}/1'

CELERY_RESULT_BACKEND = '{}/{}'.format(REDIS_DOMAIN, 1)
CELERY_RESULT_BACKEND = f'{REDIS_DOMAIN}/1'

CELERY_WORKER_CONFIG = {
'broker': CELERY_BROKER_URL,
Expand All @@ -43,7 +45,7 @@ class Config():
}


REDBEAT_REDIS_URL = '{}/{}'.format(REDIS_DOMAIN, 3)
REDBEAT_REDIS_URL = f'{REDIS_DOMAIN}/3'
REDBEAT_KEY_PREFIX = 'redbeat'
REDBEAT_LOCK_KEY = 'redbeat:lock'
# REDBEAT_LOCK_TIMEOUT = 2
Expand Down Expand Up @@ -98,11 +100,11 @@ class Config():
SOCKETIO_MESSAGE_QUEUE = 'redis://'

CACHE_CONFIG = {
'CACHE_TYPE' : 'redis',
'CACHE_TYPE': 'redis',
'CACHE_KEY_PREFIX': 'fcache_',
'CACHE_REDIS_HOST': 'localhost',
'CACHE_REDIS_PORT': '6379',
'CACHE_REDIS_URL' : '{}/{}'.format(REDIS_DOMAIN, 2)
'CACHE_REDIS_URL': f'{REDIS_DOMAIN}/2',
}

IS_AUTH_ENABLED = True
Expand Down Expand Up @@ -167,6 +169,7 @@ class Config():
}



class ProductionConfig(Config):
DEBUG = False

Expand Down
6 changes: 3 additions & 3 deletions config/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class BaseTask(Task):

def on_failure(self, exc, task_id, args, kwargs, einfo):
logger.exception(str(einfo))
logger.debug("Task_id {} failed, Arguments are {}".format(task_id, args))
logger.debug(f"Task_id {task_id} failed, Arguments are {args}")

if current_config.IS_ERROR_MAIL_ENABLED:
# send error mail
mail_subject = "[App Celery] for task_id {}, {}".format(task_id, str(exc))
mail_subject = f"[App Celery] for task_id {task_id}, {str(exc)}"

mail_body = "\nargs: {} \nkwargs: {}\n\n\n {}".format(args, kwargs, (str(einfo)))
mail_body = f"\nargs: {args} \nkwargs: {kwargs}\n\n\n {str(einfo)}"
msg = Message(subject=mail_subject, body=mail_body, sender=current_config.DEFAULT_MAIL_SENDER, recipients=current_config.ADMINS)
mail.send(msg)
4 changes: 1 addition & 3 deletions facilities/databases/DBMixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def __ne__(self, other):
Checks the inequality of two `UserMixin` objects using `get_id`.
"""
equal = self.__eq__(other)
if equal is NotImplemented:
return NotImplemented
return not equal
return NotImplemented if equal is NotImplemented else not equal


class AnonymousUserMixin:
Expand Down
6 changes: 1 addition & 5 deletions facilities/mimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,4 @@ def get_mimes(extension=None):

def get_extensions(mime_type=None):
"""Returns possible extensions for the given mime_type"""
exts = []
for ext in _mime_types:
if mime_type in _mime_types[ext]:
exts.append(ext)
return exts
return [ext for ext in _mime_types if mime_type in _mime_types[ext]]
2 changes: 1 addition & 1 deletion models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class User(Model, IDMixin):
is_active: Column = Column(Boolean, default = True, server_default = 'true')

def __repr__(self):
return '<User {}>'.format(self.username)
return f'<User {self.username}>'

# Using Praetorian specific features ----------------------
@property
Expand Down