Commit 2fcd323b authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

fixup! Add support for Python 3

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