def main(argv=None): if argv is None: argv = sys.argv try: args = parse_args(argv) f = None if args.file: f = open(args.file, "rt") else: f = sys.stdin xml = "" data = f.readline() while data: xml = "%s%s" % (xml, data) data = f.readline() config = PressgangConfig("%s/.pressgangcli.conf" % os.path.expanduser("~")) topic_server = TopicServer(config.get_location()) topic = Topic(topic_server, args.TOPIC).set_xml(xml) # Note that failure is considered non-fatal, just return the response # code for the calling script/user to deal with. if topic.status_code == 200: print "Topic %s, revision %s saved." % (args.TOPIC, topic.json["revision"]) else: print "HTTP status %s." % str(topic.status_code) return topic.status_code except Usage, err: print >>sys.stderr, err.msg print >>sys.stderr, ("For help and usage information use the --help " + "argument.") return 2
def main(argv=None): if argv is None: argv = sys.argv try: args = parse_args(argv) config = PressgangConfig("%s/.pressgangcli.conf" % os.path.expanduser("~")) topic_server = TopicServer(config.get_location()) topic = Topic(topic_server, args.TOPIC) output = None if args.json: output = topic.get_json(revision=int(args.revision)) elif args.html: output = topic.get_html(revision=int(args.revision)) else: output = topic.get_xml(revision=int(args.revision)) if output is None: if args.revision != 0: raise Error("No such topic/revision combination exists.") else: raise Error("No such topic exists.") else: print output return 0 except Usage, err: print >>sys.stderr, err.msg print >>sys.stderr, ("For help and usage information use the --help " + "argument.") return 2