diff options
author | Michael Elkins <melkins@tislabs.com> | 2010-10-19 23:13:30 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2010-10-19 23:13:30 +0000 |
commit | e3f7f7b6cfe355af89d5b8b9581497cc2cd96005 (patch) | |
tree | d56d540afd7745b2ef53040359d9b30304c923cf /portal-gui/rpkigui/myrpki/glue.py | |
parent | 7c2a3ba493d9b966ce685e864389e09783521a2e (diff) |
provide links on the dashboard to export csv files; intended to also be used by rpkidemo
svn path=/portal-gui/rpkigui/myrpki/glue.py; revision=3480
Diffstat (limited to 'portal-gui/rpkigui/myrpki/glue.py')
-rw-r--r-- | portal-gui/rpkigui/myrpki/glue.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/portal-gui/rpkigui/myrpki/glue.py b/portal-gui/rpkigui/myrpki/glue.py index 8fb74812..009acc68 100644 --- a/portal-gui/rpkigui/myrpki/glue.py +++ b/portal-gui/rpkigui/myrpki/glue.py @@ -21,6 +21,7 @@ from __future__ import with_statement import os import os.path import csv +import stat import sys from django.conf import settings @@ -55,11 +56,20 @@ def invoke_rpki(handle, args): print 'invoking', cmd os.system(cmd) -def read_identity(handle): - fname = settings.MYRPKI_DATA_DIR + '/' + handle + '/entitydb/identity.xml' - with open(fname, 'r') as fp: +def read_file_from_handle(handle, fname): + """read a filename relative to the directory for the given resource handle. returns + a tuple of (content, mtime)""" + with open(settings.MYRPKI_DATA_DIR + '/' + handle + '/' + fname, 'r') as fp: data = fp.read() - return data + mtime = os.fstat(fp.fileno())[stat.ST_MTIME] + return data, mtime + +#def read_identity(handle): +# fname = settings.MYRPKI_DATA_DIR + '/' + handle + '/entitydb/identity.xml' +# with open(fname, 'r') as fp: +# data = fp.read() +# return data +read_identity = lambda h: read_file_from_handle(h, 'entitydb/identity.xml')[0] def read_child_response(handle, child): fname = '%s/%s/entitydb/children/%s.xml' % (settings.MYRPKI_DATA_DIR, handle, child) |