示例#1
0
def ccsTrendingPlots(quantities, outfile_suffix, credentials_file,
                     section='mysql', npts=540, marker='ko',
                     markersize=3):
    """
    Create CCS trending plots.  Currently, the last npts(=540) entries
    in the trending db are plotted.  It's probably better to make a
    explicitly time-based query instead.
    """
    db = DbInterface(credentials_file, section)
    query = lambda x, npts=npts : "select rawdata.tstampmills, rawdata.doubleData from rawdata join datadesc on rawdata.descr_id=datadesc.id where datadesc.name='%s' limit %i" % (x, npts)
    unpack = lambda cursor : zip(*[x for x in cursor])
    for quantity in quantities:
        data = db.apply(query(quantity), cursorFunc=unpack)
        times, hfmt = convert_unix_time(data[0])
        fig = pylab.figure()
        ax = fig.add_subplot(111)
        ax.plot(times, data[1], marker, markersize=markersize)
        ax.xaxis.set_major_formatter(hfmt)
        pylab.xticks(fontsize=8)
        fig.autofmt_xdate()
        pylab.xlabel('Time')
        pylab.ylabel(quantity)
        pylab.savefig('%s_%s.png'%(quantity.replace('/', '_'), outfile_suffix))
示例#2
0
parser.add_option("-D", "--download", action="store", dest="dlfolder", help="The download folder the patches go in")
(opts, args) = parser.parse_args()

mandatories = ["host", "user", "passwd", "dbname", "patchfolder", "dlfolder"]

for m in mandatories:
    if not opts.__dict__[m]:
        print "Mandatory option missing\n"
        parser.print_help()
        exit(-1)

patchComsFile = os.path.join(opts.patchfolder, "misc", "patchComs.pd")
dirList = os.listdir(opts.patchfolder)

try:
    dbi = DbInterface(opts.user, opts.passwd, opts.dbname, opts.host)
except MySQLdb.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit(1)


def CreateTar(patchname, patchDir, patchComsFile, downloadFolder):

    fileName = patchname.replace(" ", "-")
    tempdir = os.path.join(os.getcwd(), fileName)

    patchComsDest = os.path.join(tempdir, "patchComs.pd")

    shutil.copytree(patchDir, tempdir)
    shutil.copyfile(patchComsFile, patchComsDest)