コード例 #1
0
ファイル: models.py プロジェクト: ptwnimbe/mayan_appsembler
    def set_properties(self):
        self._properties = SortedDict()
        if LSB:
            self.add_property(Property('is_lsb', _(u'LSB OS'), True))
            self.add_property(Property('distributor_id', _(u'Distributor ID'), lsb_release('-i','-s')))
            self.add_property(Property('description', _(u'Description'), lsb_release('-d','-s')))
            self.add_property(Property('release', _(u'Release'), lsb_release('-r','-s')))
            self.add_property(Property('codename', _(u'Codename'), lsb_release('-c','-s')))
            self.add_property(Property('sysinfo', _(u'System info'), uname('-a')))
        else:
            self.add_property(Property('is_posix', _(u'POSIX OS'), False))

        self.add_property(Property('architecture', _(u'OS architecture'), platform.architecture()))
        self.add_property(Property('python_version', _(u'Python version'), platform.python_version()))
        self.add_property(Property('hostname', _(u'Hostname'), platform.node()))
        self.add_property(Property('platform', _(u'Platform'), sys.platform))
        self.add_property(Property('machine', _(u'Machine'), platform.machine()))
        self.add_property(Property('processor', _(u'Processor'), platform.processor()))
        self.add_property(Property('cpus', _(u'Number of CPUs'), psutil.NUM_CPUS))
        self.add_property(Property('total_phymem', _(u'Total physical memory'), pretty_size(psutil.TOTAL_PHYMEM)))
        self.add_property(Property('disk_partitions', _(u'Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()])))
        
        try:
            self.add_property(Property('tesseract', _(u'tesseract version'), pbs.tesseract('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(Property('tesseract', _(u'tesseract version'), _(u'not found')))

        try:
            self.add_property(Property('unpaper', _(u'unpaper version'), pbs.unpaper('-V').stdout))
        except pbs.CommandNotFound:
            self.add_property(Property('unpaper', _(u'unpaper version'), _(u'not found')))
コード例 #2
0
ファイル: statistics.py プロジェクト: vinchu/mayan-edms
    def get_results(self):
        results = []

        total_db_documents = Document.objects.only('pk',).count()

        results.extend([
            _('Documents in database: %d') % total_db_documents,
        ])

        try:
            total_storage_documents, storage_used_space = storage_count()
            results.append(_('Documents in storage: %d') %
                           total_storage_documents)
            results.append(_('Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
                'base_2': pretty_size(storage_used_space),
                'base_10': pretty_size_10(storage_used_space),
                'bytes': storage_used_space
            })
        except NotImplementedError:
            pass

        results.extend([
            _('Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
        ])

        return results
コード例 #3
0
ファイル: statistics.py プロジェクト: AmiGanguli/mayan
def get_statistics():
    total_db_documents = Document.objects.only('pk',).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u'Documents in storage: %d') %
            total_storage_documents)
        paragraphs.append(_(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
            'base_2': pretty_size(storage_used_space),
            'base_10': pretty_size_10(storage_used_space),
            'bytes': storage_used_space
        })
    except NotImplementedError:
        pass

    document_stats = DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Min('page_count'), Max('page_count'), Avg('page_count'))
    paragraphs.extend(
        [
            _(u'Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
            _(u'Minimum amount of pages per document: %d') % (document_stats['page_count__max'] or 0),
            _(u'Maximum amount of pages per document: %d') % (document_stats['page_count__max'] or 0),
            _(u'Average amount of pages per document: %f') % (document_stats['page_count__avg'] or 0),
        ]
    )

    return {
        'title': _(u'Document statistics'),
        'paragraphs': paragraphs
    }
コード例 #4
0
ファイル: statistics.py プロジェクト: doubleotoo/mayan
def get_statistics():
    total_db_documents = Document.objects.only('pk',).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u'Documents in storage: %d') %
            total_storage_documents)
        paragraphs.append(_(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
            'base_2': pretty_size(storage_used_space),
            'base_10': pretty_size_10(storage_used_space),
            'bytes': storage_used_space
        })
    except NotImplementedError:
        pass

    paragraphs.extend(
        [
            _(u'Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
            _(u'Minimum amount of pages per document: %(page_count__min)d') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Min('page_count')),
            _(u'Maximum amount of pages per document: %(page_count__max)d') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Max('page_count')),
            _(u'Average amount of pages per document: %(page_count__avg)f') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Avg('page_count')),
        ]
    )
    #[(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {
        'title': _(u'Document statistics'),
        'paragraphs': paragraphs
    }
コード例 #5
0
ファイル: models.py プロジェクト: vinchu/mayan-edms
    def os_properties(self):
        namespace = PropertyNamespace('os', _('Operating system'))
        if LSB:
            namespace.add_property('is_lsb', _('LSB OS'), True, True)
            namespace.add_property('distributor_id', _('Distributor ID'),
                                   lsb_release('-i', '-s'), True)
            namespace.add_property('description', _('Description'),
                                   lsb_release('-d', '-s'), True)
            namespace.add_property('release', _('Release'),
                                   lsb_release('-r', '-s'), True)
            namespace.add_property('codename', _('Codename'),
                                   lsb_release('-c', '-s'), True)
            namespace.add_property('sysinfo', _('System info'), uname('-a'),
                                   True)
        else:
            namespace.add_property('is_lsb', _('LSB OS'), False)

        namespace.add_property('architecture',
                               _('OS architecture'),
                               platform.architecture(),
                               report=True)
        namespace.add_property('python_version',
                               _('Python version'),
                               platform.python_version(),
                               report=True)
        namespace.add_property('hostname', _('Hostname'), platform.node())
        namespace.add_property('platform',
                               _('Platform'),
                               sys.platform,
                               report=True)
        namespace.add_property('machine',
                               _('Machine'),
                               platform.machine(),
                               report=True)
        namespace.add_property('processor',
                               _('Processor'),
                               platform.processor(),
                               report=True)
        namespace.add_property('cpus',
                               _('Number of CPUs'),
                               psutil.cpu_count(),
                               report=True)
        namespace.add_property('total_phymem',
                               _('Total physical memory'),
                               pretty_size(psutil.virtual_memory().total),
                               report=True)
        namespace.add_property(
            'disk_partitions', _('Disk partitions'), '; '.join([
                '%s %s %s %s' % (partition.device, partition.mountpoint,
                                 partition.fstype, partition.opts)
                for partition in psutil.disk_partitions()
            ]))
コード例 #6
0
ファイル: models.py プロジェクト: SSE2000/mayan-edms
    def os_properties(self):
        namespace = PropertyNamespace('os', _('Operating system'))
        if LSB:
            namespace.add_property('is_lsb', _('LSB OS'), True, True)
            namespace.add_property('distributor_id', _('Distributor ID'), lsb_release('-i', '-s'), True)
            namespace.add_property('description', _('Description'), lsb_release('-d', '-s'), True)
            namespace.add_property('release', _('Release'), lsb_release('-r', '-s'), True)
            namespace.add_property('codename', _('Codename'), lsb_release('-c', '-s'), True)
            namespace.add_property('sysinfo', _('System info'), uname('-a'), True)
        else:
            namespace.add_property('is_lsb', _('LSB OS'), False)

        namespace.add_property('architecture', _('OS architecture'), platform.architecture(), report=True)
        namespace.add_property('python_version', _('Python version'), platform.python_version(), report=True)
        namespace.add_property('hostname', _('Hostname'), platform.node())
        namespace.add_property('platform', _('Platform'), sys.platform, report=True)
        namespace.add_property('machine', _('Machine'), platform.machine(), report=True)
        namespace.add_property('processor', _('Processor'), platform.processor(), report=True)
        namespace.add_property('cpus', _('Number of CPUs'), psutil.cpu_count(), report=True)
        namespace.add_property('total_phymem', _('Total physical memory'), pretty_size(psutil.virtual_memory().total), report=True)
        namespace.add_property('disk_partitions', _('Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()]))
コード例 #7
0
def get_statistics():
    total_db_documents = Document.objects.only('pk', ).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(
            _(u'Documents in storage: %d') % total_storage_documents)
        paragraphs.append(
            _(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes'
              ) % {
                  'base_2': pretty_size(storage_used_space),
                  'base_10': pretty_size_10(storage_used_space),
                  'bytes': storage_used_space
              })
    except NotImplementedError:
        pass

    document_stats = DocumentVersion.objects.annotate(
        page_count=Count('documentpage')).aggregate(Min('page_count'),
                                                    Max('page_count'),
                                                    Avg('page_count'))
    paragraphs.extend([
        _(u'Document pages in database: %d') %
        DocumentPage.objects.only('pk', ).count(),
        _(u'Minimum amount of pages per document: %d') %
        (document_stats['page_count__min'] or 0),
        _(u'Maximum amount of pages per document: %d') %
        (document_stats['page_count__max'] or 0),
        _(u'Average amount of pages per document: %f') %
        (document_stats['page_count__avg'] or 0),
    ])

    return {'title': _(u'Document statistics'), 'paragraphs': paragraphs}
コード例 #8
0
def get_statistics():
    total_db_documents = Document.objects.only('pk', ).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(
            _(u'Documents in storage: %d') % total_storage_documents)
        paragraphs.append(
            _(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes'
              ) % {
                  'base_2': pretty_size(storage_used_space),
                  'base_10': pretty_size_10(storage_used_space),
                  'bytes': storage_used_space
              })
    except NotImplementedError:
        pass

    paragraphs.extend([
        _(u'Document pages in database: %d') %
        DocumentPage.objects.only('pk', ).count(),
        _(u'Minimum amount of pages per document: %(page_count__min)d') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Min('page_count')),
        _(u'Maximum amount of pages per document: %(page_count__max)d') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Max('page_count')),
        _(u'Average amount of pages per document: %(page_count__avg)f') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Avg('page_count')),
    ])
    #[(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {'title': _(u'Document statistics'), 'paragraphs': paragraphs}
コード例 #9
0
ファイル: statistics.py プロジェクト: ranjithtenz/mayan
def get_statistics():
    total_db_documents = Document.objects.only("pk").count()

    paragraphs = [
        _(u"Document types: %d") % DocumentType.objects.count(),
        _(u"Documents in database: %d") % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u"Documents in storage: %d") % total_storage_documents)
        paragraphs.append(
            _(u"Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes")
            % {
                "base_2": pretty_size(storage_used_space),
                "base_10": pretty_size_10(storage_used_space),
                "bytes": storage_used_space,
            }
        )
    except NotImplementedError:
        pass

    paragraphs.extend(
        [
            _(u"Document pages in database: %d") % DocumentPage.objects.only("pk").count(),
            _(u"Minimum amount of pages per document: %(page_count__min)d")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Min("page_count")),
            _(u"Maximum amount of pages per document: %(page_count__max)d")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Max("page_count")),
            _(u"Average amount of pages per document: %(page_count__avg)f")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Avg("page_count")),
        ]
    )
    # [(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {"title": _(u"Document statistics"), "paragraphs": paragraphs}
コード例 #10
0
ファイル: views.py プロジェクト: strogo/mayan
def document_view(request, document_id):
    check_permissions(request.user, "documents", [PERMISSION_DOCUMENT_VIEW])

    document = get_object_or_404(Document, pk=document_id)
    form = DocumentForm_view(
        instance=document,
        extra_fields=[
            {"label": _(u"Filename"), "field": "file_filename"},
            {"label": _(u"File extension"), "field": "file_extension"},
            {"label": _(u"File mimetype"), "field": "file_mimetype"},
            {"label": _(u"File mime encoding"), "field": "file_mime_encoding"},
            {
                "label": _(u"File size"),
                "field": lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else "-",
            },
            {"label": _(u"Exists in storage"), "field": "exists"},
            {"label": _(u"File path in storage"), "field": "file"},
            {"label": _(u"Date added"), "field": lambda x: x.date_added.date()},
            {"label": _(u"Time added"), "field": lambda x: unicode(x.date_added.time()).split(".")[0]},
            {"label": _(u"Checksum"), "field": "checksum"},
            {"label": _(u"UUID"), "field": "uuid"},
            {"label": _(u"Pages"), "field": lambda x: x.documentpage_set.count()},
        ],
    )

    metadata_groups, errors = document.get_metadata_groups()
    if (request.user.is_staff or request.user.is_superuser) and errors:
        for error in errors:
            messages.warning(request, _(u"Metadata group query error: %s" % error))

    preview_form = DocumentPreviewForm(document=document)
    form_list = [
        {"form": form, "object": document, "grid": 6},
        {"form": preview_form, "title": _(u"document preview"), "object": document, "grid": 6, "grid_clear": True},
    ]
    subtemplates_dict = [
        {
            "name": "generic_list_subtemplate.html",
            "title": _(u"metadata"),
            "object_list": document.documentmetadata_set.all(),
            "extra_columns": [{"name": _(u"value"), "attribute": "value"}],
            "hide_link": True,
        }
    ]

    if FILESERVING_ENABLE:
        subtemplates_dict.append(
            {
                "name": "generic_list_subtemplate.html",
                "title": _(u"index links"),
                "object_list": document.documentmetadataindex_set.all(),
                "hide_link": True,
            }
        )

    sidebar_groups = []
    for group, data in metadata_groups.items():
        if len(data) or GROUP_SHOW_EMPTY:
            if len(data):
                if len(data) > GROUP_MAX_RESULTS:
                    total_string = "(%s out of %s)" % (GROUP_MAX_RESULTS, len(data))
                else:
                    total_string = "(%s)" % len(data)
            else:
                total_string = ""

            extra_columns = [
                {
                    "name": "current",
                    "attribute": lambda x: '<span class="famfam active famfam-resultset_previous"></span>'
                    if x == document
                    else "",
                }
            ]

            if GROUP_SHOW_THUMBNAIL:
                extra_columns.append(
                    {
                        "name": _(u"thumbnail"),
                        "attribute": lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>'
                        % (reverse("document_preview", args=[x.id]), reverse("document_thumbnail", args=[x.id])),
                    }
                )

            sidebar_groups.append(
                {
                    "title": "%s %s" % (group.label, total_string),
                    "name": "generic_list_subtemplate.html",
                    "object_list": data[:GROUP_MAX_RESULTS],
                    "hide_columns": True,
                    "hide_header": True,
                    "extra_columns": extra_columns,
                }
            )

    return render_to_response(
        "generic_detail.html",
        {
            "form_list": form_list,
            "object": document,
            "subtemplates_dict": subtemplates_dict,
            "sidebar_subtemplates_dict": sidebar_groups,
        },
        context_instance=RequestContext(request),
    )
コード例 #11
0
ファイル: views.py プロジェクト: IHLeanne/mayan
def document_view(request, document_id, advanced=False):
    check_permissions(request.user, [PERMISSION_DOCUMENT_VIEW])
    #document = get_object_or_404(Document.objects.select_related(), pk=document_id)
    # Triggers a 404 error on documents uploaded via local upload
    # TODO: investigate
    document = get_object_or_404(Document, pk=document_id)

    RecentDocument.objects.add_document_for_user(request.user, document)

    subtemplates_list = []

    if advanced:
        document_properties_form = DocumentPropertiesForm(instance=document, extra_fields=[
            {'label': _(u'Filename'), 'field': 'file_filename'},
            {'label': _(u'File extension'), 'field': 'file_extension'},
            {'label': _(u'File mimetype'), 'field': 'file_mimetype'},
            {'label': _(u'File mime encoding'), 'field': 'file_mime_encoding'},
            {'label': _(u'File size'), 'field':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
            {'label': _(u'Exists in storage'), 'field': 'exists'},
            {'label': _(u'File path in storage'), 'field': 'file'},
            {'label': _(u'Date added'), 'field':lambda x: x.date_added.date()},
            {'label': _(u'Time added'), 'field':lambda x: unicode(x.date_added.time()).split('.')[0]},
            {'label': _(u'Checksum'), 'field': 'checksum'},
            {'label': _(u'UUID'), 'field': 'uuid'},
            {'label': _(u'Pages'), 'field': lambda x: x.documentpage_set.count()},
        ])

        subtemplates_list.append(
            {
                'name': 'generic_form_subtemplate.html',
                'context': {
                    'form': document_properties_form,
                    'object': document,
                    'title': _(u'document properties for: %s') % document,
                }
            },
        )
    else:
        preview_form = DocumentPreviewForm(document=document)
        subtemplates_list.append(
            {
                'name': 'generic_form_subtemplate.html',
                'context': {
                    'form': preview_form,
                    'object': document,
                }
            },
        )

        content_form = DocumentContentForm(document=document)

        subtemplates_list.append(
            {
                'name': 'generic_form_subtemplate.html',
                'context': {
                    'title': _(u'document data'),
                    'form': content_form,
                    'object': document,
                },
            }
        )

    return render_to_response('generic_detail.html', {
        'object': document,
        'document': document,
        'subtemplates_list': subtemplates_list,
        'disable_auto_focus': True,
    }, context_instance=RequestContext(request))
コード例 #12
0
def document_view(request, document_id):
    check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
            
    document = get_object_or_404(Document, pk=document_id)
    form = DocumentForm_view(instance=document, extra_fields=[
        {'label':_(u'Filename'), 'field':'file_filename'},
        {'label':_(u'File extension'), 'field':'file_extension'},
        {'label':_(u'File mimetype'), 'field':'file_mimetype'},
        {'label':_(u'File mime encoding'), 'field':'file_mime_encoding'},
        {'label':_(u'File size'), 'field':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
        {'label':_(u'Exists in storage'), 'field':'exists'},
        {'label':_(u'File path in storage'), 'field':'file'},
        {'label':_(u'Date added'), 'field':lambda x: x.date_added.date()},
        {'label':_(u'Time added'), 'field':lambda x: unicode(x.date_added.time()).split('.')[0]},
        {'label':_(u'Checksum'), 'field':'checksum'},
        {'label':_(u'UUID'), 'field':'uuid'},
        {'label':_(u'Pages'), 'field':lambda x: x.documentpage_set.count()},
    ])

        
    metadata_groups, errors = document.get_metadata_groups()
    if (request.user.is_staff or request.user.is_superuser) and errors:
        for error in errors:
            messages.warning(request, _(u'Metadata group query error: %s' % error))

    preview_form = DocumentPreviewForm(document=document)
    form_list = [
        {
            'form':form,
            'object':document,
            'grid':6,
        },
        {
            'form':preview_form,
            'title':_(u'document preview'),
            'object':document,
            'grid':6,
            'grid_clear':True,
        },
    ]
    subtemplates_dict = [
            {
                'name':'generic_list_subtemplate.html',
                'title':_(u'metadata'),
                'object_list':document.documentmetadata_set.all(),
                'extra_columns':[{'name':_(u'value'), 'attribute':'value'}],
                'hide_link':True,
            },
        ]
    
    if FILESERVING_ENABLE:
        subtemplates_dict.append({
            'name':'generic_list_subtemplate.html',
            'title':_(u'index links'),
            'object_list':document.documentmetadataindex_set.all(),
            'hide_link':True})

    sidebar_groups = []
    for group, data in metadata_groups.items():
        if len(data) or GROUP_SHOW_EMPTY:
            if len(data):
                if len(data) > GROUP_MAX_RESULTS:
                    total_string = '(%s out of %s)' % (GROUP_MAX_RESULTS, len(data))
                else:
                    total_string = '(%s)' % len(data)
            else:
                total_string = ''
              
            extra_columns = [{'name':'current','attribute':lambda x:
                    '<span class="famfam active famfam-resultset_previous"></span>' if x == document else ''}]
                    
            if GROUP_SHOW_THUMBNAIL:
                extra_columns.append({'name':_(u'thumbnail'), 'attribute': 
                        lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]),
                        reverse('document_thumbnail', args=[x.id]))})
                
            sidebar_groups.append({
                'title':'%s %s' % (group.label, total_string),
                'name':'generic_list_subtemplate.html',
                'object_list':data[:GROUP_MAX_RESULTS],
                'hide_columns':True,
                'hide_header':True,
                'extra_columns':extra_columns,
                })
            
    return render_to_response('generic_detail.html', {
        'form_list':form_list,
        'object':document,
        'subtemplates_dict':subtemplates_dict,
        'sidebar_subtemplates_dict':sidebar_groups,
    }, context_instance=RequestContext(request))
コード例 #13
0
ファイル: models.py プロジェクト: stefanw/mayan
    def set_properties(self):
        self._properties = SortedDict()
        if LSB:
            self.add_property(Property('is_lsb', _(u'LSB OS'), True))
            self.add_property(
                Property('distributor_id', _(u'Distributor ID'),
                         lsb_release('-i', '-s')))
            self.add_property(
                Property('description', _(u'Description'),
                         lsb_release('-d', '-s')))
            self.add_property(
                Property('release', _(u'Release'), lsb_release('-r', '-s')))
            self.add_property(
                Property('codename', _(u'Codename'), lsb_release('-c', '-s')))
            self.add_property(
                Property('sysinfo', _(u'System info'), uname('-a')))
        else:
            self.add_property(Property('is_posix', _(u'POSIX OS'), False))

        self.add_property(
            Property('architecture', _(u'OS architecture'),
                     platform.architecture()))
        self.add_property(
            Property('python_version', _(u'Python version'),
                     platform.python_version()))
        self.add_property(Property('hostname', _(u'Hostname'),
                                   platform.node()))
        self.add_property(Property('platform', _(u'Platform'), sys.platform))
        self.add_property(
            Property('machine', _(u'Machine'), platform.machine()))
        self.add_property(
            Property('processor', _(u'Processor'), platform.processor()))
        self.add_property(
            Property('cpus', _(u'Number of CPUs'), psutil.NUM_CPUS))
        self.add_property(
            Property('total_phymem', _(u'Total physical memory'),
                     pretty_size(psutil.TOTAL_PHYMEM)))
        self.add_property(
            Property(
                'disk_partitions', _(u'Disk partitions'), '; '.join([
                    '%s %s %s %s' % (partition.device, partition.mountpoint,
                                     partition.fstype, partition.opts)
                    for partition in psutil.disk_partitions()
                ])))

        try:
            self.add_property(
                Property('tesseract', _(u'tesseract version'),
                         pbs.tesseract('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(
                Property('tesseract', _(u'tesseract version'),
                         _(u'not found')))

        try:
            self.add_property(
                Property('unpaper', _(u'unpaper version'),
                         pbs.unpaper('-V').stdout))
        except pbs.CommandNotFound:
            self.add_property(
                Property('unpaper', _(u'unpaper version'), _(u'not found')))
コード例 #14
0
ファイル: models.py プロジェクト: eschipul/mayan
    def set_properties(self):
        self._properties = SortedDict()
        if LSB:
            self.add_property(Property('is_lsb', _(u'LSB OS'), True))
            self.add_property(Property('distributor_id', _(u'Distributor ID'), lsb_release('-i', '-s')))
            self.add_property(Property('description', _(u'Description'), lsb_release('-d', '-s')))
            self.add_property(Property('release', _(u'Release'), lsb_release('-r', '-s')))
            self.add_property(Property('codename', _(u'Codename'), lsb_release('-c', '-s')))
            self.add_property(Property('sysinfo', _(u'System info'), uname('-a')))
        else:
            self.add_property(Property('is_lsb', _(u'LSB OS'), False))

        self.add_property(Property('architecture', _(u'OS architecture'), platform.architecture()))
        self.add_property(Property('python_version', _(u'Python version'), platform.python_version()))
        self.add_property(Property('hostname', _(u'Hostname'), platform.node()))
        self.add_property(Property('platform', _(u'Platform'), sys.platform))
        self.add_property(Property('machine', _(u'Machine'), platform.machine()))
        self.add_property(Property('processor', _(u'Processor'), platform.processor()))
        self.add_property(Property('cpus', _(u'Number of CPUs'), psutil.NUM_CPUS))
        self.add_property(Property('total_phymem', _(u'Total physical memory'), pretty_size(psutil.TOTAL_PHYMEM)))
        self.add_property(Property('disk_partitions', _(u'Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()])))

        tesseract = pbs.Command(TESSERACT_PATH)
        try:
            self.add_property(Property('tesseract', _(u'tesseract version'), tesseract('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(Property('tesseract', _(u'tesseract version'), _(u'not found')))
        except Exception:
            self.add_property(Property('tesseract', _(u'tesseract version'), _(u'error getting version')))

        unpaper = pbs.Command(UNPAPER_PATH)
        try:
            self.add_property(Property('unpaper', _(u'unpaper version'), unpaper('-V').stdout))
        except pbs.CommandNotFound:
            self.add_property(Property('unpaper', _(u'unpaper version'), _(u'not found')))
        except Exception:
            self.add_property(Property('unpaper', _(u'unpaper version'), _(u'error getting version')))

        pdftotext = pbs.Command(PDFTOTEXT_PATH)
        try:
            self.add_property(Property('pdftotext', _(u'pdftotext version'), pdftotext('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(Property('pdftotext', _(u'pdftotext version'), _(u'not found')))
        except Exception:
            self.add_property(Property('pdftotext', _(u'pdftotext version'), _(u'error getting version')))

        self.add_property(Property('mayan_version', _(u'Mayan EDMS version'), mayan_version))
        self.add_property(Property('fabfile', _(u'Installed via fabfile'), os.path.exists(FABFILE_MARKER)))

        try:
            repo = Repo(settings.PROJECT_ROOT)
        except:
            self.add_property(Property('is_git_repo', _(u'Running from a Git repository'), False))
        else:
            repo.config_reader()
            headcommit = repo.head.commit
            self.add_property(Property('is_git_repo', _(u'Running from a Git repository'), True))
            self.add_property(Property('repo_remotes', _(u'Repository remotes'), ', '.join([unicode(remote) for remote in repo.remotes])))
            self.add_property(Property('repo_remotes_urls', _(u'Repository remotes URLs'), ', '.join([unicode(remote.url) for remote in repo.remotes])))
            self.add_property(Property('repo_head_reference', _(u'Branch'), repo.head.reference))
            self.add_property(Property('headcommit_hexsha', _(u'HEAD commit hex SHA'), headcommit.hexsha))
            self.add_property(Property('headcommit_author', _(u'HEAD commit author'), headcommit.author))
            self.add_property(Property('headcommit_authored_date', _(u'HEAD commit authored date'), time.asctime(time.gmtime(headcommit.authored_date))))
            self.add_property(Property('headcommit_committer', _(u'HEAD commit committer'), headcommit.committer))
            self.add_property(Property('headcommit_committed_date', _(u'HEAD commit committed date'), time.asctime(time.gmtime(headcommit.committed_date))))
            self.add_property(Property('headcommit_message', _(u'HEAD commit message'), headcommit.message))
コード例 #15
0
ファイル: views.py プロジェクト: coulix/mayan
def document_view(request, document_id):
    check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
            
    document = get_object_or_404(Document, pk=document_id)
    form = DocumentForm_view(instance=document, extra_fields=[
        {'label':_(u'Filename'), 'field':'file_filename'},
        {'label':_(u'File extension'), 'field':'file_extension'},
        {'label':_(u'File mimetype'), 'field':'file_mimetype'},
        {'label':_(u'File mime encoding'), 'field':'file_mime_encoding'},
        {'label':_(u'File size'), 'field':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
        {'label':_(u'Exists in storage'), 'field':'exists'},
        {'label':_(u'Date added'), 'field':lambda x: x.date_added.date()},
        {'label':_(u'Time added'), 'field':lambda x: unicode(x.date_added.time()).split('.')[0]},
        {'label':_(u'Checksum'), 'field':'checksum'},
        {'label':_(u'UUID'), 'field':'uuid'},
        {'label':_(u'Pages'), 'field':lambda x: x.documentpage_set.count()},
    ])

        
    metadata_groups, errors = document.get_metadata_groups()
    if request.user.is_staff and errors:
        for error in errors:
            messages.warning(request, _(u'Metadata group query error: %s' % error))

    preview_form = DocumentPreviewForm(document=document)
    form_list = [
        {
            'form':form,
            'object':document,
            'grid':6,
        },
        {
            'form':preview_form,
            'title':_(u'document preview'),
            'object':document,
            'grid':6,
            'grid_clear':True,
        },
    ]
    subtemplates_dict = [
            {
                'name':'generic_list_subtemplate.html',
                'title':_(u'metadata'),
                'object_list':document.documentmetadata_set.all(),
                'extra_columns':[{'name':_(u'value'), 'attribute':'value'}],
                'hide_link':True,
            },
        ]
    
    if FILESERVING_ENABLE:
        subtemplates_dict.append({
            'name':'generic_list_subtemplate.html',
            'title':_(u'index links'),
            'object_list':document.documentmetadataindex_set.all(),
            'hide_link':True})

    sidebar_groups = []
    for group, data in metadata_groups.items():
        if len(data) or GROUP_SHOW_EMPTY:
            if len(data):
                if len(data) > GROUP_MAX_RESULTS:
                    total_string = '(%s out of %s)' % (GROUP_MAX_RESULTS, len(data))
                else:
                    total_string = '(%s)' % len(data)
            else:
                total_string = ''
              
            extra_columns = [{'name':'current','attribute':lambda x:
                    '<span class="famfam active famfam-resultset_previous"></span>' if x == document else ''}]
                    
            if GROUP_SHOW_THUMBNAIL:
                extra_columns.append({'name':_(u'thumbnail'), 'attribute': 
                        lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]),
                        reverse('document_thumbnail', args=[x.id]))})
                
            sidebar_groups.append({
                'title':'%s %s' % (group.label, total_string),
                'name':'generic_list_subtemplate.html',
                'object_list':data[:GROUP_MAX_RESULTS],
                'hide_columns':True,
                'hide_header':True,
                'extra_columns':extra_columns,
                })
            
    return render_to_response('generic_detail.html', {
        'form_list':form_list,
        'object':document,
        'subtemplates_dict':subtemplates_dict,
        'sidebar_subtemplates_dict':sidebar_groups,
    }, context_instance=RequestContext(request))