Skip to content

Commit

Permalink
Make scripts run on python2 and python3 (apache#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahmed-se authored and srkukarni committed Jan 11, 2019
1 parent 46f00fe commit 69ab1f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docker/pulsar/scripts/apply-config-from-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import os, sys

if len(sys.argv) < 2:
print 'Usage: %s' % (sys.argv[0])
print('Usage: %s' % (sys.argv[0]))
sys.exit(1)

# Always apply env config to env scripts as well
Expand All @@ -52,7 +52,7 @@
for k in sorted(os.environ.keys()):
v = os.environ[k]
if k in keys:
print '[%s] Applying config %s = %s' % (conf_filename, k, v)
print('[%s] Applying config %s = %s' % (conf_filename, k, v))
idx = keys[k]
lines[idx] = '%s=%s\n' % (k, v)

Expand Down
2 changes: 1 addition & 1 deletion docker/pulsar/scripts/gen-yml-from-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
PF_ENV_PREFIX = 'PF_'

if len(sys.argv) < 2:
print 'Usage: %s' % (sys.argv[0])
print('Usage: %s' % (sys.argv[0]))
sys.exit(1)

conf_files = sys.argv[1:]
Expand Down
24 changes: 12 additions & 12 deletions docker/pulsar/scripts/watch-znode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
logging.getLogger('kazoo.client').addHandler(logging.StreamHandler())

def usage():
print >> sys.stderr, "\n%s -z <zookeeper> -p <path> [-w|-c|-e]" % (sys.argv[0])
print >> sys.stderr, "\nWait for, or create znode"
print >> sys.stderr, "\n-z Specify zookeeper connect string"
print >> sys.stderr, "\n-p Znode path to watch or create"
print >> sys.stderr, "\n-w Watch for path creation"
print >> sys.stderr, "\n-c Create path"
print >> sys.stderr, "\n-e Check if znode exists"
print("\n%s -z <zookeeper> -p <path> [-w|-c|-e]" % (sys.argv[0]), file=sys.stderr)
print("\nWait for, or create znode", file=sys.stderr)
print("\n-z Specify zookeeper connect string", file=sys.stderr)
print("\n-p Znode path to watch or create", file=sys.stderr)
print("\n-w Watch for path creation", file=sys.stderr)
print("\n-c Create path", file=sys.stderr)
print("\n-e Check if znode exists", file=sys.stderr)

try:
opts, args = getopt.getopt(sys.argv[1:], "z:p:cweh")
except getopt.GetoptError as err:
print >> sys.stderr, str(err)
print(str(err), file=sys.stderr)
usage()
sys.exit(2)

Expand Down Expand Up @@ -67,17 +67,17 @@ def usage():
sys.exit(2)

if not zookeeper:
print >> sys.stderr, "Zookeeper must be specified"
print("Zookeeper must be specified", file=sys.stderr)
usage()
sys.exit(3)

if not znode:
print >> sys.stderr, "Znode must be specified"
print("Znode must be specified", file=sys.stderr)
usage()
sys.exit(4)

if (not watch and not create and not exists):
print >> sys.stderr, "Exactly one of watch (-w), create (-c) or exists (-e) must be specified"
print("Exactly one of watch (-w), create (-c) or exists (-e) must be specified", file=sys.stderr)
usage()
sys.exit(5)

Expand All @@ -93,7 +93,7 @@ def usage():
sys.exit(0)
elif watch:
while not zk.exists(znode):
print "Waiting for %s" % znode
print("Waiting for %s" % znode)
time.sleep(1)
sys.exit(0)
elif exists:
Expand Down

0 comments on commit 69ab1f5

Please sign in to comment.