Пример #1
0
 def month_resolver(self, start_mth, start_yr, end_mth, end_yr, dbname_template):
     """Month list
     """
     if self.include_times:
         months = {}
     else:
         months = []
     vol_month = start_mth
     vol_year = start_yr
     while vol_year <= end_yr or (vol_year == end_yr and vol_month <= end_mth):
         voltime = antstock.str2epoch("%d/1/%d" % (vol_month, vol_year))
         if vol_month < 12:
             vol_month += 1
         else:
             vol_month = 1
             vol_year += 1
         volendtime = antstock.str2epoch("%d/1/%d" % (vol_month,vol_year)) - 1
         dbname = antstock.epoch2str(int(voltime), dbname_template)
         if os.path.exists(dbname) and os.path.isfile(dbname):
             if self.include_times:
                 months[dbname] = (voltime,volendtime)
             else:
                 months.append(dbname)
         else:
             if not legacy:
                 antelog.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
             else:
                 antstock.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
     return months
Пример #2
0
 def __init__(self, path, clustername, include_times=False):
     """Initialize class
     """
     self.path = path
     self.clustername = clustername
     self.include_times = include_times
     self.errstr = antstock.epoch2str(antstock.now(), "%g %H:%M:%S")
     self.base = os.path.basename(__file__)
Пример #3
0
 def year_resolver(self, start_yr, end_yr, dbname_template):
     """Year list
     """
     if self.include_times:
         years = {}
     else:
         years = []
     for y in range(start_yr, end_yr + 1):
         voltime = antstock.str2epoch("1/1/%s 00:00:00" % y)
         volendtime = antstock.str2epoch("12/31/%s 23:59:59" % y)
         dbname = antstock.epoch2str(voltime, dbname_template)
         if os.path.exists(dbname) and os.path.isfile(dbname):
             if self.include_times:
                 years[dbname] = (voltime,volendtime)
             else:
                 years.append(dbname)
         else:
             if not legacy:
                 antelog.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
             else:
                 antstock.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
     return years
Пример #4
0
 def day_resolver(self, start_dy, end_dy, dbname_template):
     """Day list
     """
     if self.include_times:
         days = {}
     else:
         days = []
     while start_dy <= end_dy:
         voltime = antstock.epoch(start_day)
         volendtime = voltime + 86399 # one second less than a full day
         dbname = antstock.epoch2str(voltime, dbname_template)
         if os.path.exists(dbname) and os.path.isfile(dbname):
             if self.include_times:
                 days[dbname] = (voltime, volendtime)
             else:
                 days.append(dbname)
         else:
             if not legacy:
                 antelog.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
             else:
                 antstock.elog_notify("%s %s *notify*: Dbpath '%s' does not exist." % (self.errstr, self.base, dbname))
         start_dy = yearday((antstock.epoch(start_dy) + 86400))
     return days
Пример #5
0
                antelog.elog_die("%s %s *die*: Zero records for the clustername '%s'." % (self.errstr, self.base, self.clustername))
            else:
                antstock.elog_die("%s %s *die*: Zero records for the clustername '%s'." % (self.errstr, self.base, self.clustername))

        db.sort('time')

        for i in range(db.query('dbRECORD_COUNT')):
            db[3] = i
            dbname_template = db.extfile()
            volumes, time, endtime = db.getv('volumes', 'time', 'endtime')

            if endtime == null_endtime:
                endtime = antstock.now()

            start_day = int(antstock.yearday(time))
            start_month = int(antstock.epoch2str(time, '%L'))
            start_year = int(antstock.epoch2str(time, '%Y'))
            end_day = int(antstock.yearday(endtime))
            end_month = int(antstock.epoch2str(endtime, '%L'))
            end_year = int(antstock.epoch2str(endtime, '%Y'))

            if volumes == 'single':
                if self.include_times:
                    namelist[dbname_template] = (time, endtime)
                else:
                    namelist = dbname_template ;

            elif volumes == 'year':
                namelist = self.year_resolver(start_year, end_year, dbname_template)

            elif volumes == 'month':