root/gip/trunk/gip/providers/osg_info_timestamp.py

Revision 2820, 1.5 kB (checked in by burt, 9 months ago)

First stab at fixing Trac ticket #18

  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2
3 import sys, time, os
4
5 # Make sure the gip_common libraries are in our path
6 sys.path.append(os.path.expandvars("$GIP_LOCATION/lib/python"))
7 from gip_common import config, getTemplate, getLogger, printTemplate
8 from gip_cluster import getSubClusterIDs, getClusterID
9
10 # Retrieve our logger in case of failure
11 log = getLogger("GIP.timestamp")
12
13 def main():
14     try:
15         # Load up the site configuration
16         cp = config()
17
18         # Get the timestamp in the two formats we wanted
19         epoch = str(time.time())
20         now = time.strftime("%a %b %d %T UTC %Y", time.gmtime())
21
22         # Load up the template for GlueLocationLocalID
23         # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
24         template = getTemplate("GlueCluster", "GlueLocationLocalID")
25         cluster_id = getClusterID(cp)
26         for subClusterId in getSubClusterIDs(cp):
27             # Dictionary of data to fill in for GlueLocationLocalID
28             info = {'locationId':   'TIMESTAMP',
29                     'subClusterId': subClusterId,
30                     'clusterId':    cluster_id,
31                     'locationName': 'TIMESTAMP',
32                     'version':      epoch,
33                     'path':         now,
34                     }
35
36             # Spit out our template, fill it with the appropriate info.
37             printTemplate(template, info)
38
39     except Exception, e:
40         # Log error, then report it via stderr.
41         log.error(e)
42         sys.stdout = sys.stderr
43         raise
44
45 if __name__ == '__main__':
46     main()
47
Note: See TracBrowser for help on using the browser.