Merge pull request #73 from Ostrokrzew/changed

Porting python2 to python3 syntax
This commit is contained in:
Adam Rutkowski 2019-08-05 13:37:19 +02:00 committed by GitHub
commit f55425ed4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -1,10 +1,9 @@
#!/usr/bin/env python2 #!/usr/bin/env python3
# #
# Copyright(c) 2012-2019 Intel Corporation # Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear # SPDX-License-Identifier: BSD-3-Clause-Clear
# #
from __future__ import print_function
import argparse import argparse
import sys import sys
import re import re
@ -42,7 +41,7 @@ def add_core_recursive(core, config):
.format(core.device, core.cache_id)) .format(core.device, core.cache_id))
exit(3) exit(3)
core.marked = True core.marked = True
match = re.match('/dev/cas(\d)-(\d).*', core.device) match = re.match(r'/dev/cas(\d)-(\d).*', core.device)
if match: if match:
cache_id,core_id = match.groups() cache_id,core_id = match.groups()
with_error = add_core_recursive(config.caches[int(cache_id)].cores[int(core_id)], config) with_error = add_core_recursive(config.caches[int(cache_id)].cores[int(core_id)], config)

View File

@ -1,10 +1,9 @@
#!/usr/bin/env python2 #!/usr/bin/env python3
# #
# Copyright(c) 2012-2019 Intel Corporation # Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear # SPDX-License-Identifier: BSD-3-Clause-Clear
# #
from __future__ import print_function
import subprocess import subprocess
import time import time
import opencas import opencas

View File

@ -17,11 +17,11 @@ class casadm:
class result: class result:
def __init__(self, cmd): def __init__(self, cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE,
self.exit_code = p.wait() stderr=subprocess.PIPE)
output = p.communicate() self.exit_code = p.returncode
self.stdout = output[0] self.stdout = p.stdout
self.stderr = output[1] self.stderr = p.stderr
class CasadmError(Exception): class CasadmError(Exception):
def __init__(self, result): def __init__(self, result):
@ -500,10 +500,10 @@ def start_cache(cache, load, force=False):
force=force) force=force)
def configure_cache(cache): def configure_cache(cache):
if cache.params.has_key('cleaning_policy'): if 'cleaning_policy' in cache.params:
casadm.set_param('cleaning', cache_id=cache.cache_id, casadm.set_param('cleaning', cache_id=cache.cache_id,
policy=cache.params['cleaning_policy']) policy=cache.params['cleaning_policy'])
if cache.params.has_key('ioclass_file'): if 'ioclass_file' in cache.params:
casadm.io_class_load_config(cache_id=cache.cache_id, casadm.io_class_load_config(cache_id=cache.cache_id,
ioclass_file=cache.params['ioclass_file']) ioclass_file=cache.params['ioclass_file'])