Coverage for python/lsst/sims/downtimeModel/scheduled_downtime.py : 36%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Handle the scheduled downtime information.
This class handles the scheduled downtime information. """
"""Initialize the class. """ self.downtime_file = None self.downtimes = []
"""Return the top downtime. """ try: return self.downtimes.pop(0) except IndexError: return None
"""Return number of scheduled downtimes.
Returns ------- int """ return len(self.downtimes)
"""Configure the set of scheduled downtimes.
This function gets the appropriate database file and creates the set of scheduled downtimes from it. The default behavior is to use the module stored database. However, an alternate database file can be provided. The alternate database file needs to have a table called *Downtime* with the following columns:
night int : The night (from start of simulation) the downtime occurs. duration int : The duration (units=days) of the downtime. activity str : A description of the activity involved.
Parameters ---------- downtime_file : str, optional A full path to an alternate scheduled downtime database file. """
if downtime_file != "": self.downtime_file = downtime_file else: self.downtime_file = self.SCHEDULED_DOWNTIME_DB
with sqlite3.connect(self.downtime_file) as conn: cur = conn.cursor() cur.execute("select * from Downtime;") for row in cur: self.downtimes.append((row[0], row[1], row[2])) cur.close()
return self.downtimes[index] |