Commit 19347e2c authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch 'improve_db_info_print_output' into 'master'

Add root folder information to output of database information output

See merge request !300
parents 59891ea8 0e014c4a
Pipeline #32533 passed with stages
in 20 minutes and 21 seconds
......@@ -25,35 +25,40 @@
# #
###############################################################################
import logging
from django.core.management.base import BaseCommand
from ...models import Database
logger = logging.getLogger("beat.web")
class Command(BaseCommand):
help = "Prints the list of databases with access level and user information"
def handle(self, *ignored, **options):
def add_arguments(self, parser):
parser.add_argument(
"--folder-filter",
action="store",
dest="folder_filter",
default=None,
help="Path element up to which the the string must be cleaned",
)
# Setup this command's logging level
global logger
verbosity = int(options["verbosity"])
if verbosity >= 1:
if verbosity == 1:
logger.setLevel(logging.INFO)
elif verbosity >= 2:
logger.setLevel(logging.DEBUG)
def handle(self, *ignored, **options):
self.stdout.write("name, access, user")
self.stdout.write("name, access, folder, user")
for database in Database.objects.all():
db_info = "{}, {}".format(
database.fullname(), database.get_sharing_display()
folder = database.declaration["root_folder"]
folder_filter = options["folder_filter"]
if folder_filter:
try:
start = folder.rindex(folder_filter) + len(folder_filter)
except ValueError:
start = 0
folder = folder[start:]
db_info = "{}, {}, {}".format(
database.fullname(), database.get_sharing_display(), folder
)
for user in [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment