Skip to content

Commit

Permalink
Merge pull request #645 from nvgoldin/backport_super
Browse files Browse the repository at this point in the history
Backport Python3 super constructor to the codebase
  • Loading branch information
ovirt-infra authored Jul 25, 2017
2 parents 21054a7 + ef78447 commit ac55bb3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
9 changes: 4 additions & 5 deletions lago/export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from future.builtins import super
from abc import ABCMeta, abstractmethod
import logging
import functools
Expand Down Expand Up @@ -154,8 +155,7 @@ class TemplateExportManager(DiskExportManager):
"""

def __init__(self, dst, disk_type, disk, do_compress, *args, **kwargs):
super(TemplateExportManager,
self).__init__(dst, disk_type, disk, do_compress)
super().__init__(dst, disk_type, disk, do_compress)
self.standalone = kwargs['standalone']
self.src_qemu_info = utils.get_qemu_info(self.src, backing_chain=True)

Expand Down Expand Up @@ -204,7 +204,7 @@ def rebase(self):
)

def update_lago_metadata(self):
super(TemplateExportManager, self).update_lago_metadata()
super().update_lago_metadata()

if self.standalone:
self.exported_metadata['base'] = 'None'
Expand Down Expand Up @@ -241,8 +241,7 @@ class FileExportManager(DiskExportManager):
"""

def __init__(self, dst, disk_type, disk, do_compress, *args, **kwargs):
super(FileExportManager,
self).__init__(dst, disk_type, disk, do_compress)
super().__init__(dst, disk_type, disk, do_compress)

def export(self):
"""
Expand Down
11 changes: 6 additions & 5 deletions lago/log_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2015 Red Hat, Inc.
# Copyright 2015-2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,6 +20,7 @@
"""
This module defines the special logging tools that lago uses
"""
from future.builtins import super
import logging
import logging.config
import os
Expand Down Expand Up @@ -110,7 +111,7 @@ def format(self, record):
else:
color = self.DEFAULT

message = super(ColorFormatter, self).format(record)
message = super().format(record)
if record.args:
try:
message = message % record.args
Expand Down Expand Up @@ -224,7 +225,7 @@ def __init__(
level=logging.NOTSET,
formatter=ColorFormatter,
):
super(TaskHandler, self).__init__()
super().__init__()
self.formatter = formatter
self.initial_depth = initial_depth
self.tasks_by_thread = {}
Expand Down Expand Up @@ -521,8 +522,8 @@ def pretty_emit(self, record, is_header=False, task_level=None):
' ' * (task_level - 1) + extra_prefix + str(record.msg)
)

super(TaskHandler, self).emit(record)
super(TaskHandler, self).flush()
super().emit(record)
super().flush()

def emit(self, record):
"""
Expand Down
6 changes: 3 additions & 3 deletions lago/providers/libvirt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# Refer to the README and COPYING files for full details of the license
#

from future.builtins import super
from collections import defaultdict
import functools
import logging
Expand Down Expand Up @@ -301,11 +301,11 @@ def start(self):

brctl.create(self._libvirt_name())
try:
super(BridgeNetwork, self).start()
super().start()
except:
brctl.destroy(self._libvirt_name())

def stop(self):
super(BridgeNetwork, self).stop()
super().stop()
if brctl.exists(self._libvirt_name()):
brctl.destroy(self._libvirt_name())
13 changes: 7 additions & 6 deletions lago/providers/libvirt/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#

from future.builtins import super
import functools
import logging
import os
Expand Down Expand Up @@ -51,7 +52,7 @@

class LocalLibvirtVMProvider(vm_plugin.VMProviderPlugin):
def __init__(self, vm):
super(LocalLibvirtVMProvider, self).__init__(vm)
super().__init__(vm)
self._has_guestfs = 'lago.guestfs_tools' in sys.modules
libvirt_url = config.get('libvirt_url')
self.libvirt_con = libvirt_utils.get_libvirt_connection(
Expand All @@ -75,7 +76,7 @@ def __del__(self):
self.libvirt_con.close()

def start(self):
super(LocalLibvirtVMProvider, self).start()
super().start()
if not self.defined():
# the wait_suspend method is a work around for:
# https://bugzilla.redhat.com/show_bug.cgi?id=1411025
Expand Down Expand Up @@ -155,7 +156,7 @@ def _createXML(self, dom_xml, flags=0):
return dom

def stop(self):
super(LocalLibvirtVMProvider, self).stop()
super().stop()
if self.defined():
self.vm._ssh_client = None
with LogTask('Destroying VM %s' % self.vm.name()):
Expand All @@ -164,7 +165,7 @@ def stop(self):
).destroy()

def shutdown(self, *args, **kwargs):
super(LocalLibvirtVMProvider, self).shutdown(*args, **kwargs)
super().shutdown(*args, **kwargs)

self._shutdown(
libvirt_cmd=libvirt.virDomain.shutdown,
Expand All @@ -182,7 +183,7 @@ def shutdown(self, *args, **kwargs):
)

def reboot(self, *args, **kwargs):
super(LocalLibvirtVMProvider, self).reboot(*args, **kwargs)
super().reboot(*args, **kwargs)

self._shutdown(
libvirt_cmd=libvirt.virDomain.reboot,
Expand Down Expand Up @@ -336,7 +337,7 @@ def extract_paths(self, paths, ignore_nopath):

try:

super(LocalLibvirtVMProvider, self).extract_paths(
super().extract_paths(
paths=paths,
ignore_nopath=ignore_nopath,
)
Expand Down
3 changes: 2 additions & 1 deletion lago/sdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import print_function
from future.builtins import super
from lago import cmd
from lago.config import config as lago_config
from lago.lago_ansible import LagoAnsible
Expand Down Expand Up @@ -117,7 +118,7 @@ def __init__(self, workdir, prefix):

def __getattr__(self, name):
try:
attr = super(SDK, self).__getattr__(name)
attr = super().__getattr__(name)
except AttributeError:
attr = getattr(self._pprefix, name)
return attr
Expand Down
14 changes: 8 additions & 6 deletions lago/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#
# Refer to the README and COPYING files for full details of the license
#

from future.builtins import super
from lago.plugins.service import (
ServicePlugin,
ServiceState,
Expand All @@ -27,11 +29,11 @@ class SystemdService(ServicePlugin):
BIN_PATH = '/usr/bin/systemctl'

def _request_start(self):
super(SystemdService, self)._request_start()
super()._request_start()
return self._vm.ssh([self.BIN_PATH, 'start', self._name])

def _request_stop(self):
super(SystemdService, self)._request_stop()
super()._request_stop()
return self._vm.ssh([self.BIN_PATH, 'stop', self._name])

def state(self):
Expand All @@ -52,11 +54,11 @@ class SysVInitService(ServicePlugin):
BIN_PATH = '/sbin/service'

def _request_start(self):
super(SysVInitService, self)._request_start()
super()._request_start()
return self._vm.ssh([self.BIN_PATH, self._name, 'start'])

def _request_stop(self):
super(SysVInitService, self)._request_stop()
super()._request_stop()
return self._vm.ssh([self.BIN_PATH, self._name, 'stop'])

def state(self):
Expand All @@ -76,7 +78,7 @@ class SystemdContainerService(ServicePlugin):
HOST_BIN_PATH = '/usr/bin/systemctl'

def _request_start(self):
super(SystemdContainerService, self)._request_start()
super()._request_start()
ret = self._vm.ssh(
[self.BIN_PATH, 'exec vdsmc systemctl start', self._name]
)
Expand All @@ -87,7 +89,7 @@ def _request_start(self):
return self._vm.ssh([self.HOST_BIN_PATH, 'start', self._name])

def _request_stop(self):
super(SystemdContainerService, self)._request_stop()
super()._request_stop()
ret = self._vm.ssh(
[self.BIN_PATH, 'exec vdsmc systemctl stop', self._name]
)
Expand Down

0 comments on commit ac55bb3

Please sign in to comment.