%
import time, rfc822
later = time.time() + (60 * 2) # 2 minutes expiry
now = time.time()
req.headers_out['Expires'] = rfc822.formatdate(later)
req.headers_out['Last-modified'] = rfc822.formatdate(now)
domainId = args.domainId
repositoryId = args.repositoryId
repositoryGroupId = args.repositoryGroupId
import os
from merescoharvester.harvester.repositorystatus import RepositoryStatus
logDir = req.get_options()['logDir']
def writeStatus(repositoryId, repositoryGroupId):
rs = RepositoryStatus()
statsfile = os.path.join(logDir, domainId, repositoryId + '.events')
if os.path.isfile(statsfile):
try:
f = open(statsfile)
%><%
rs.innerXml(f, req)
req.write("")
finally:
f.close()
#
exists = True
if repositoryId:
exists = os.path.isfile(req.document_root() + '/' + domainId + '.' + repositoryId + '.repository')
elif repositoryGroupId:
exists = os.path.isfile(req.document_root() + '/' + domainId + '.' + repositoryGroupId + '.repositoryGroup')
if not exists:
include('/saharageterror?errorCode=idDoesNotExist')
else:
type('text/xml; charset=utf-8')
%>
<%
include('/saharagetTime')
%>
GetStatus
<% escape_xml(domainId) %><%
if repositoryId:
%>
<% escape_xml(repositoryId) %><%
elif repositoryGroupId:
%>
<% escape_xml(repositoryGroupId) %><%
#
%>
<%
#
if not repositoryId and repositoryGroupId:
allGroupIds = [ repositoryGroupId ]
else:
allGroupIds = asxml(url('/' + domainId + '.domain')).domain.repositoryGroupId
for groupId in allGroupIds:
repositories = asxml(url('/' + domainId + '.' + groupId + '.repositoryGroup')).repositoryGroup.repositoryId
for repId in repositories:
if not repositoryId or repositoryId == repId:
writeStatus(repId, groupId)
#
%>