Add a switch to all the tests to toggle between Python and GO CLI version.
Fixed use of static python/go CLI switch; replaced with instance variable. Add missing wsk properties overrides in one test. Fix singleton object methods to accept required switch as argument. Add exemption for go cli link.
diff --git a/tools/cli/wsk b/tools/cli/wsk
index 328ddd9..00ddca8 100755
--- a/tools/cli/wsk
+++ b/tools/cli/wsk
@@ -67,7 +67,7 @@
if (args.verbose):
print props
if apihost is None and (args.cmd != 'property' or args.cmd == 'property' and args.subcmd != 'set'):
- print 'error: API host is not set. Set it with "wsk property set --apihost <host>".'
+ print >> sys.stderr, 'error: API host is not set. Set it with "wsk property set --apihost <host>".'
return 2
exitCode = {
@@ -164,7 +164,7 @@
else:
auth = userprops.get('AUTH')
if auth is None:
- print 'error: cannot set namespace without an authentication key'
+ print >> sys.stderr, 'error: cannot set namespace without an authentication key'
return 1
res = request('GET', url, auth=auth, verbose=args.verbose)
namespaces = None
@@ -183,7 +183,7 @@
wskprop.updateProps('NAMESPACE', '%s' % choice, propsLocation)
print 'ok: namespace set to %s' % choice
return 0
- print 'error: you are either not entitled to a namespace or you made an invalid choice'
+ print >> sys.stderr, 'error: you are either not entitled to a namespace or you made an invalid choice'
return 1
else:
return responseError(res)
diff --git a/tools/cli/wskaction.py b/tools/cli/wskaction.py
index 78881de..f9e9306 100644
--- a/tools/cli/wskaction.py
+++ b/tools/cli/wskaction.py
@@ -14,6 +14,7 @@
# limitations under the License.
#
+import sys
import os
import json
import base64
@@ -102,9 +103,9 @@
return self.put(args, props, update, json.dumps(payload))
else:
if not args.copy:
- print 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact
+ print >> sys.stderr, 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact
else:
- print 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact
+ print >> sys.stderr, 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact
return 2
def invoke(self, args, props):
diff --git a/tools/cli/wskadmin b/tools/cli/wskadmin
index 2750c41..d678c73 100755
--- a/tools/cli/wskadmin
+++ b/tools/cli/wskadmin
@@ -165,7 +165,7 @@
print 'authorization id is not a valid UUID'
return 2
- key = parts(1)
+ key = parts[1]
if len(key) < 64:
print 'authorization key must be at least 64 characters long'
return 2
diff --git a/tools/cli/wskutil.py b/tools/cli/wskutil.py
index 88093d5..ff7b961 100644
--- a/tools/cli/wskutil.py
+++ b/tools/cli/wskutil.py
@@ -103,31 +103,31 @@
def responseError(res, prefix = 'error:', flatten = True):
if prefix:
- print prefix,
+ print >> sys.stderr, prefix,
response = None
try:
response = res.read()
result = json.loads(response)
if 'error' in result and 'code' in result:
- print '%s (code %s)' % (result['error'], result['code'])
+ print >> sys.stderr, '%s (code %s)' % (result['error'], result['code'])
elif 'error' in result and flatten:
- print result['error']
+ print >> sys.stderr, result['error']
else:
- print getPrettyJson(result)
+ print >> sys.stderr, getPrettyJson(result)
except:
if res.status == 502:
- print 'connection failed or timed out'
+ print >> sys.stderr, 'connection failed or timed out'
elif isinstance(res, collections.Iterable):
if 'read' in res:
- print res.read()
+ print >> sys.stderr, res.read()
elif 'error' in res:
- print res['error']
+ print >> sys.stderr, res['error']
else:
- print 'unrecognized failure'
+ print >> sys.stderr, 'unrecognized failure'
elif response is not None:
- print response
+ print >> sys.stderr, response
else:
- print 'unrecognized failure'
+ print >> sys.stderr, 'unrecognized failure'
return res.status
# creates [ { key: "key name", value: "the value" }* ] from annotations.