-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunBlessedPlots.py
More file actions
executable file
·46 lines (36 loc) · 1.96 KB
/
RunBlessedPlots.py
File metadata and controls
executable file
·46 lines (36 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
#///////////////////////////////////////////////////////////////////////////////
#///////////////////////////////////////////////////////////////////////////////
# BLESSED PLOTS WEB BACKEND
#
# This script maintains the database of blessed plots for presentation on the
# web.
import config #/// User configuration
import bp #/// Blessed plots specific functions
# Start by setting some things up. This involves printing a splash screen
# and checking for the existence of a JSON file with potentially outdated
# document information in it
bp.Init()
# Get all the document information from DocDB.
documents_curr = bp.GetDocumentInfoFromDocDB()
# Get all the document information from the pre-existing JSON file. If there is
# no JSON file already, the REGENERATE flag will be set to True and an empty
# array will be returned here.
documents_prev = bp.GetDocumentInfoFromDisk()
# Take in the output from the previous two lines. This checks for discrepencies
# between the 'current' and 'previous' lists. Files that have been added or
# modified will be returned by this function to be processed.
documents_to_process = bp.FindChanges(documents_curr, documents_prev)
# Fetch files for the new documents, remember where we fetched them to
tmpdir = bp.DownloadFiles(documents_to_process)
# Look through the directory to associate image files with their captions
# It also takes documents_to_process and documents_prev as it will copy
# the old json info back if the old entry has not been modified
bp.FindFiles(tmpdir, documents_curr, documents_to_process, documents_prev)
# Generate thumbnails in the web directory. The first argument is simply an
# array of DocDB IDs, so the second argument is needed to extract necessary
# info about those IDs, like filenames, etc.
bp.ProcessImages(documents_to_process, documents_curr, tmpdir)
# Save current document info to JSON file on disk for use by the website and
# this script later.
bp.WriteJSON(documents_curr)