Classes | Functions | Variables
galleryMaker Namespace Reference

Classes

class  FileNBE
 
class  SavedFigure
 

Functions

def authenticate (urlStr)
 
def getPage (url)
 
def getFileNBE (fileDom)
 
def loadStatusCache (filePath)
 
def panelRowOpen ()
 
def panelRowClose ()
 
def title (str)
 
def heading1 (str)
 
def heading2 (str)
 
def heading3 (str)
 
def heading4 (str)
 
def link (text, url)
 
def paragraph (str, width=None)
 
def entry (str)
 
def hrule ()
 
def hruleWide ()
 
def gridEntry (fig, thumbWidth)
 
def bootStrap ()
 
def bodyOpen ()
 
def bodyClose ()
 
def jumbo (content)
 
def navBar (categories=None)
 

Variables

string xmlOut = "&outformat=xml"
 FUNCTIONS ############# The first part of this file will define functions and create objects that will aid in web interface. More...
 
string endl = "\n"
 
string hendl = "<br>"
 
 pwMan = urllib2.HTTPBasicAuthHandler()
 
string webPath = "/nusoft/app/web/htdoc/nova/blessedplots/"
 CONFIGURABLE PARAMETERS #############. More...
 
string officialURL = "http://nova-docdb.fnal.gov:8080/cgi-bin/Search?topics=370"
 
string thumbsDir = "thumbs/"
 
string wrappersDir = "wrappers/"
 
 thumbsPath = webPath+thumbsDir
 
 wrappersPath = webPath+wrappersDir
 
string tempDir = "temp/"
 
 tempPath = webPath+tempDir
 
 thumbSize = str(225)
 
string pageTitle = "NOvA Blessed Plots and Figures Gallery"
 
string gridTitle = "NOvA Blessed Plots and Figures Grid"
 
 fullWidth = str(1000)
 
 pw = open(os.environ['NOVADOCPWDFILE'], 'r').readlines()[0].strip()
 
 optParser = optparse.OptionParser()
 MAIN EXECUTIING BODY #############. More...
 
 action
 
 help
 
 options
 
 args
 
 officialPage = getPage(officialURL)
 
 officialDom = minidom.parse(officialPage)
 
 documents = officialDom.getElementsByTagName("document")
 
string statusPath = webPath+"status.txt"
 
 cacheStatus = loadStatusCache(statusPath)
 
 status = OrderedDict()
 
 id = doc.getAttribute("id")
 
 rev = doc.getElementsByTagName("docrevision")[0]
 
 mod = rev.getAttribute("modified")
 
bool changed = False
 
 statusFile = open(statusPath, 'w')
 
 topicMap = dict()
 
 docURL = doc.getAttribute("href")+xmlOut
 
 docPage = getPage(docURL)
 
 docDom = minidom.parse(docPage)
 
 topics = docDom.getElementsByTagName("topic")
 
list topicNames = []
 
 nameDom = topic.getElementsByTagName("name")
 
 name = nameDom[0].lastChild.nodeValue
 
 gallery = codecs.open(webPath + "gallery_new.html", 'w', "utf-8")
 
list savedFigs = []
 
 savedFigsByTopic = OrderedDict()
 
 docId = docDom.getAttribute("id")
 Loop over docs in each topic. More...
 
 docTitle = docDom.getElementsByTagName("title")[0].lastChild.nodeValue
 
 files = docDom.getElementsByTagName("file")
 
list nbes = [ getFileNBE(fileDom) for fileDom in files]
 Construct list of files from DOM objects. More...
 
 fileNBE = getFileNBE(fileDom)
 
 arcUrl = fileDom.getAttribute("href")
 
string tempName = tempPath+'docArchive.tar.gz'
 
 tar = tarfile.open(tempName, 'r')
 
 base
 
 ext
 
string url = 'http://nova-docdb.fnal.gov:8080/cgi-bin/RetrieveFile?docid='
 
bool foundOnceAlready = False
 loop over files More...
 
string shortName = "doc"
 THUMBNAIL BLOCK: We need to make a thumbnail for each. More...
 
string thumbName = shortName+".png"
 
 thumbPath = thumbsPath+thumbName
 
 thumbWebPath = thumbsDir+thumbName
 
string wrapperName = shortName+".html"
 
 wrapperPath = wrappersPath+wrapperName
 
 wrapperWebPath = wrappersDir+wrapperName
 
 imgUrl = otherFileNBE.url
 
list formats = []
 
 capFile = tarfile.open(fileNBE.tarPath, 'r')\
 
 caption = cgi.escape(str(capFile.read()).decode(encoding="utf-8", errors='ignore')).replace("\n", "<br> \n").replace("\t", "&emsp;")
 
 fig = SavedFigure(topic, thumbWebPath, caption, formats, docURL, docTitle, wrapperWebPath, wrapperPath, fileNBE.base)
 
 grid = codecs.open(webPath + "grid_new.html", 'w', "utf-8")
 
int gridNumCols = 4
 
 gridThumbWidth = str(240)
 
int currentCell = 1
 
 sGrid = codecs.open(webPath + "sortgrid_new.html", 'w', "utf-8")
 

Function Documentation

def galleryMaker.authenticate (   urlStr)

Definition at line 31 of file galleryMaker.py.

Referenced by getPage().

31 def authenticate(urlStr):
32  pwMan.add_password( realm ="PasswordRequired",
33  uri = urlStr,
34  user = 'nova',
35  passwd = pw)
36  opener = urllib2.build_opener(pwMan)
37  urllib2.install_opener(opener)
38 
39 # Pages on DocDB will be behind a password. getPage() will add the password to the manager
40 # and return the webpage as a (web) file object.
def authenticate(urlStr)
Definition: galleryMaker.py:31
def galleryMaker.bodyClose ( )

Definition at line 194 of file galleryMaker.py.

194 def bodyClose():
195  return """
196  <!-- Bootstrap core JavaScript
197  ================================================== -->
198  <!-- Placed at the end of the document so the pages load faster -->
199  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
200  <script src="static/bootstrap/js/bootstrap.min.js"></script>
201 
202  </body>'
203  """
204 
def galleryMaker.bodyOpen ( )

Definition at line 191 of file galleryMaker.py.

191 def bodyOpen():
192  return '<body role="document">'
193 
def galleryMaker.bootStrap ( )

Definition at line 169 of file galleryMaker.py.

169 def bootStrap():
170  return """
171  <head>
172  <meta charset="utf-8">
173  <meta http-equiv="X-UA-Compatible" content="IE=edge">
174  <meta name="viewport" content="width=device-width, initial-scale=1">
175  <meta name="description" content="">
176  <meta name="author" content="">
177  <link rel="icon" href="../../favicon.ico">
178 
179 
180 
181  <!-- Bootstrap core CSS -->
182  <link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
183 
184  <!-- Custom styles for this template -->
185  <link href="static/bootstrap/css/theme.css" rel="stylesheet">
186 
187 
188 
189  """
190 
def galleryMaker.entry (   str)

Definition at line 147 of file galleryMaker.py.

147 def entry(str):
148  return "<li>" + str + "</li>" + endl
def entry(str)
def galleryMaker.getFileNBE (   fileDom)

Definition at line 57 of file galleryMaker.py.

57 def getFileNBE(fileDom):
58  # Find out if there is a "description" (for renamed files)
59  descriptions = fileDom.getElementsByTagName("description")
60  if len(descriptions) > 0:
61  fileName = descriptions[0].lastChild.nodeValue
62  #Otherwise use the filename
63  else:
64  fileName = fileDom.getElementsByTagName("name")[0].lastChild.nodeValue
65 
66  url = fileDom.getAttribute("href")
67  baseExt = os.path.splitext(fileName)
68  return FileNBE(fileName, baseExt[0], baseExt[1], url)
69 
def getFileNBE(fileDom)
Definition: galleryMaker.py:57
def galleryMaker.getPage (   url)

Definition at line 41 of file galleryMaker.py.

References authenticate().

41 def getPage(url):
42  authenticate(url)
43  req = urllib2.Request(url)
44  page = urllib2.urlopen(url)
45  return page
46 
47 # FileNBE objects hold the full name, base and extension
def authenticate(urlStr)
Definition: galleryMaker.py:31
def getPage(url)
Definition: galleryMaker.py:41
def galleryMaker.gridEntry (   fig,
  thumbWidth 
)

Definition at line 155 of file galleryMaker.py.

References link().

155 def gridEntry(fig, thumbWidth):
156  #creates table entry with image and text
157  entry = '<td valign="bottom" style="border:1px solid black" >'
158  entry += link('<img src="' + fig.thumbWebPath + '" width="'+ thumbWidth +'" style="border-style: none" Title="'+fig.caption+'" />', fig.wrapperWebPath)
159  entry += '<center>'
160  entry += '<p>'
161  entry += fig.formatsBar()
162  entry += '</p>'
163  entry += '</center>'
164  entry += '</td>'
165 
166  entry += endl
167  return entry
168 
def link(text, url)
def gridEntry(fig, thumbWidth)
def galleryMaker.heading1 (   str)

Definition at line 130 of file galleryMaker.py.

Referenced by galleryMaker.SavedFigure.makeWrapper().

130 def heading1(str):
131  return "<h1>" + str + "</h1>" + endl
def heading1(str)
def galleryMaker.heading2 (   str)

Definition at line 132 of file galleryMaker.py.

Referenced by galleryMaker.SavedFigure.makeWrapper().

132 def heading2(str):
133  return "<h2>" + str + "</h2>" + endl
def heading2(str)
def galleryMaker.heading3 (   str)

Definition at line 134 of file galleryMaker.py.

134 def heading3(str):
135  return "<h3>" + str + "</h3>"+ endl
def heading3(str)
def galleryMaker.heading4 (   str)

Definition at line 136 of file galleryMaker.py.

136 def heading4(str):
137  return "<h4>" + str + "</h4>" + endl
def heading4(str)
def galleryMaker.hrule ( )

Definition at line 149 of file galleryMaker.py.

Referenced by galleryMaker.SavedFigure.makeWrapper().

149 def hrule():
150  return '<hr width="100%" align="left" noshade color="#000000">' + endl
151 
def galleryMaker.hruleWide ( )

Definition at line 152 of file galleryMaker.py.

152 def hruleWide():
153  return '<hr align="left" noshade color="#000000">' + endl
154 
def galleryMaker.jumbo (   content)

Definition at line 205 of file galleryMaker.py.

205 def jumbo(content):
206  t = ' <div class="jumbotron">' + endl
207  t+= " " + content + endl
208  t+= '</div>' + endl
209  return t
210 
211 
def jumbo(content)
def galleryMaker.link (   text,
  url 
)

Definition at line 138 of file galleryMaker.py.

Referenced by galleryMaker.SavedFigure.formatsBar(), gridEntry(), and navBar().

138 def link(text, url):
139  return '<a href="'+ url + '">' + text + "</a>" + endl
def link(text, url)
def galleryMaker.loadStatusCache (   filePath)

Definition at line 70 of file galleryMaker.py.

References open(), and split().

70 def loadStatusCache(filePath):
71  cacheFile = open(filePath, 'r')
72  cache = OrderedDict()
73  for line in cacheFile:
74  splitLine = line.strip().split("@")
75  cache[splitLine[0]] = splitLine[1]
76  return cache
77 
void split(double tt, double *fr)
procfile open("FD_BRL_v0.txt")
def loadStatusCache(filePath)
Definition: galleryMaker.py:70
def galleryMaker.navBar (   categories = None)

Definition at line 212 of file galleryMaker.py.

References link().

212 def navBar(categories=None):
213  t = """
214  <!-- Fixed navbar -->
215  <div class="navbar navbar-default navbar-fixed-top" role="navigation">
216  <div class="container">
217  <div class="navbar-header">
218  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
219  <span class="sr-only">Toggle navigation</span>
220  <span class="icon-bar"></span>
221  <span class="icon-bar"></span>
222  <span class="icon-bar"></span>
223  </button>
224  <a class="navbar-brand" href="#">Blessed Plots</a>
225  </div>
226  <div class="navbar-collapse collapse">
227  <ul class="nav navbar-nav">
228  """
229  t+= ' <li>' + link("Grid View", "sortgrid.html") + '</li>' + endl
230  t+= ' <li>' + link("Unsorted GridView", "grid.html") + '</li>' + endl
231  t+= ' <li>' + link("Captioned View", "gallery.html") + '</li>' + endl
232  if categories:
233  t+= """
234  <li class="dropdown">
235  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Categories <span class="caret"></span></a>
236  <ul class="dropdown-menu" role="menu">
237 
238  """
239  for cat in categories:
240  t +=' <li><a href="#' + cat.strip().replace(" ", "").lower() + '">' + cat + '</a></li>' + endl
241  t+="""
242  </ul>
243  </li>
244  """
245  t+= """
246  </ul>
247  </div><!--/.nav-collapse -->
248  </div>
249  </div>
250  """
251  return t
252 
253 
254 """
255  <!-- Fixed navbar -->
256  <div class="navbar navbar-default navbar-fixed-top" role="navigation">
257  <div class="container">
258  <div class="navbar-header">
259  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
260  <span class="sr-only">Toggle navigation</span>
261  <span class="icon-bar"></span>
262  <span class="icon-bar"></span>
263  <span class="icon-bar"></span>
264  </button>
265  <a class="navbar-brand" href="#">Project name</a>
266  </div>
267  <div class="navbar-collapse collapse">
268 
269  </ul>
270  </div><!--/.nav-collapse -->
271  </div>
272  </div>
273 """
274 
275 
def navBar(categories=None)
def link(text, url)
def galleryMaker.panelRowClose ( )

Definition at line 120 of file galleryMaker.py.

121  return """
122  </div><!-- /.col-sm-4 -->
123  </div>
124 
125  """
126 
127 # HTML Helper functions
def panelRowClose()
def galleryMaker.panelRowOpen ( )

Definition at line 115 of file galleryMaker.py.

116  return """
117  <div class="row">
118  <div class="col-sm-4">
119  """
def panelRowOpen()
def galleryMaker.paragraph (   str,
  width = None 
)

Definition at line 140 of file galleryMaker.py.

Referenced by galleryMaker.SavedFigure.makeWrapper().

140 def paragraph(str, width=None):
141  p = ""
142  if width: p += '<p style="width:'+width+'px;">'
143  else: p += '<p>'
144 
145  p+= str + "</p>" + endl
146  return p
def paragraph(str, width=None)
def galleryMaker.title (   str)

Definition at line 128 of file galleryMaker.py.

128 def title(str):
129  return "<title>" + str + "</title>" + endl
def title(str)

Variable Documentation

galleryMaker.action

Definition at line 295 of file galleryMaker.py.

galleryMaker.arcUrl = fileDom.getAttribute("href")

Definition at line 447 of file galleryMaker.py.

galleryMaker.args

Definition at line 303 of file galleryMaker.py.

galleryMaker.base

Definition at line 452 of file galleryMaker.py.

galleryMaker.cacheStatus = loadStatusCache(statusPath)

Definition at line 317 of file galleryMaker.py.

galleryMaker.capFile = tarfile.open(fileNBE.tarPath, 'r')\

Definition at line 513 of file galleryMaker.py.

string galleryMaker.caption = cgi.escape(str(capFile.read()).decode(encoding="utf-8", errors='ignore')).replace("\n", "<br> \n").replace("\t", "&emsp;")

Definition at line 517 of file galleryMaker.py.

bool galleryMaker.changed = False

Definition at line 325 of file galleryMaker.py.

int galleryMaker.currentCell = 1

Definition at line 563 of file galleryMaker.py.

galleryMaker.docDom = minidom.parse(docPage)

Definition at line 354 of file galleryMaker.py.

galleryMaker.docId = docDom.getAttribute("id")

Loop over docs in each topic.

Definition at line 434 of file galleryMaker.py.

galleryMaker.docPage = getPage(docURL)

Definition at line 353 of file galleryMaker.py.

galleryMaker.docTitle = docDom.getElementsByTagName("title")[0].lastChild.nodeValue

Definition at line 436 of file galleryMaker.py.

galleryMaker.documents = officialDom.getElementsByTagName("document")

Definition at line 310 of file galleryMaker.py.

galleryMaker.docURL = doc.getAttribute("href")+xmlOut

Definition at line 350 of file galleryMaker.py.

string galleryMaker.endl = "\n"

Definition at line 22 of file galleryMaker.py.

galleryMaker.ext

Definition at line 527 of file galleryMaker.py.

galleryMaker.fileNBE = getFileNBE(fileDom)

Definition at line 445 of file galleryMaker.py.

galleryMaker.files = docDom.getElementsByTagName("file")

Definition at line 437 of file galleryMaker.py.

list galleryMaker.formats = []

Definition at line 504 of file galleryMaker.py.

tuple galleryMaker.foundOnceAlready = False

loop over files

Definition at line 466 of file galleryMaker.py.

galleryMaker.fullWidth = str(1000)

Definition at line 288 of file galleryMaker.py.

galleryMaker.gallery = codecs.open(webPath + "gallery_new.html", 'w', "utf-8")

Definition at line 392 of file galleryMaker.py.

galleryMaker.grid = codecs.open(webPath + "grid_new.html", 'w', "utf-8")
int galleryMaker.gridNumCols = 4

Definition at line 555 of file galleryMaker.py.

galleryMaker.gridThumbWidth = str(240)

Definition at line 556 of file galleryMaker.py.

string galleryMaker.gridTitle = "NOvA Blessed Plots and Figures Grid"

Definition at line 287 of file galleryMaker.py.

galleryMaker.help

Definition at line 296 of file galleryMaker.py.

string galleryMaker.hendl = "<br>"

Definition at line 23 of file galleryMaker.py.

galleryMaker.id = doc.getAttribute("id")

Definition at line 320 of file galleryMaker.py.

galleryMaker.imgUrl = otherFileNBE.url

Definition at line 483 of file galleryMaker.py.

galleryMaker.mod = rev.getAttribute("modified")

Definition at line 322 of file galleryMaker.py.

galleryMaker.name = nameDom[0].lastChild.nodeValue

Definition at line 371 of file galleryMaker.py.

galleryMaker.nameDom = topic.getElementsByTagName("name")

Definition at line 369 of file galleryMaker.py.

list galleryMaker.nbes = [ getFileNBE(fileDom) for fileDom in files]

Construct list of files from DOM objects.

Definition at line 440 of file galleryMaker.py.

galleryMaker.officialDom = minidom.parse(officialPage)

Definition at line 309 of file galleryMaker.py.

galleryMaker.officialPage = getPage(officialURL)

Definition at line 306 of file galleryMaker.py.

string galleryMaker.officialURL = "http://nova-docdb.fnal.gov:8080/cgi-bin/Search?topics=370"

Definition at line 278 of file galleryMaker.py.

galleryMaker.options

Definition at line 303 of file galleryMaker.py.

galleryMaker.optParser = optparse.OptionParser()

MAIN EXECUTIING BODY #############.

Definition at line 294 of file galleryMaker.py.

string galleryMaker.pageTitle = "NOvA Blessed Plots and Figures Gallery"

Definition at line 286 of file galleryMaker.py.

galleryMaker.pw = open(os.environ['NOVADOCPWDFILE'], 'r').readlines()[0].strip()

Definition at line 290 of file galleryMaker.py.

galleryMaker.pwMan = urllib2.HTTPBasicAuthHandler()

Definition at line 26 of file galleryMaker.py.

galleryMaker.rev = doc.getElementsByTagName("docrevision")[0]

Definition at line 321 of file galleryMaker.py.

list galleryMaker.savedFigs = []

Definition at line 418 of file galleryMaker.py.

galleryMaker.savedFigsByTopic = OrderedDict()

Definition at line 419 of file galleryMaker.py.

galleryMaker.sGrid = codecs.open(webPath + "sortgrid_new.html", 'w', "utf-8")

Definition at line 580 of file galleryMaker.py.

string galleryMaker.shortName = "doc"
galleryMaker.status = OrderedDict()

Definition at line 318 of file galleryMaker.py.

galleryMaker.statusFile = open(statusPath, 'w')

Definition at line 341 of file galleryMaker.py.

string galleryMaker.statusPath = webPath+"status.txt"

Definition at line 316 of file galleryMaker.py.

galleryMaker.tar = tarfile.open(tempName, 'r')

Definition at line 450 of file galleryMaker.py.

string galleryMaker.tempDir = "temp/"

Definition at line 283 of file galleryMaker.py.

galleryMaker.tempName = tempPath+'docArchive.tar.gz'
galleryMaker.tempPath = webPath+tempDir

Definition at line 284 of file galleryMaker.py.

string galleryMaker.thumbName = shortName+".png"

Definition at line 470 of file galleryMaker.py.

galleryMaker.thumbPath = thumbsPath+thumbName

Definition at line 471 of file galleryMaker.py.

string galleryMaker.thumbsDir = "thumbs/"

Definition at line 279 of file galleryMaker.py.

galleryMaker.thumbSize = str(225)

Definition at line 285 of file galleryMaker.py.

galleryMaker.thumbsPath = webPath+thumbsDir

Definition at line 281 of file galleryMaker.py.

galleryMaker.thumbWebPath = thumbsDir+thumbName

Definition at line 472 of file galleryMaker.py.

galleryMaker.topicMap = dict()

Definition at line 347 of file galleryMaker.py.

list galleryMaker.topicNames = []

Definition at line 357 of file galleryMaker.py.

galleryMaker.topics = docDom.getElementsByTagName("topic")

Definition at line 355 of file galleryMaker.py.

string galleryMaker.url = 'http://nova-docdb.fnal.gov:8080/cgi-bin/RetrieveFile?docid='

Definition at line 459 of file galleryMaker.py.

string galleryMaker.webPath = "/nusoft/app/web/htdoc/nova/blessedplots/"

CONFIGURABLE PARAMETERS #############.

Definition at line 277 of file galleryMaker.py.

string galleryMaker.wrapperName = shortName+".html"

Definition at line 473 of file galleryMaker.py.

galleryMaker.wrapperPath = wrappersPath+wrapperName

Definition at line 474 of file galleryMaker.py.

string galleryMaker.wrappersDir = "wrappers/"

Definition at line 280 of file galleryMaker.py.

galleryMaker.wrappersPath = webPath+wrappersDir

Definition at line 282 of file galleryMaker.py.

galleryMaker.wrapperWebPath = wrappersDir+wrapperName

Definition at line 475 of file galleryMaker.py.

string galleryMaker.xmlOut = "&outformat=xml"

FUNCTIONS ############# The first part of this file will define functions and create objects that will aid in web interface.

Definition at line 21 of file galleryMaker.py.