Skip to content

Instantly share code, notes, and snippets.

View mcantelon's full-sized avatar

Mike Cantelon mcantelon

View GitHub Profile
demo@archivematicaDev:~$ ls -l /usr/share/elasticsearch/
total 36
drwxrwxr-x 2 demo demo 4096 Apr 22 14:42 bin
drwxrwxr-x 2 demo demo 4096 Apr 22 14:42 config
drwxrwxr-x 3 demo demo 4096 Apr 22 14:42 lib
-rw-r--r-- 1 demo demo 11358 Oct 13 2012 LICENSE.txt
-rw-r--r-- 1 demo demo 165 Oct 13 2012 NOTICE.txt
-rw-r--r-- 1 demo demo 7935 Mar 25 02:39 README.textile
@mcantelon
mcantelon / gist:5359715
Created April 11, 2013 00:36
Create SIP
# get transfer info
transfer = models.Transfer.objects.get(uuid=transfer_uuid)
transfer_path = transfer.currentlocation.replace(
'%sharedPath%',
helpers.get_server_config_value('sharedDirectory')
)
# extra transfer name
transfer_directory_name = os.path.basename(transfer_path[:-1])
transfer_name = transfer_directory_name[:-37]
from lxml import etree
stuff = {
"aaa": "bbb",
"ccc": "ddd"
}
# create XML
root = etree.Element('processingMCP')
choices = etree.Element('preconfiguredChoices')
@mcantelon
mcantelon / gist:5094314
Last active December 14, 2015 13:38
Django dynamic form:
forms.py:
class ProcessingForm(forms.Form):
def __init__(self, *args, **kwargs):
if 'extra' in kwargs:
extra = kwargs.pop('extra')
super(ProcessingForm, self).__init__(*args, **kwargs)
if 'extra' in locals():
for i, question in enumerate(extra):
@mcantelon
mcantelon / sword-diag.py
Created February 26, 2013 00:20
Diagnose Qubit-SWORD issus
sudo apt-get install curl
curl https://raw.github.com/artefactual/archivematica/master/src/archivematicaCommon/lib/utilities/sword-diagnose.py | python
Part I
1. Why the Web needs Node
2. Getting started with Node
3. Asynchronous programming
Part II
4. Building Node web applications
5. Storing Node application data
1) Use one of the task files as guidance… for example:
lib/task/import/csvAuthorityRecordImportTask.class.php
2) Some code to create a repo:
<?php
$repo = new QubitRepository();
$repo->authorizedFormOfName = 'My Repository';
@mcantelon
mcantelon / gist:3990484
Created October 31, 2012 22:54
Check if index exists
conn = pyes.ES('127.0.0.1:9200')
indexes = conn.get_indices()
if 'fpr_file' not in indexes:
# Grab relevant FPR data from the DB
results = get_fpr_table()
# Setup indexing for some Elastic Search action.
for row in results:
conn.index(row, 'fpr_file', 'fpr_files')
@mcantelon
mcantelon / es-rebuild
Created August 28, 2012 01:09
es-rebuild
#!/usr/bin/env python
import sys, MySQLdb, cPickle, base64
sys.path.append("/usr/lib/archivematica/archivematicaCommon")
import databaseInterface
sys.path.append("/usr/lib/archivematica/archivematicaCommon/externals")
import pyes
def index_documents_from_database(index, type):
indexed = 0
@mcantelon
mcantelon / elasticSearchIndexProcessTransfer.py
Created August 24, 2012 21:16
elasticSearchIndexProcessTransfer.py
#!/usr/bin/python -OO
# This file is part of Archivematica.
#
# Copyright 2010-2011 Artefactual Systems Inc. <http://artefactual.com>
#
# Archivematica is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.