xmlrpc_test.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. ############################################################################
  3. # tools/xmlrpc_test.py
  4. #
  5. # Copyright (C) 2012 Max Holtzberg. All rights reserved.
  6. # Author: Max Holtzberg <mh@uvc.de>
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions
  10. # are met:
  11. #
  12. # 1. Redistributions of source code must retain the above copyright
  13. # notice, this list of conditions and the following disclaimer.
  14. # 2. Redistributions in binary form must reproduce the above copyright
  15. # notice, this list of conditions and the following disclaimer in
  16. # the documentation and/or other materials provided with the
  17. # distribution.
  18. # 3. Neither the name NuttX nor the names of its contributors may be
  19. # used to endorse or promote products derived from this software
  20. # without specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. # POSSIBILITY OF SUCH DAMAGE.
  34. #
  35. ############################################################################
  36. import sys
  37. import xmlrpclib
  38. if __name__ == '__main__':
  39. if len(sys.argv) != 2:
  40. print 'Usage: %s <ip address>' % sys.argv[0]
  41. quit(1)
  42. server_url = 'http://%s/device' % sys.argv[1]
  43. server = xmlrpclib.ServerProxy(server_url)
  44. result = server.get_device_stats("username", "password", 0)
  45. print result