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

Revision 2158, 1.4 kB (checked in by brian, 1 year ago)

Moved some of the libexec scripts around; perl to attic.

  • 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
9 # Retrieve our logger in case of failure
10 log = getLogger("GIP.timestamp")
11
12 def main():
13     try:
14         # Load up the site configuration
15         cp = config()
16
17         # Get the timestamp in the two formats we wanted
18         epoch = str(time.time())
19         now = time.strftime("%a %b %d %T UTC %Y", time.gmtime())
20
21         # Load up the template for GlueLocationLocalID
22         # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
23         template = getTemplate("GlueCluster", "GlueLocationLocalID")
24
25         # Dictionary of data to fill in for GlueLocationLocalID
26         info = {'locationId':   'TIMESTAMP',
27                 'subClusterId': cp.get('ce', 'name'),
28                 'clusterId':    cp.get('ce', 'name'),
29                 'locationName': 'TIMESTAMP',
30                 'version':      epoch,
31                 'path':         now,
32                }
33
34         # Spit out our template, fill it with the appropriate info.
35         printTemplate(template, info)
36
37     except Exception, e:
38         # Log error, then report it via stderr.
39         log.error(e)
40         sys.stdout = sys.stderr
41         raise
42
43 if __name__ == '__main__':
44     main()
45
Note: See TracBrowser for help on using the browser.