86 if args[
'csvdump'] !=
None and args[
'database']:
90 if args[
'last_data'] !=
None:
94 if 'field_list' in args
and args[
'field_list']:
97 for i
in range(len(names)):
98 print i,
':\t'+names[i]
102 if args[
'query'] !=
None:
103 datas =
p2data.P2Datas(args[
'database'],args[
'query'],args[
'separator'])
107 if args[
'format'] ==
'csv':
110 if args[
'output'] ==
'-':
113 cvsout = open(args[
'output'],
"w+");
116 datas.getPlotData(
True, cvsout,
';')
118 if args[
'output'] !=
'-':
124 g = tempfile.NamedTemporaryFile(
'w+',-1,
'pyP2gnuplotcommand')
125 rep = datas.getDateTimeFormats()
127 if not (args[
'format'] ==
None or args[
'format'] ==
'gnuplot'):
128 if args[
'format'] ==
'png':
129 gbuff+=
'set terminal png'
130 elif args[
'format'] ==
'svg':
131 gbuff+=
'set terminal svg'
132 elif args[
'format'] ==
'jpg':
133 gbuff+=
'set terminal jpg'
134 if args[
'resolution'] !=
None:
135 gbuff+=
' size '+args[
'resolution']
137 gbuff+=
'set output "'+args[
'output']+
'"\n'
139 gbuff+=
'set terminal wxt\n'
141 if args[
'title'] !=
None:
142 gbuff+=
'set title "'+args[
'title']+
'"\n'
145 gbuff+=
'set xdata time\n'
146 gbuff+=
'set timefmt "'+inFmt+
'"\n'
147 gbuff+=
'set format x "%H:%M:%S"\n'
148 gbuff+=
'set timefmt "'+inFmt+
'"\n'
149 gbuff+=
'set ytics nomirror\n'
150 gbuff+=
'set y2tics nomirror\n'
151 gbuff+=
'set offset graph 0.001, 0.10, 0.20, 0.20\n'
152 gbuff+=
'set autoscale y\n'
153 gbuff+=
'set autoscale y2\n'
156 gbuff += datas.getPlotCommand()
157 logger.debug(
"Writing gnuplot options : "+ gbuff)
161 os.system(
'gnuplot --persist "'+g.name+
'"')
163 if args[
'format'] ==
'gnuplot':
164 raw_input(
'Please press return to continue...\n')
170 print >> sys.stderr,
'Error, no query specified with database'
176 print >> sys.stderr,
'Error, no input specified with -d or -i'