Commit f5e23695 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

fixup! Add support for Python 3

parent 1c8269b2
......@@ -22,7 +22,7 @@ def stop(key, secret, service, node_uuid, ssh_key=None):
ssh = getSSHConnection(driver, public_ip, ssh_key)
print('Stopping instance...')
stdin, stdout, stderr = ssh.exec_command('halt')
except SSHException, e:
except SSHException as e:
print('unable to stop')
raise e
error_log = stderr.read()
......
......@@ -59,7 +59,7 @@ def install(key, secret, service, image_id, size_id, location_id,
keypair = driver.ex_create_keypair(unique_keyname)
ssh_key = keypair['keyMaterial']
argument_list['ex_keyname'] = unique_keyname
except Exception, e:
except Exception as e:
# XX-Cedric : what to do here?
if e.args[0].find("InvalidKeyPair.Duplicate") == -1:
# XXX-Cedric : our unique key was not so unique...Do something
......@@ -82,7 +82,7 @@ def install(key, secret, service, image_id, size_id, location_id,
if 'EC2' in service:
try:
driver.ex_create_security_group(security_group, security_group)
except Exception, e:
except Exception as e:
if e.args[0].find("InvalidPermission.Duplicate") == -1:
pass #It's okay, don't worry.
driver.ex_authorize_security_group_permissive(security_group)
......
# -*- coding: utf-8 -*-
from __future__ import print_function
from six.moves import configparser
import argparse
from six.moves import dbm_gnu as gdbm
......@@ -27,7 +28,7 @@ def main():
if args.pid is not None:
pid_filename = args.pid[0]
if os.path.exists(pid_filename):
print >> sys.stderr, "Already running"
print("Already running", file=sys.stderr)
return 127
with open(pid_filename, 'w') as pid_file:
pid_file.write(str(os.getpid()))
......
......@@ -30,9 +30,9 @@ class RunPromise(GenericPromise):
# self.logger.info("port connection OK")
try:
socket.create_connection(addr).close()
except (socket.herror, socket.gaierror), e:
except (socket.herror, socket.gaierror) as e:
self.logger.error("ERROR hostname/port ({}) is not correct: {}".format(addr, e))
except (socket.error, socket.timeout), e:
except (socket.error, socket.timeout) as e:
self.logger.error("ERROR while connecting to {}: {}".format(addr, e))
else:
self.logger.info("port connection OK ({})".format(addr))
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import csv
import datetime
......@@ -79,7 +80,7 @@ def main():
saveStatus('STARTED')
if args.max_run <= 0:
print "--max-run argument takes a strictely positive number as argument"
print("--max-run argument takes a strictely positive number as argument")
sys.exit(-1)
while args.max_run > 0:
......@@ -108,7 +109,7 @@ def main():
content.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
))
print content
print(content)
# Write feed safely
error_message = ""
......@@ -128,7 +129,7 @@ def main():
'slapos:%s' % uuid.uuid4(),
])
os.rename(temp_file, args.logfile[0])
except Exception, e:
except Exception as e:
error_message = "ERROR ON WRITING FEED - %s" % str(e)
finally:
try:
......@@ -143,7 +144,7 @@ def main():
if exit_code != 0:
sys.exit(exit_code)
print 'Fetching %s feed...' % args.feed_url[0]
print('Fetching %s feed...' % args.feed_url[0])
feed = urllib2.urlopen(args.feed_url[0])
body = feed.read()
......
......@@ -26,6 +26,7 @@
#
##############################################################################
from __future__ import print_function
import argparse
import json
import importlib
......@@ -228,7 +229,7 @@ def runResiliencyTest():
"""
error_message_set, exit_status = ScalabilityLauncher().run()
for error_message in error_message_set:
print >>sys.stderr, 'ERROR: %s' % error_message
print('ERROR: %s' % error_message, file=sys.stderr)
sys.exit(exit_status)
......
......@@ -167,7 +167,7 @@ class GitlabTestSuite(SlaprunnerTestSuite):
while loop < 3:
try:
self._connectToGitlab(url=self.backend_url)
except Exception, e:
except Exception as e:
if loop == 2:
raise
self.logger.warning(str(e))
......
......@@ -144,7 +144,7 @@ def serve(config):
result = cloneRepo(repo_url, repository_path)
if branch_name:
switchBranch(repository_path, branch_name)
except GitCommandError, e:
except GitCommandError as e:
app.logger.warning('Error while cloning default repository: %s' % str(e))
traceback.print_exc()
# Start slapproxy here when runner is starting
......
from __future__ import print_function
import ZODB.FileStorage
import ZODB.serialize
import argparse
......@@ -16,24 +17,24 @@ def run():
point = now - (3600 * 24 * args.days)
print 'Now is %s' % time.asctime(time.localtime(now))
print 'Will pack until %s' % time.asctime(time.localtime(point))
print('Now is %s' % time.asctime(time.localtime(now)))
print('Will pack until %s' % time.asctime(time.localtime(point)))
failures = 0
for f in args.files:
b = time.time()
print 'Trying to pack %r' % f
print('Trying to pack %r' % f)
try:
pack(point, f)
except Exception:
print 'Failed to pack %r:' % f
print('Failed to pack %r:' % f)
traceback.print_exc()
failures += 1
print 'Finished %s in %.3fs' % (f, time.time() - b)
print('Finished %s in %.3fs' % (f, time.time() - b))
if failures:
print 'Failed files: %s' % failures
print('Failed files: %s' % failures)
return failures
else:
print 'All files sucessfully packed.'
print('All files sucessfully packed.')
return 0
def pack(point, f):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment