refresh = True if args: if len(args) != 1: usage("incorrect number of arguments") format = args[0] else: format = None apikey = os.getenv('HUB_APIKEY', None) if not apikey: fatal("HUB_APIKEY not specified in environment") hub = Hub(apikey) servers = hub.servers.get(refresh_cache=refresh) if servers: servers = sorted(servers, key=lambda server: server.status) if format: format = Formatter(format) for server in servers: print format(server) else: print fmt_server_header() for server in servers: print fmt_server(server) if __name__ == "__main__": main()
auto_unregister = True for opt, val in opts: if opt in ('-h', '--help'): usage() if opt == "--disable-unregister": auto_unregister = False if len(args) != 1: usage("incorrect number of arguments") instance_id = args[0] apikey = os.getenv('HUB_APIKEY', None) if not apikey: fatal("HUB_APIKEY not specified in environment") hub = Hub(apikey) try: server = hub.servers.get(instance_id)[0] server.destroy(auto_unregister=auto_unregister) except hub.Error, e: fatal(e.description) print fmt_server_header() print fmt_server(server) if __name__ == "__main__": main()