[Python-modules-commits] [python-cs] 01/03: Import python-cs_0.8.3.orig.tar.gz

Vincent Bernat bernat at moszumanska.debian.org
Mon Aug 29 08:26:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

bernat pushed a commit to branch master
in repository python-cs.

commit 1a9c342df8d932cc56a924c6937ab5c8c2d6170f
Author: Vincent Bernat <bernat at debian.org>
Date:   Mon Aug 29 10:22:49 2016 +0200

    Import python-cs_0.8.3.orig.tar.gz
---
 README.rst |  9 +++++++++
 cs.py      | 16 +++++++++++++---
 setup.py   |  2 +-
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst
index a733f6d..726a63f 100644
--- a/README.rst
+++ b/README.rst
@@ -62,6 +62,9 @@ Then::
 The command-line client polls when async results are returned. To disable
 polling, use the ``--async`` flag.
 
+To find the list CloudStack API calls go to
+http://cloudstack.apache.org/api.html
+
 Configuration
 -------------
 
@@ -123,3 +126,9 @@ logic to allow fetching large result sets in one go. This is done with the
 Or in Python::
 
     cs.listVirtualMachines(fetch_list=True)
+
+Links
+-----
+
+* CloudStack API: http://cloudstack.apache.org/api.html
+* Example of use: `Get Started with the exoscale API client <https://www.exoscale.ch/syslog/2016/02/23/get-started-with-the-exoscale-api-client/>`_
diff --git a/cs.py b/cs.py
index 091ed01..862c864 100644
--- a/cs.py
+++ b/cs.py
@@ -223,6 +223,8 @@ def main():
                         help='use POST instead of GET')
     parser.add_argument('--async', action='store_true', default=False,
                         help='do not wait for async result')
+    parser.add_argument('--quiet', '-q', action='store_true', default=False,
+                        help='do not display additional status messages')
     parser.add_argument('command', metavar="COMMAND",
                         help='Cloudstack API command to execute')
 
@@ -251,23 +253,30 @@ def main():
     if options.post:
         config['method'] = 'post'
     cs = CloudStack(**config)
+    ok = True
     try:
         response = getattr(cs, command)(**kwargs)
     except CloudStackException as e:
         response = e.args[2]
-        sys.stderr.write("Cloudstack error:\n")
+        if not options.quiet:
+            sys.stderr.write("Cloudstack error:\n")
+        ok = False
 
     if 'Async' not in command and 'jobid' in response and not options.async:
-        sys.stderr.write("Polling result... ^C to abort\n")
+        if not options.quiet:
+            sys.stderr.write("Polling result... ^C to abort\n")
         while True:
             try:
                 res = cs.queryAsyncJobResult(**response)
                 if res['jobstatus'] != 0:
                     response = res
+                    if res['jobresultcode'] != 0:
+                        ok = False
                     break
                 time.sleep(3)
             except KeyboardInterrupt:
-                sys.stderr.write("Result not ready yet.\n")
+                if not options.quiet:
+                    sys.stderr.write("Result not ready yet.\n")
                 break
 
     data = json.dumps(response, indent=2, sort_keys=True)
@@ -275,6 +284,7 @@ def main():
     if pygments and sys.stdout.isatty():
         data = pygments.highlight(data, JsonLexer(), TerminalFormatter())
     sys.stdout.write(data)
+    sys.exit(int(not ok))
 
 
 if __name__ == '__main__':
diff --git a/setup.py b/setup.py
index cf8785c..2099f98 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ with open('README.rst', 'r') as f:
 
 setup(
     name='cs',
-    version='0.8.2',
+    version='0.8.3',
     url='https://github.com/exoscale/cs',
     license='BSD',
     author=u'Bruno Renié',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-cs.git



More information about the Python-modules-commits mailing list