From 1acbc39c48fd74aa7438c60c49182ca820bc0193 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 3 Nov 2014 01:40:30 -0400 Subject: [PATCH] Issue #56, with the addition of watched folders this feature is repititive --- mayan/apps/sources/management/__init__.py | 0 .../sources/management/commands/__init__.py | 0 .../management/commands/bulk_upload.py | 80 ------------------- 3 files changed, 80 deletions(-) delete mode 100644 mayan/apps/sources/management/__init__.py delete mode 100644 mayan/apps/sources/management/commands/__init__.py delete mode 100644 mayan/apps/sources/management/commands/bulk_upload.py diff --git a/mayan/apps/sources/management/__init__.py b/mayan/apps/sources/management/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mayan/apps/sources/management/commands/__init__.py b/mayan/apps/sources/management/commands/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mayan/apps/sources/management/commands/bulk_upload.py b/mayan/apps/sources/management/commands/bulk_upload.py deleted file mode 100644 index d69b066216..0000000000 --- a/mayan/apps/sources/management/commands/bulk_upload.py +++ /dev/null @@ -1,80 +0,0 @@ -from __future__ import absolute_import - -from json import loads -from optparse import make_option -import os -import sys - -from django.core.management.base import CommandError, LabelCommand - -from common.compressed_files import NotACompressedFile -from documents.models import DocumentType -from metadata.api import convert_dict_to_dict_list - -from ...models import OutOfProcess - - -class Command(LabelCommand): - args = '' - help = 'Upload documents from a compressed file in to the database.' - option_list = LabelCommand.option_list + ( - make_option('--noinput', action='store_false', dest='interactive', - default=True, help='Do not ask the user for confirmation before ' - 'starting.'), - make_option('--metadata', action='store', dest='metadata', - help='A metadata dictionary list to apply to the documents.'), - make_option('--document_type', action='store', dest='document_type_name', - help='The document type to apply to the uploaded documents.'), - ) - - def handle_label(self, label, **options): - if not os.access(label, os.R_OK): - raise CommandError("File '%s' is not readable." % label) - - if options['metadata']: - try: - metadata_dict = loads(options['metadata']) - metadata_dict_list = convert_dict_to_dict_list(metadata_dict) - except Exception as exception: - sys.exit('Metadata error: %s' % exception) - else: - metadata_dict_list = None - - if options['document_type_name']: - try: - document_type = DocumentType.objects.get(name=options['document_type_name']) - except DocumentType.DoesNotExist: - sys.exit('Unknown document type') - else: - document_type = None - - if _confirm(options['interactive']) == 'yes': - print 'Beginning upload...' - if metadata_dict_list: - print 'Using the metadata values:' - for key, value in metadata_dict.items(): - print '%s: %s' % (key, value) - - if document_type: - print 'Uploaded document will be of type: %s' % options['document_type_name'] - - source = OutOfProcess() - fd = open(label) - try: - source.upload_file(fd, filename=None, use_file_name=False, document_type=document_type, expand=True, metadata_dict_list=metadata_dict_list, user=None, document=None, new_version_data=None, command_line=True) - except NotACompressedFile: - print '%s is not a compressed file.' % label - else: - print 'Finished.' - - fd.close() - else: - print 'Cancelled.' - - -def _confirm(interactive): - if not interactive: - return 'yes' - return raw_input('You have requested to bulk upload a number of documents from a compressed file.\n' - 'Are you sure you want to do this?\n' - 'Type \'yes\' to continue, or any other value to cancel: ')