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
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
from __future__ import print_function
import argparse
import sys
import re
@ -42,7 +41,7 @@ def add_core_recursive(core, config):
.format(core.device, core.cache_id))
exit(3)
core.marked = True
match = re.match('/dev/cas(\d)-(\d).*', core.device)
match = re.match(r'/dev/cas(\d)-(\d).*', core.device)
if match:
cache_id,core_id = match.groups()
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
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
from __future__ import print_function
import subprocess
import time
import opencas

View File

@ -17,11 +17,11 @@ class casadm:
class result:
def __init__(self, cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.exit_code = p.wait()
output = p.communicate()
self.stdout = output[0]
self.stderr = output[1]
p = subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.exit_code = p.returncode
self.stdout = p.stdout
self.stderr = p.stderr
class CasadmError(Exception):
def __init__(self, result):
@ -500,10 +500,10 @@ def start_cache(cache, load, force=False):
force=force)
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,
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,
ioclass_file=cache.params['ioclass_file'])