Skip to content
Snippets Groups Projects
Commit 33226f44 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #2669: Allow generating obs ids from the command line

parent 6d7b3f66
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
from util.Hosts import ropen
from Locations import Locations
# do not modify any files if DRYRUN is True
DRYRUN = False
......@@ -10,16 +9,13 @@ DRYRUN = False
The following files exist to aid the creation of observation IDs:
nextMSnumber contains the next free observation ID (integer)
MSList contains a list of existing measurements and their start time [deprecated: not updated anymore]
Their locations are stored in the Locations dictionary.
"""
class ObservationID:
def __init__( self ):
self.obsid = 0
def generateID( self ):
def generateID( self, nextMSnumber = "/globalhome/lofarsystem/log/nextMSNumber" ):
""" Returns an unique observation ID to use and reserve it. """
if self.obsid:
......@@ -27,16 +23,21 @@ class ObservationID:
return self.obsid
# read the next ms number
f = ropen( Locations.files["nextmsnumber"], "r" )
f = ropen( nextMSnumber, "r" )
obsid = int(f.readline())
f.close()
if not DRYRUN:
# increment it and save
f = ropen( Locations.files["nextmsnumber"], "w" )
f = ropen( nextMSnumber, "w" )
print >>f, "%s" % (obsid+1)
f.close()
self.obsid = obsid
return self.obsid
if __name__ == "__main__":
obsID = ObservationID()
print obsID.generateID()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment