Monday, February 5, 2018

Python, eXist, Alliance Share the Work


1. Python

    Did a little work in python this week to set up a script that we can just run with one command to restore the various directories in our eXist database. Prompts the user for which back up and then iterates through the directories we have indicated we need to restore.

#!/usr/bin/env python

import subprocess

#Directories to restore list

directories = ["apps/METSALTO", "bulletincatalogs", "collegian", "commencement", "handbooks", "puritan", "scene", "scrapbooks", "wallulah", "system/config/db"]

#Prompt user for backup directory

backup_date = raw_input('Enter the backup directory: ')

#Note to run by cron just place the date in the file here and comment line above out

#backup_date = ""

report_date = backup_date + ".txt"

rout = open(report_date, 'w')

program = "/var/lib/exist/eXist-db/bin/backup.sh"

for directory in directories :

    directory_backup = "/backup/" + backup_date + "/db/" + directory + "/__contents__.xml"
    arguments = ["-u", "admin", "-p", "XXXXX", "-r", directory_backup]
    command = [program]
    command.extend(arguments)

    #restore each directory and send output to file
    subprocess.call(command, stdout=rout)

2.  eXist

 I wrote a simple XQuery that could be run in the Exide that runs through the different eXist collections that we want to reindex after the restore command run from above.

xquery version "3.0" encoding "UTF-8";
declare option exist:serialize "method=xhtml media-type=text/html indent=yes";
    let $data-collection := '/db'
    let $login := xmldb:login($data-collection, 'admin', 'XXXXXX')
      for $directory in ("/bulletincatalogs/fulltext","/bulletincatalogs/mets","/collegian/fulltext","/collegian/mets","/handbooks/fulltext","/handbooks/mets","/puritan/fulltext","/puritan/mets","/scene/fulltext","scene/mets","scrapbook/fulltext","scrapbook/mets","walullah/fulltext","/walullah/mets")
        let $start-time := util:system-time()
        let $collection := concat($data-collection,$directory)
          let $reindex := xmldb:reindex($collection)
            let $runtime-ms := ((util:system-time() - $start-time)
                                 div xs:dayTimeDuration('PT1S'))  * 1000
                return
                  <html>
                      <head>
                         <title>Reindex</title>
                      </head>
                      <body>
                      <h1>Reindex</h1>
                      <p>The index for {$collection} was updated in {$runtime-ms} milliseconds.</p>
                      </body>
                  </html>

                  So this works just fine, but my supervisor would prefer we did not run through the Exide interface over HTTP. Okay, so finished the week, by trying to write an ant task to accomplish that, I'll share my success or failure with that next week.

                  3. Alliance Sharing the Work

                  On Friday morning I had a great call with the DUX leaders Anne at UW and Molly at PSU and Cassie from the Alliance offices. In my opinion, our group was doing too much hand holding for the other libraries with each Primo Upgrade. ExLibris puts out plenty of information at each upgrade, and in the past, we had been doing a bunch of customization to that information. Where in my opinion it just was not necessary. And if anyone cared enough they would be able to go through the information from ExLibris and gather what they need from it. 

                  The folks on the DUX call agreed, and we also agreed to allow people to just add their own issues to a spreadsheet for tracking issues with each upgrade. If the issue is important to you document it in the spreadsheet, no need to send to me to document, you can edit the spreadsheet just as easy as I can. If you care about the upgrade you will do testing and put your results and calls in the Google Doc folder that everyone can edit and read.
                  I now get to share this information with my group, maybe I should have told them about this, but I have to think they will be for the change as well. Then I will present the changes on the Alliance Discovery call on the 15th.

                  No comments:

                  Post a Comment