def main(): kw, given, args = parseOpts(sys.argv[1:]) output = kw.get('output', 'graphtool.png') graph = kw.get('graph', 'QualityMap') try: Graph = getattr(graphs, 'Basic' + graph) except: raise print("Unknown graph type: %s" % graph, file=sys.stderr) sys.exit(1) g = Graph() if graph in ['QualityMap', 'Cumulative', 'StackedBar', 'SimpleStackedBar', \ 'StackedLine']: data, metadata = parse_csv_pg(sys.stdin, **kw) elif graph in ['Bar', 'Pie']: data, metadata = parse_csv_p(sys.stdin, **kw) else: print("Unknown graph type: %s" % graph, file=sys.stderr) sys.exit(1) if output == '-': fp = sys.stdout else: fp = open(os.path.expandvars(os.path.expanduser(output)), 'w') for key, val in kw.items(): metadata[key] = val g.run(data, fp, metadata)
def main(): kw, given, args = parseOpts(sys.argv[1:]) output = kw.get('output', 'graphtool.png') graph = kw.get('graph', 'QualityMap') try: Graph = getattr(graphs, 'Basic' + graph) except: raise print >> sys.stderr, "Unknown graph type: %s" % graph sys.exit(1) g = Graph() if graph in ['QualityMap', 'Cumulative', 'StackedBar', 'SimpleStackedBar', \ 'StackedLine']: data, metadata = parse_csv_pg(sys.stdin, **kw) elif graph in ['Bar', 'Pie']: data, metadata = parse_csv_p(sys.stdin, **kw) else: print >> sys.stderr, "Unknown graph type: %s" % graph sys.exit(1) if output == '-': fp = sys.stdout else: fp = open(os.path.expandvars(os.path.expanduser(output)), 'w') for key, val in kw.items(): metadata[key] = val g.run(data, fp, metadata)
#!/usr/bin/env python # TODO bring this back via another package for command line tools from graphtool.tools.commandline_tool import CommandLineTool from graphtool.tools.common import parseOpts import sys if __name__ == '__main__': keywordOpts, passedOpts, givenOpts = parseOpts( sys.argv[1:] ) me = CommandLineTool( **keywordOpts ) me.run()
#!/usr/bin/env python # TODO bring this back via another package for command line tools from graphtool.tools.commandline_tool import CommandLineTool from graphtool.tools.common import parseOpts import sys if __name__ == '__main__': keywordOpts, passedOpts, givenOpts = parseOpts(sys.argv[1:]) me = CommandLineTool(**keywordOpts) me.run()
pirates = ({ 'id': 0, 'name': 'Shoutin Clive Morgan' }, { 'id': 1, 'name': 'Screaming Sam'}, { 'id': 2, 'name': 'Bluebeard'}, { 'id': 3, 'name': 'Hairy Jock Smythe' }, { 'id': 4, 'name': 'Pele' }, { 'id': 5, 'name': 'Leather-face John Blackbeard' }, { 'id': 6, 'name': 'Sir William Defoe' }) insert = '''insert into pirate (id, name) values (:id, :name)''' for pirate in pirates: cur.execute(insert, pirate) insert = '''insert into treasure (timebin, pirate, gold, jewels) values (:timebin, :pirate, :gold, :jewels)''' t_end = time.time() t = t_end - 365*24*3600 while t < t_end: for pirate in pirates: gold = 100 * random.random() jewels = int(math.floor(100 * random.random())) binds = { 'timebin': t, 'pirate': pirate['id'], 'gold': gold, 'jewels': jewels } print "At %s pirate %s got %s gold and %s jewels" % (t, pirate, gold, jewels) cur.execute(insert, binds) t += 24*3600 con.commit() if __name__ == '__main__': kw, passed, given = parseOpts(sys.argv[1:])