-from model import *
-from nodecommon import *
-
-from config import config
-from optparse import OptionParser
-
-parser = OptionParser()
-parser.set_defaults(node=None, fields='state', fromtime=None)
-parser.add_option("", "--node", dest="node", metavar="nodename.edu",
- help="A single node name to add to the nodegroup")
-parser.add_option("", "--fields", dest="fields", metavar="key",
- help="Which record field to extract from all files.")
-parser.add_option("", "--fromtime", dest="fromtime", metavar="YYYY-MM-DD",
- help="Specify a starting date from which to begin the query.")
-config = config(parser)
-config.parse_args()
-
-def datetime_fromstr(str):
- if '-' in str:
- tup = time.strptime(str, "%Y-%m-%d")
- elif '/' in str:
- tup = time.strptime(str, "%m/%d/%Y")
- else:
- tup = time.strptime(str, "%m/%d/%Y")
- return datetime.fromtimestamp(calendar.timegm(tup))
-
-def diff_time(timestamp):
- now = time.time()
- if timestamp == None:
- return "unknown"
- diff = now - timestamp
- # return the number of seconds as a difference from current time.
- t_str = ""
- if diff < 60: # sec in min.
- t = diff
- t_str = "%s sec ago" % t
- elif diff < 60*60: # sec in hour
- t = diff // (60)
- t_str = "%s min ago" % int(t)
- elif diff < 60*60*24: # sec in day
- t = diff // (60*60)
- t_str = "%s hours ago" % int(t)
- elif diff < 60*60*24*7: # sec in week
- t = diff // (60*60*24)
- t_str = "%s days ago" % int(t)
- elif diff < 60*60*24*30: # approx sec in month
- t = diff // (60*60*24*7)
- t_str = "%s weeks ago" % int(t)
- elif diff > 60*60*24*30: # approx sec in month
- t = diff // (60*60*24*7*30)
- t_str = "%s months ago" % int(t)
- return t_str
+from monitor.model import *
+from monitor.common import *
+
+def get_filefromglob(d, str):
+ import os
+ import glob
+ # TODO: This is aweful.
+ path = "archive-pdb"
+ archive = database.SPickle(path)
+ glob_str = "%s*.%s.pkl" % (d.strftime("%Y-%m-%d"), str)
+ os.chdir(path)
+ #print glob_str
+ #file = glob.glob(glob_str)[0]
+ files = glob.glob(glob_str)
+ #print "loading %s" % file
+ os.chdir("..")
+ files_chng = [ file[:-4] for file in files ]
+ return files_chng
+ #fb = archive.load(file[:-4])
+