* [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
@ 2015-10-12 4:35 Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Mike Frysinger
` (8 more replies)
0 siblings, 9 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/base/clearbase.py | 4 ++--
catalyst/base/resume.py | 4 ++--
catalyst/base/stagebase.py | 14 +++++++-------
catalyst/fileops.py | 2 +-
catalyst/targets/netboot2.py | 2 +-
catalyst/targets/snapshot.py | 2 +-
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 3817196..9a4c625 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -30,13 +30,13 @@ class ClearBase(object):
def clear_chroot(self):
self.chroot_lock.unlock()
log.notice('Clearing the chroot path ...')
- clear_dir(self.settings["chroot_path"], 0755, True)
+ clear_dir(self.settings["chroot_path"], 0o755, True)
def remove_chroot(self):
self.chroot_lock.unlock()
log.notice('Removing the chroot path ...')
- clear_dir(self.settings["chroot_path"], 0755, True, remove=True)
+ clear_dir(self.settings["chroot_path"], 0o755, True, remove=True)
def clear_packages(self, remove=False):
diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
index 99d8abc..70d9a4f 100644
--- a/catalyst/base/resume.py
+++ b/catalyst/base/resume.py
@@ -25,7 +25,7 @@ class AutoResume(object):
'''
- def __init__(self, basedir, mode=0755):
+ def __init__(self, basedir, mode=0o755):
self.basedir = basedir
ensure_dirs(basedir, mode=mode, fatal=True)
self._points = {}
@@ -131,7 +131,7 @@ class AutoResume(object):
@remove: boolean, passed through to clear_dir()
@return boolean
'''
- if clear_dir(self.basedir, mode=0755, chg_flags=True, remove=remove):
+ if clear_dir(self.basedir, mode=0o755, chg_flags=True, remove=remove):
self._points = {}
return True
return False
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 740e05d..a4832ec 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -492,7 +492,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
))
if "autoresume" in self.settings["options"]:
log.info('The autoresume path is %s', self.settings['autoresume_path'])
- self.resume = AutoResume(self.settings["autoresume_path"], mode=0755)
+ self.resume = AutoResume(self.settings["autoresume_path"], mode=0o755)
def set_controller_file(self):
self.settings["controller_file"]=normpath(self.settings["sharedir"]+\
@@ -773,10 +773,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
ensure_dirs(self.settings["chroot_path"]+"/tmp",mode=1777)
if "pkgcache" in self.settings["options"]:
- ensure_dirs(self.settings["pkgcache_path"],mode=0755)
+ ensure_dirs(self.settings["pkgcache_path"],mode=0o755)
if "kerncache" in self.settings["options"]:
- ensure_dirs(self.settings["kerncache_path"],mode=0755)
+ ensure_dirs(self.settings["kerncache_path"],mode=0o755)
log.notice('%s', display_msg % unpack_info)
@@ -848,7 +848,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
cleanup_cmd = "rm -rf " + target_portdir
log.info('unpack() cleanup_cmd = %s', cleanup_cmd)
cmd(cleanup_cmd,cleanup_errmsg,env=self.env)
- ensure_dirs(target_portdir, mode=0755)
+ ensure_dirs(target_portdir, mode=0o755)
log.notice('Unpacking portage tree (this can take a long time) ...')
if not self.decompressor.extract(unpack_info):
@@ -936,11 +936,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
_cmd = ''
log.debug('bind(); x = %s', x)
target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
- ensure_dirs(target, mode=0755)
+ ensure_dirs(target, mode=0o755)
if not os.path.exists(self.mountmap[x]):
if self.mountmap[x] not in ["tmpfs", "shmfs"]:
- ensure_dirs(self.mountmap[x], mode=0755)
+ ensure_dirs(self.mountmap[x], mode=0o755)
src=self.mountmap[x]
log.debug('bind(); src = %s', src)
@@ -1222,7 +1222,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# the proper perms and ownership
mystat=os.stat(myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
self.resume.enable("empty")
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 8fb2a36..1ef6b4c 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -37,7 +37,7 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True,
:param mode: permissions to set any created directories to
:param minimal: boolean controlling whether or not the specified mode
must be enforced, or is the minimal permissions necessary. For example,
- if mode=0755, minimal=True, and a directory exists with mode 0707,
+ if mode=0o755, minimal=True, and a directory exists with mode 0707,
this will restore the missing group perms resulting in 757.
:param failback: function to run in the event of a failed attemp
to create the directory.
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index d882a06..8644786 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -157,7 +157,7 @@ class netboot2(StageBase):
# the proper perms and ownership
mystat=os.stat(myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
self.resume.enable("empty")
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index d19f4ef..dbc4b1c 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -106,6 +106,6 @@ class snapshot(TargetBase, GenBase):
if os.uname()[0] == "FreeBSD":
os.system("chflags -R noschg "+myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
@ 2015-10-12 4:35 ` Mike Frysinger
2015-10-28 14:46 ` Brian Dolbec
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 3/9] stagebase: disable undefined-variable lint warning Mike Frysinger
` (7 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
---
doc/make_target_table.py | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/doc/make_target_table.py b/doc/make_target_table.py
index f127c37..9eb072b 100755
--- a/doc/make_target_table.py
+++ b/doc/make_target_table.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
# Copyright (C) 2012 W. Trevor King <wking@drexel.edu>
# Copyright (C) 2012 Sebastian Pipping <sebastian@pipping.org>
# Copyright (C) 2013 Brian dolbec <dolsen@gentoo.org>
@@ -10,34 +10,38 @@
from __future__ import print_function
-import sys as _sys
-
import glob
-import re
+import locale
+import os
+import sys
-def key_netboot_before_netboot2((target_name, _module)):
- return target_name + '1'
+def main(_argv):
+ source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ # Force consistent sorting order.
+ locale.setlocale(locale.LC_COLLATE, 'C')
-if __name__ == '__main__':
- extractor = re.compile('^catalyst/targets/(([^ ]+)).py$')
targets = list()
- for filename in sorted(glob.glob('catalyst/targets/*.py')):
+ for filename in glob.glob(os.path.join(source_root, 'catalyst/targets/*.py')):
if '__init__' in filename:
continue
- match = extractor.match(filename)
- target_name = match.group(2).replace('_', '-')
- module_name = 'catalyst.targets.' + match.group(1)
+ name = os.path.basename(filename)[0:-3]
+ target_name = name.replace('_', '-')
+ module_name = 'catalyst.targets.' + name
__import__(module_name)
- module = _sys.modules[module_name]
+ module = sys.modules[module_name]
targets.append((target_name, module))
- for target_name, module in sorted(targets, key=key_netboot_before_netboot2):
+ for target_name, module in sorted(targets, key=lambda x: x[0]):
print('`%s`;;' % target_name)
# Replace blank lines with `+` (asciidoc list item continuation)
print(module.__doc__.strip().replace('\n\n', '\n+\n'))
print('')
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 3/9] stagebase: disable undefined-variable lint warning
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Mike Frysinger
@ 2015-10-12 4:35 ` Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 4/9] log: make sure NOTICE is an int Mike Frysinger
` (6 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
raw_input doesn't exist w/py3, so pylint complains. Disable
the warning for this one line since we know it's fine.
---
catalyst/base/stagebase.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index a4832ec..770ce76 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -28,7 +28,7 @@ from catalyst.base.resume import AutoResume
if sys.version_info[0] >= 3:
py_input = input
else:
- py_input = raw_input
+ py_input = raw_input # pylint: disable=undefined-variable
class StageBase(TargetBase, ClearBase, GenBase):
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 4/9] log: make sure NOTICE is an int
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 3/9] stagebase: disable undefined-variable lint warning Mike Frysinger
@ 2015-10-12 4:35 ` Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 5/9] genbase: use sorted() with dict keys Mike Frysinger
` (5 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
The log module wants ints for its levels, so make sure NOTICE is
not a float due to the division. This doesn't show up so much in
py2, but py3 barfs on floats.
---
catalyst/log.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalyst/log.py b/catalyst/log.py
index 871c53c..5938199 100644
--- a/catalyst/log.py
+++ b/catalyst/log.py
@@ -39,7 +39,7 @@ del _klass
# Set the notice level between warning and info.
-NOTICE = (logging.WARNING + logging.INFO) / 2
+NOTICE = (logging.WARNING + logging.INFO) // 2
logging.addLevelName(NOTICE, 'NOTICE')
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 5/9] genbase: use sorted() with dict keys
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (2 preceding siblings ...)
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 4/9] log: make sure NOTICE is an int Mike Frysinger
@ 2015-10-12 4:35 ` Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 6/9] hash_utils: fix bad keyword w/CatalystError Mike Frysinger
` (4 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
In py3, the dict keys func returns a view which doesn't have a sort
member. Pass the result through sorted() which works with py2 and
py3.
---
catalyst/base/genbase.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index a33f924..8a1af8d 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -22,8 +22,7 @@ class GenBase(object):
keys={}
for i in self.settings["contents"].split():
keys[i]=1
- array=keys.keys()
- array.sort()
+ array = sorted(keys.keys())
for j in array:
contents = contents_map.contents(path, j,
verbose=self.settings["VERBOSE"])
@@ -42,8 +41,7 @@ class GenBase(object):
keys={}
for i in self.settings["digests"].split():
keys[i]=1
- array=keys.keys()
- array.sort()
+ array = sorted(keys.keys())
for f in [path, path + '.CONTENTS']:
if os.path.exists(f):
if "all" in array:
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 6/9] hash_utils: fix bad keyword w/CatalystError
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (3 preceding siblings ...)
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 5/9] genbase: use sorted() with dict keys Mike Frysinger
@ 2015-10-12 4:35 ` Mike Frysinger
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen Mike Frysinger
` (3 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:35 UTC (permalink / raw
To: gentoo-catalyst
The exception takes "print_traceback", not "traceback".
---
catalyst/hash_utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 3db61f1..1161da3 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -79,7 +79,7 @@ class HashMap(object):
hash_)
except:
raise CatalystError("Error generating hash, is appropriate " + \
- "utility installed on your system?", traceback=True)
+ "utility installed on your system?", print_traceback=True)
def calc_hash(self, file_, hash_):
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (4 preceding siblings ...)
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 6/9] hash_utils: fix bad keyword w/CatalystError Mike Frysinger
@ 2015-10-12 4:36 ` Mike Frysinger
2015-10-28 14:49 ` Brian Dolbec
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance Mike Frysinger
` (2 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:36 UTC (permalink / raw
To: gentoo-catalyst
In py3, the return of popen is binary data. We need
to decode it to get a string we can work with.
---
catalyst/hash_utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 1161da3..6e08967 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -117,7 +117,7 @@ class HashMap(object):
log.debug('args = %r', args)
source = Popen(args, stdout=PIPE)
output = source.communicate()
- lines = output[0].split('\n')
+ lines = output[0].decode('ascii').split('\n')
log.debug('output = %s', output)
header = lines[0]
h_f = lines[1].split()
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (5 preceding siblings ...)
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen Mike Frysinger
@ 2015-10-12 4:36 ` Mike Frysinger
2015-10-28 14:55 ` Brian Dolbec
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings Mike Frysinger
2015-10-12 4:41 ` [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
8 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:36 UTC (permalink / raw
To: gentoo-catalyst
pylint complains about using (type(...) == types.xxx) checks as it
prefers isinstance(..., xxx) instead. Convert the code base to it.
---
.pylintrc | 3 +--
catalyst/base/stagebase.py | 57 +++++++++++++++++----------------------
catalyst/support.py | 3 +--
catalyst/targets/grp.py | 5 ++--
catalyst/targets/livecd_stage1.py | 5 ++--
catalyst/targets/netboot.py | 9 +++----
catalyst/targets/netboot2.py | 11 ++++----
7 files changed, 39 insertions(+), 54 deletions(-)
diff --git a/.pylintrc b/.pylintrc
index b3327cf..2a03f23 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -32,11 +32,10 @@ load-plugins=
# bad-continuation -- might be hard with tab indentation policy
# invalid-name -- need to manage constants better
# line-too-long -- figure out a length and stick to it
-# unidiomatic-typecheck -- convert to isinstance
# redefined-outer-name -- clean up code to not do this
# super-init-not-called -- fix the classes __init__ structure
# no-init -- update classes w/missing __init__ functions
-disable=missing-docstring, too-many-lines, too-many-branches, too-many-statements, too-few-public-methods, too-many-instance-attributes, too-many-public-methods, too-many-locals, too-many-arguments, locally-enabled, locally-disabled, fixme, broad-except, bad-whitespace, bad-continuation, invalid-name, line-too-long, unidiomatic-typecheck, redefined-outer-name, super-init-not-called, no-init
+disable=missing-docstring, too-many-lines, too-many-branches, too-many-statements, too-few-public-methods, too-many-instance-attributes, too-many-public-methods, too-many-locals, too-many-arguments, locally-enabled, locally-disabled, fixme, broad-except, bad-whitespace, bad-continuation, invalid-name, line-too-long, redefined-outer-name, super-init-not-called, no-init
[REPORTS]
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 770ce76..f08b9a4 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1,7 +1,6 @@
import os
import imp
-import types
import shutil
import sys
from stat import ST_UID, ST_GID, ST_MODE
@@ -297,7 +296,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_install_mask(self):
if "install_mask" in self.settings:
- if type(self.settings["install_mask"])!=types.StringType:
+ if not isinstance(self.settings['install_mask'], str):
self.settings["install_mask"]=\
' '.join(self.settings["install_mask"])
@@ -313,14 +312,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["version_stamp"] +'/'
def set_source_subpath(self):
- if type(self.settings["source_subpath"])!=types.StringType:
+ if not isinstance(self.settings['source_subpath'], str):
raise CatalystError(
"source_subpath should have been a string. Perhaps you have " +\
"something wrong in your spec file?")
def set_pkgcache_path(self):
if "pkgcache_path" in self.settings:
- if type(self.settings["pkgcache_path"])!=types.StringType:
+ if not isinstance(self.settings['pkgcache_path'], str):
self.settings["pkgcache_path"]=\
normpath(self.settings["pkgcache_path"])
else:
@@ -330,7 +329,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_kerncache_path(self):
if "kerncache_path" in self.settings:
- if type(self.settings["kerncache_path"])!=types.StringType:
+ if not isinstance(self.settings['kerncache_path'], str):
self.settings["kerncache_path"]=\
normpath(self.settings["kerncache_path"])
else:
@@ -536,7 +535,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
del self.settings[self.settings["spec_prefix"]+"/use"]
if "use" not in self.settings:
self.settings["use"]=""
- if type(self.settings["use"])==types.StringType:
+ if isinstance(self.settings['use'], str):
self.settings["use"]=self.settings["use"].split()
# Force bindist when options ask for it
@@ -554,30 +553,27 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_rm(self):
if self.settings["spec_prefix"]+"/rm" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/rm"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/rm'], str):
self.settings[self.settings["spec_prefix"]+"/rm"]=\
self.settings[self.settings["spec_prefix"]+"/rm"].split()
def set_linuxrc(self):
if self.settings["spec_prefix"]+"/linuxrc" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/linuxrc"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/linuxrc'], str):
self.settings["linuxrc"]=\
self.settings[self.settings["spec_prefix"]+"/linuxrc"]
del self.settings[self.settings["spec_prefix"]+"/linuxrc"]
def set_busybox_config(self):
if self.settings["spec_prefix"]+"/busybox_config" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/busybox_config"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/busybox_config'], str):
self.settings["busybox_config"]=\
self.settings[self.settings["spec_prefix"]+"/busybox_config"]
del self.settings[self.settings["spec_prefix"]+"/busybox_config"]
def set_portage_overlay(self):
if "portage_overlay" in self.settings:
- if type(self.settings["portage_overlay"])==types.StringType:
+ if isinstance(self.settings['portage_overlay'], str):
self.settings["portage_overlay"]=\
self.settings["portage_overlay"].split()
log.info('portage_overlay directories are set to: %s',
@@ -585,16 +581,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_overlay(self):
if self.settings["spec_prefix"]+"/overlay" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/overlay"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/overlay'], str):
self.settings[self.settings["spec_prefix"]+"/overlay"]=\
self.settings[self.settings["spec_prefix"]+\
"/overlay"].split()
def set_root_overlay(self):
if self.settings["spec_prefix"]+"/root_overlay" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/root_overlay"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/root_overlay'], str):
self.settings[self.settings["spec_prefix"]+"/root_overlay"]=\
self.settings[self.settings["spec_prefix"]+\
"/root_overlay"].split()
@@ -605,7 +599,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_valid_build_kernel_vars(self,addlargs):
if "boot/kernel" in addlargs:
- if type(addlargs["boot/kernel"])==types.StringType:
+ if isinstance(addlargs['boot/kernel'], str):
loopy=[addlargs["boot/kernel"]]
else:
loopy=addlargs["boot/kernel"]
@@ -625,8 +619,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.valid_values.append("boot/kernel/"+x+"/packages")
self.valid_values.append("boot/kernel/"+x+"/kernelopts")
if "boot/kernel/"+x+"/packages" in addlargs:
- if type(addlargs["boot/kernel/"+x+\
- "/packages"])==types.StringType:
+ if isinstance(addlargs['boot/kernel/'+x+'/packages'], str):
addlargs["boot/kernel/"+x+"/packages"]=\
[addlargs["boot/kernel/"+x+"/packages"]]
@@ -1207,8 +1200,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping empty operation...')
else:
if self.settings["spec_prefix"]+"/empty" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/empty"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/empty'], str):
self.settings[self.settings["spec_prefix"]+"/empty"]=\
self.settings[self.settings["spec_prefix"]+\
"/empty"].split()
@@ -1338,14 +1330,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
varname = "clst_" + x.replace("/", "_")
varname = varname.replace("-", "_")
varname = varname.replace(".", "_")
- if type(self.settings[x])==types.StringType:
+ if isinstance(self.settings[x], str):
# Prefix to prevent namespace clashes
#os.environ[varname]=self.settings[x]
self.env[varname]=self.settings[x]
- elif type(self.settings[x])==types.ListType:
+ elif isinstance(self.settings[x], list):
#os.environ[varname] = ' '.join(self.settings[x])
self.env[varname] = ' '.join(self.settings[x])
- elif type(self.settings[x])==types.BooleanType:
+ elif isinstance(self.settings[x], bool):
if self.settings[x]:
self.env[varname] = "true"
else:
@@ -1354,7 +1346,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# Its currently used only for USE_EXPAND flags which are dictionaries of
# lists in arch/amd64.py and friends. If we wanted self.settigs[var]
# of any depth, we should make this function recursive.
- elif type(self.settings[x]) == types.DictType:
+ elif isinstance(self.settings[x], dict):
if x in ["compress_definitions",
"decompress_definitions"]:
continue
@@ -1363,11 +1355,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
varname2 = "clst_" + y.replace("/", "_")
varname2 = varname2.replace("-", "_")
varname2 = varname2.replace(".", "_")
- if type(self.settings[x][y]) == types.StringType:
+ if isinstance(self.settings[x][y], str):
self.env[varname2] = self.settings[x][y]
- elif type(self.settings[x][y]) == types.ListType:
+ elif isinstance(self.settings[x][y], list):
self.env[varname2] = ' '.join(self.settings[x][y])
- elif type(self.settings[x][y]) == types.BooleanType:
+ elif isinstance(self.settings[x][y], bool):
if self.settings[x][y]:
self.env[varname] = "true"
else:
@@ -1429,8 +1421,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping unmerge operation...')
else:
if self.settings["spec_prefix"]+"/unmerge" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+\
- "/unmerge"])==types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/unmerge'], str):
self.settings[self.settings["spec_prefix"]+"/unmerge"]=\
[self.settings[self.settings["spec_prefix"]+"/unmerge"]]
myunmerge=\
@@ -1529,7 +1520,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "boot/kernel" in self.settings:
try:
mynames=self.settings["boot/kernel"]
- if type(mynames)==types.StringType:
+ if isinstance(mynames, str):
mynames=[mynames]
# Execute the script that sets up the kernel build environment
cmd(self.settings["controller_file"]+\
@@ -1558,7 +1549,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
myopts=self.settings["boot/kernel/"+kname+\
"/kernelopts"]
- if type(myopts) != types.StringType:
+ if not isinstance(myopts, str):
myopts = ' '.join(myopts)
self.env[kname+"_kernelopts"]=myopts
diff --git a/catalyst/support.py b/catalyst/support.py
index 8883acb..380c1c1 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -2,7 +2,6 @@
import glob
import sys
import os
-import types
import re
import time
from subprocess import Popen
@@ -14,7 +13,7 @@ BASH_BINARY = "/bin/bash"
def list_bashify(mylist):
- if type(mylist)==types.StringType:
+ if isinstance(mylist, str):
mypack=[mylist]
else:
mypack=mylist[:]
diff --git a/catalyst/targets/grp.py b/catalyst/targets/grp.py
index b37366c..0b38417 100644
--- a/catalyst/targets/grp.py
+++ b/catalyst/targets/grp.py
@@ -4,7 +4,6 @@ Gentoo Reference Platform (GRP) target
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import types
import glob
from catalyst import log
@@ -27,11 +26,11 @@ class grp(StageBase):
raise CatalystError("Required value \"grp\" not specified in spec.")
self.required_values.extend(["grp"])
- if type(addlargs["grp"])==types.StringType:
+ if isinstance(addlargs['grp'], str):
addlargs["grp"]=[addlargs["grp"]]
if "grp/use" in addlargs:
- if type(addlargs["grp/use"])==types.StringType:
+ if isinstance(addlargs['grp/use'], str):
addlargs["grp/use"]=[addlargs["grp/use"]]
for x in addlargs["grp"]:
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 8d9dcc7..70f9243 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -4,7 +4,6 @@ LiveCD stage1 target
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import types
from catalyst import log
from catalyst.support import (normpath, cmd)
@@ -60,14 +59,14 @@ class livecd_stage1(StageBase):
def set_packages(self):
StageBase.set_packages(self)
if self.settings["spec_prefix"]+"/packages" in self.settings:
- if type(self.settings[self.settings["spec_prefix"]+"/packages"]) == types.StringType:
+ if isinstance(self.settings[self.settings['spec_prefix']+'/packages'], str):
self.settings[self.settings["spec_prefix"]+"/packages"] = \
self.settings[self.settings["spec_prefix"]+"/packages"].split()
self.settings[self.settings["spec_prefix"]+"/packages"].append("app-misc/livecd-tools")
def set_pkgcache_path(self):
if "pkgcache_path" in self.settings:
- if type(self.settings["pkgcache_path"]) != types.StringType:
+ if not isinstance(self.settings['pkgcache_path'], str):
self.settings["pkgcache_path"] = normpath(' '.join(self.settings["pkgcache_path"]))
else:
StageBase.set_pkgcache_path(self)
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 333a230..5285c05 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -4,7 +4,6 @@ netboot target, version 1
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import types
from catalyst import log
from catalyst.support import (CatalystError, normpath,
@@ -33,7 +32,7 @@ class netboot(StageBase):
try:
# XXX: This code does nothing because the for loop below is disabled.
if "netboot/packages" in addlargs:
- if type(addlargs["netboot/packages"]) == types.StringType:
+ if isinstance(addlargs['netboot/packages'], str):
_loopy = [addlargs["netboot/packages"]]
else:
_loopy = addlargs["netboot/packages"]
@@ -88,20 +87,20 @@ class netboot(StageBase):
# create image
myfiles=[]
if "netboot/packages" in self.settings:
- if type(self.settings["netboot/packages"]) == types.StringType:
+ if isinstance(self.settings['netboot/packages'], str):
loopy=[self.settings["netboot/packages"]]
else:
loopy=self.settings["netboot/packages"]
for x in loopy:
if "netboot/packages/"+x+"/files" in self.settings:
- if type(self.settings["netboot/packages/"+x+"/files"]) == types.ListType:
+ if isinstance(type(self.settings['netboot/packages/'+x+'/files']), str):
myfiles.extend(self.settings["netboot/packages/"+x+"/files"])
else:
myfiles.append(self.settings["netboot/packages/"+x+"/files"])
if "netboot/extra_files" in self.settings:
- if type(self.settings["netboot/extra_files"]) == types.ListType:
+ if isinstance(self.settings['netboot/extra_files'], list):
myfiles.extend(self.settings["netboot/extra_files"])
else:
myfiles.append(self.settings["netboot/extra_files"])
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 8644786..769b945 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -4,7 +4,6 @@ netboot target, version 2
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import types
import shutil
from stat import ST_UID, ST_GID, ST_MODE
@@ -36,7 +35,7 @@ class netboot2(StageBase):
try:
if "netboot2/packages" in addlargs:
- if type(addlargs["netboot2/packages"]) == types.StringType:
+ if isinstance(addlargs['netboot2/packages'], str):
loopy=[addlargs["netboot2/packages"]]
else:
loopy=addlargs["netboot2/packages"]
@@ -73,20 +72,20 @@ class netboot2(StageBase):
log.notice('Resume point detected, skipping target path setup operation...')
else:
if "netboot2/packages" in self.settings:
- if type(self.settings["netboot2/packages"]) == types.StringType:
+ if isinstance(self.settings['netboot2/packages'], str):
loopy=[self.settings["netboot2/packages"]]
else:
loopy=self.settings["netboot2/packages"]
for x in loopy:
if "netboot2/packages/"+x+"/files" in self.settings:
- if type(self.settings["netboot2/packages/"+x+"/files"]) == types.ListType:
+ if isinstance(self.settings['netboot2/packages/'+x+'/files'], list):
myfiles.extend(self.settings["netboot2/packages/"+x+"/files"])
else:
myfiles.append(self.settings["netboot2/packages/"+x+"/files"])
if "netboot2/extra_files" in self.settings:
- if type(self.settings["netboot2/extra_files"]) == types.ListType:
+ if isinstance(self.settings['netboot2/extra_files'], list):
myfiles.extend(self.settings["netboot2/extra_files"])
else:
myfiles.append(self.settings["netboot2/extra_files"])
@@ -145,7 +144,7 @@ class netboot2(StageBase):
log.notice('Resume point detected, skipping empty operation...')
else:
if "netboot2/empty" in self.settings:
- if type(self.settings["netboot2/empty"])==types.StringType:
+ if isinstance(self.settings['netboot2/empty'], str):
self.settings["netboot2/empty"]=self.settings["netboot2/empty"].split()
for x in self.settings["netboot2/empty"]:
myemp=self.settings["chroot_path"] + self.settings["merge_path"] + x
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (6 preceding siblings ...)
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance Mike Frysinger
@ 2015-10-12 4:36 ` Mike Frysinger
2015-10-28 14:58 ` Brian Dolbec
2015-10-12 4:41 ` [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
8 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:36 UTC (permalink / raw
To: gentoo-catalyst
The doc module just needs a main func to hold all the variables
instead of coding it all in global scope.
---
.pylintrc | 3 +--
catalyst/log.py | 4 ++++
doc/make_subarch_table_guidexml.py | 9 +++++++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/.pylintrc b/.pylintrc
index 2a03f23..e657daf 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -32,10 +32,9 @@ load-plugins=
# bad-continuation -- might be hard with tab indentation policy
# invalid-name -- need to manage constants better
# line-too-long -- figure out a length and stick to it
-# redefined-outer-name -- clean up code to not do this
# super-init-not-called -- fix the classes __init__ structure
# no-init -- update classes w/missing __init__ functions
-disable=missing-docstring, too-many-lines, too-many-branches, too-many-statements, too-few-public-methods, too-many-instance-attributes, too-many-public-methods, too-many-locals, too-many-arguments, locally-enabled, locally-disabled, fixme, broad-except, bad-whitespace, bad-continuation, invalid-name, line-too-long, redefined-outer-name, super-init-not-called, no-init
+disable=missing-docstring, too-many-lines, too-many-branches, too-many-statements, too-few-public-methods, too-many-instance-attributes, too-many-public-methods, too-many-locals, too-many-arguments, locally-enabled, locally-disabled, fixme, broad-except, bad-whitespace, bad-continuation, invalid-name, line-too-long, super-init-not-called, no-init
[REPORTS]
diff --git a/catalyst/log.py b/catalyst/log.py
index 5938199..d640dec 100644
--- a/catalyst/log.py
+++ b/catalyst/log.py
@@ -98,6 +98,10 @@ class CatalystFormatter(logging.Formatter):
return msg
+# We define |debug| in global scope so people can call log.debug(), but it
+# makes the linter complain when we have a |debug| keyword. Since we don't
+# use that func in here, it's not a problem, so silence the warning.
+# pylint: disable=redefined-outer-name
def setup_logging(level, output=None, debug=False, color=None):
"""Initialize the logging module using the |level| level"""
# The incoming level will be things like "info", but setLevel wants
diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py
index a6a9022..0699d2a 100755
--- a/doc/make_subarch_table_guidexml.py
+++ b/doc/make_subarch_table_guidexml.py
@@ -6,6 +6,7 @@
import os
import re
+import sys
import textwrap
@@ -99,11 +100,11 @@ def dump(subarch_title_to_subarch_id, subarch_id_to_pattern_arch_genericrch_id):
f.close()
-if __name__ == '__main__':
+def main(_argv):
subarch_title_to_subarch_id = dict()
subarch_id_to_pattern_arch_genericrch_id = dict()
- for (dirpath, dirnames, filenames) in os.walk('catalyst/arch'):
+ for dirpath, _dirnames, filenames in os.walk('catalyst/arch'):
for _fn in filenames:
if not _fn.endswith('.py'):
continue
@@ -114,3 +115,7 @@ if __name__ == '__main__':
handle_file(fn, subarch_title_to_subarch_id, subarch_id_to_pattern_arch_genericrch_id)
dump(subarch_title_to_subarch_id, subarch_id_to_pattern_arch_genericrch_id)
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
--
2.5.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
` (7 preceding siblings ...)
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings Mike Frysinger
@ 2015-10-12 4:41 ` Mike Frysinger
2015-10-22 5:17 ` Mike Frysinger
8 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-12 4:41 UTC (permalink / raw
To: gentoo-catalyst
[-- Attachment #1: Type: text/plain, Size: 179 bytes --]
with this patchseries, catalyst is able to build a snapshot/stage[123]
using python3. well, after a fix in decomp too, but i filed an issue
in the github tracker for that.
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-12 4:41 ` [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
@ 2015-10-22 5:17 ` Mike Frysinger
2015-10-24 7:00 ` Mike Frysinger
2015-10-24 11:37 ` Anthony G. Basile
0 siblings, 2 replies; 23+ messages in thread
From: Mike Frysinger @ 2015-10-22 5:17 UTC (permalink / raw
To: gentoo-catalyst
[-- Attachment #1: Type: text/plain, Size: 257 bytes --]
On 12 Oct 2015 00:41, Mike Frysinger wrote:
> with this patchseries, catalyst is able to build a snapshot/stage[123]
> using python3. well, after a fix in decomp too, but i filed an issue
> in the github tracker for that.
any takers for review ? :)
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-22 5:17 ` Mike Frysinger
@ 2015-10-24 7:00 ` Mike Frysinger
2015-10-28 14:25 ` Brian Dolbec
2015-10-24 11:37 ` Anthony G. Basile
1 sibling, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-24 7:00 UTC (permalink / raw
To: gentoo-catalyst
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
On 22 Oct 2015 01:17, Mike Frysinger wrote:
> On 12 Oct 2015 00:41, Mike Frysinger wrote:
> > with this patchseries, catalyst is able to build a snapshot/stage[123]
> > using python3. well, after a fix in decomp too, but i filed an issue
> > in the github tracker for that.
>
> any takers for review ? :)
i pushed the obvious & bugfix ones:
hash_utils: fix bad keyword w/CatalystError
genbase: use sorted() with dict keys
log: make sure NOTICE is an int
stagebase: disable undefined-variable lint warning
convert octals to py3 compat
lock: fix ensure_dirs call
the other 5 are still pending review though:
lint: fix redefined-outer-name warnings
lint: convert type/types to isinstance
hash_utils: decode output of popen
make_target_table: rewrite for py3/stability
stagebase: robustify portage_confdir setup
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-22 5:17 ` Mike Frysinger
2015-10-24 7:00 ` Mike Frysinger
@ 2015-10-24 11:37 ` Anthony G. Basile
2015-10-24 14:16 ` Anthony G. Basile
1 sibling, 1 reply; 23+ messages in thread
From: Anthony G. Basile @ 2015-10-24 11:37 UTC (permalink / raw
To: gentoo-catalyst
On 10/22/15 1:17 AM, Mike Frysinger wrote:
> On 12 Oct 2015 00:41, Mike Frysinger wrote:
>> with this patchseries, catalyst is able to build a snapshot/stage[123]
>> using python3. well, after a fix in decomp too, but i filed an issue
>> in the github tracker for that.
>
> any takers for review ? :)
> -mike
>
I didn't see anything obviously wrong. I will be testing master
hopefully within an hour or so on some of my stuff and I'll get back to
everyone.
--
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-24 11:37 ` Anthony G. Basile
@ 2015-10-24 14:16 ` Anthony G. Basile
2015-11-09 4:52 ` Brian Dolbec
0 siblings, 1 reply; 23+ messages in thread
From: Anthony G. Basile @ 2015-10-24 14:16 UTC (permalink / raw
To: gentoo-catalyst
On 10/24/15 7:37 AM, Anthony G. Basile wrote:
> On 10/22/15 1:17 AM, Mike Frysinger wrote:
>> On 12 Oct 2015 00:41, Mike Frysinger wrote:
>>> with this patchseries, catalyst is able to build a snapshot/stage[123]
>>> using python3. well, after a fix in decomp too, but i filed an issue
>>> in the github tracker for that.
>>
>> any takers for review ? :)
>> -mike
>>
>
> I didn't see anything obviously wrong. I will be testing master
> hopefully within an hour or so on some of my stuff and I'll get back to
> everyone.
>
It did something quite unexpected. I'll have to dissect and I'll give a
better report. I don't want to just give a half baked report now. Did
anyone else test?
--
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-24 7:00 ` Mike Frysinger
@ 2015-10-28 14:25 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 14:25 UTC (permalink / raw
To: gentoo-catalyst
On Sat, 24 Oct 2015 03:00:36 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> On 22 Oct 2015 01:17, Mike Frysinger wrote:
> > On 12 Oct 2015 00:41, Mike Frysinger wrote:
> > > with this patchseries, catalyst is able to build a
> > > snapshot/stage[123] using python3. well, after a fix in decomp
> > > too, but i filed an issue in the github tracker for that.
> >
> > any takers for review ? :)
>
> i pushed the obvious & bugfix ones:
> hash_utils: fix bad keyword w/CatalystError
> genbase: use sorted() with dict keys
> log: make sure NOTICE is an int
> stagebase: disable undefined-variable lint warning
> convert octals to py3 compat
> lock: fix ensure_dirs call
>
> the other 5 are still pending review though:
> lint: fix redefined-outer-name warnings
> lint: convert type/types to isinstance
> hash_utils: decode output of popen
> make_target_table: rewrite for py3/stability
> stagebase: robustify portage_confdir setup
> -mike
OK, I'm back and starting to catch up with the hundreds of gentoo
emails still left in my inbox. Was over 2000 initially. (from just 2
weeks)
Yeah, those first 5 committed looked fine. It would have been
nicer/easier to track if you used the patch numbers in the above
listings... [PATCH 1/9], not just the message title.
I'll get to the decomp fix later today probably.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Mike Frysinger
@ 2015-10-28 14:46 ` Brian Dolbec
2015-10-28 16:49 ` Mike Frysinger
0 siblings, 1 reply; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 14:46 UTC (permalink / raw
To: gentoo-catalyst
On Mon, 12 Oct 2015 00:35:55 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> ---
> doc/make_target_table.py | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/doc/make_target_table.py b/doc/make_target_table.py
> index f127c37..9eb072b 100755
> --- a/doc/make_target_table.py
> +++ b/doc/make_target_table.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/python
> # Copyright (C) 2012 W. Trevor King <wking@drexel.edu>
> # Copyright (C) 2012 Sebastian Pipping <sebastian@pipping.org>
> # Copyright (C) 2013 Brian dolbec <dolsen@gentoo.org>
> @@ -10,34 +10,38 @@
>
> from __future__ import print_function
>
> -import sys as _sys
> -
> import glob
> -import re
> +import locale
> +import os
> +import sys
>
>
> -def key_netboot_before_netboot2((target_name, _module)):
> - return target_name + '1'
> +def main(_argv):
> + source_root =
> os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
> + # Force consistent sorting order.
> + locale.setlocale(locale.LC_COLLATE, 'C')
>
> -if __name__ == '__main__':
> - extractor = re.compile('^catalyst/targets/(([^ ]+)).py$')
> targets = list()
> - for filename in sorted(glob.glob('catalyst/targets/*.py')):
> + for filename in glob.glob(os.path.join(source_root,
> 'catalyst/targets/*.py')): if '__init__' in filename:
> continue
>
> - match = extractor.match(filename)
> - target_name = match.group(2).replace('_', '-')
> - module_name = 'catalyst.targets.' + match.group(1)
> + name = os.path.basename(filename)[0:-3]
> + target_name = name.replace('_', '-')
> + module_name = 'catalyst.targets.' + name
>
> __import__(module_name)
> - module = _sys.modules[module_name]
> + module = sys.modules[module_name]
>
> targets.append((target_name, module))
>
> - for target_name, module in sorted(targets,
> key=key_netboot_before_netboot2):
> + for target_name, module in sorted(targets, key=lambda x:
> x[0]): print('`%s`;;' % target_name)
> # Replace blank lines with `+` (asciidoc list item
> continuation) print(module.__doc__.strip().replace('\n\n', '\n+\n'))
> print('')
> +
> +
> +if __name__ == '__main__':
> + main(sys.argv[1:])
looks harmless enough ;) test will be when generating the docs making a
release
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen Mike Frysinger
@ 2015-10-28 14:49 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 14:49 UTC (permalink / raw
To: gentoo-catalyst
On Mon, 12 Oct 2015 00:36:00 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> In py3, the return of popen is binary data. We need
> to decode it to get a string we can work with.
> ---
> catalyst/hash_utils.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
> index 1161da3..6e08967 100644
> --- a/catalyst/hash_utils.py
> +++ b/catalyst/hash_utils.py
> @@ -117,7 +117,7 @@ class HashMap(object):
> log.debug('args = %r', args)
> source = Popen(args, stdout=PIPE)
> output = source.communicate()
> - lines = output[0].split('\n')
> + lines = output[0].decode('ascii').split('\n')
> log.debug('output = %s', output)
> header = lines[0]
> h_f = lines[1].split()
looks good
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance Mike Frysinger
@ 2015-10-28 14:55 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 14:55 UTC (permalink / raw
To: gentoo-catalyst
On Mon, 12 Oct 2015 00:36:01 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> pylint complains about using (type(...) == types.xxx) checks as it
> prefers isinstance(..., xxx) instead. Convert the code base to it.
> ---
> .pylintrc | 3 +--
> catalyst/base/stagebase.py | 57
> +++++++++++++++++----------------------
> catalyst/support.py | 3 +--
> catalyst/targets/grp.py | 5 ++--
> catalyst/targets/livecd_stage1.py | 5 ++--
> catalyst/targets/netboot.py | 9 +++----
> catalyst/targets/netboot2.py | 11 ++++---- 7 files changed, 39
> insertions(+), 54 deletions(-)
>
>
looks good.
Thanks, yet another task done that has been bugging me for quite a
while.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings Mike Frysinger
@ 2015-10-28 14:58 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 14:58 UTC (permalink / raw
To: gentoo-catalyst
On Mon, 12 Oct 2015 00:36:02 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> The doc module just needs a main func to hold all the variables
> instead of coding it all in global scope.
> ---
> .pylintrc | 3 +--
> catalyst/log.py | 4 ++++
> doc/make_subarch_table_guidexml.py | 9 +++++++--
> 3 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/.pylintrc b/.pylintrc
> index 2a03f23..e657daf 100644
> --- a/.pylintrc
> +++ b/.pylintrc
> @@ -32,10 +32,9 @@ load-plugins=
> # bad-continuation -- might be hard with tab indentation policy
> # invalid-name -- need to manage constants better
> # line-too-long -- figure out a length and stick to it
> -# redefined-outer-name -- clean up code to not do this
> # super-init-not-called -- fix the classes __init__ structure
> # no-init -- update classes w/missing __init__ functions
> -disable=missing-docstring, too-many-lines, too-many-branches,
> too-many-statements, too-few-public-methods,
> too-many-instance-attributes, too-many-public-methods,
> too-many-locals, too-many-arguments, locally-enabled,
> locally-disabled, fixme, broad-except, bad-whitespace,
> bad-continuation, invalid-name, line-too-long, redefined-outer-name,
> super-init-not-called, no-init +disable=missing-docstring,
> too-many-lines, too-many-branches, too-many-statements,
> too-few-public-methods, too-many-instance-attributes,
> too-many-public-methods, too-many-locals, too-many-arguments,
> locally-enabled, locally-disabled, fixme, broad-except,
> bad-whitespace, bad-continuation, invalid-name, line-too-long,
> super-init-not-called, no-init [REPORTS] diff --git a/catalyst/log.py
> b/catalyst/log.py index 5938199..d640dec 100644 --- a/catalyst/log.py
> +++ b/catalyst/log.py @@ -98,6 +98,10 @@ class
> CatalystFormatter(logging.Formatter): return msg +# We define |debug|
> in global scope so people can call log.debug(), but it +# makes the
> linter complain when we have a |debug| keyword. Since we don't +#
> use that func in here, it's not a problem, so silence the warning. +#
> pylint: disable=redefined-outer-name def setup_logging(level,
> output=None, debug=False, color=None): """Initialize the logging
> module using the |level| level""" # The incoming level will be things
> like "info", but setLevel wants diff --git
> a/doc/make_subarch_table_guidexml.py
> b/doc/make_subarch_table_guidexml.py index a6a9022..0699d2a 100755
> --- a/doc/make_subarch_table_guidexml.py +++
> b/doc/make_subarch_table_guidexml.py @@ -6,6 +6,7 @@ import os
> import re
> +import sys
> import textwrap
>
>
> @@ -99,11 +100,11 @@ def dump(subarch_title_to_subarch_id,
> subarch_id_to_pattern_arch_genericrch_id): f.close()
>
>
> -if __name__ == '__main__':
> +def main(_argv):
> subarch_title_to_subarch_id = dict()
> subarch_id_to_pattern_arch_genericrch_id = dict()
>
> - for (dirpath, dirnames, filenames) in
> os.walk('catalyst/arch'):
> + for dirpath, _dirnames, filenames in
> os.walk('catalyst/arch'): for _fn in filenames:
> if not _fn.endswith('.py'):
> continue
> @@ -114,3 +115,7 @@ if __name__ == '__main__':
> handle_file(fn, subarch_title_to_subarch_id,
> subarch_id_to_pattern_arch_genericrch_id)
> dump(subarch_title_to_subarch_id,
> subarch_id_to_pattern_arch_genericrch_id) +
> +
> +if __name__ == '__main__':
> + main(sys.argv[1:])
looks good
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability
2015-10-28 14:46 ` Brian Dolbec
@ 2015-10-28 16:49 ` Mike Frysinger
2015-10-28 17:15 ` Brian Dolbec
0 siblings, 1 reply; 23+ messages in thread
From: Mike Frysinger @ 2015-10-28 16:49 UTC (permalink / raw
To: gentoo-catalyst
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
On 28 Oct 2015 07:46, Brian Dolbec wrote:
> looks harmless enough ;) test will be when generating the docs making a
> release
i was running the code and verifying the output matched before any of my changes
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability
2015-10-28 16:49 ` Mike Frysinger
@ 2015-10-28 17:15 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-10-28 17:15 UTC (permalink / raw
To: gentoo-catalyst
On Wed, 28 Oct 2015 12:49:19 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> On 28 Oct 2015 07:46, Brian Dolbec wrote:
> > looks harmless enough ;) test will be when generating the docs
> > making a release
>
> i was running the code and verifying the output matched before any of
> my changes -mike
yes, I figured as much :)
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-10-24 14:16 ` Anthony G. Basile
@ 2015-11-09 4:52 ` Brian Dolbec
2015-11-19 4:19 ` Brian Dolbec
0 siblings, 1 reply; 23+ messages in thread
From: Brian Dolbec @ 2015-11-09 4:52 UTC (permalink / raw
To: gentoo-catalyst
On Sat, 24 Oct 2015 10:16:03 -0400
"Anthony G. Basile" <basile@opensource.dyc.edu> wrote:
> On 10/24/15 7:37 AM, Anthony G. Basile wrote:
> > On 10/22/15 1:17 AM, Mike Frysinger wrote:
> >> On 12 Oct 2015 00:41, Mike Frysinger wrote:
> >>> with this patchseries, catalyst is able to build a
> >>> snapshot/stage[123] using python3. well, after a fix in decomp
> >>> too, but i filed an issue in the github tracker for that.
> >>
> >> any takers for review ? :)
> >> -mike
> >>
> >
> > I didn't see anything obviously wrong. I will be testing master
> > hopefully within an hour or so on some of my stuff and I'll get
> > back to everyone.
> >
>
> It did something quite unexpected. I'll have to dissect and I'll
> give a better report. I don't want to just give a half baked report
> now. Did anyone else test?
>
What is happening with this one?
Anthony, did you get any further checking it out?
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat
2015-11-09 4:52 ` Brian Dolbec
@ 2015-11-19 4:19 ` Brian Dolbec
0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2015-11-19 4:19 UTC (permalink / raw
To: gentoo-catalyst
On Sun, 8 Nov 2015 20:52:20 -0800
Brian Dolbec <dolsen@gentoo.org> wrote:
> On Sat, 24 Oct 2015 10:16:03 -0400
> "Anthony G. Basile" <basile@opensource.dyc.edu> wrote:
>
> > On 10/24/15 7:37 AM, Anthony G. Basile wrote:
> > > On 10/22/15 1:17 AM, Mike Frysinger wrote:
> > >> On 12 Oct 2015 00:41, Mike Frysinger wrote:
> > >>> with this patchseries, catalyst is able to build a
> > >>> snapshot/stage[123] using python3. well, after a fix in decomp
> > >>> too, but i filed an issue in the github tracker for that.
> > >>
> > >> any takers for review ? :)
> > >> -mike
> > >>
> > >
> > > I didn't see anything obviously wrong. I will be testing master
> > > hopefully within an hour or so on some of my stuff and I'll get
> > > back to everyone.
> > >
> >
> > It did something quite unexpected. I'll have to dissect and I'll
> > give a better report. I don't want to just give a half baked report
> > now. Did anyone else test?
> >
>
> What is happening with this one?
>
> Anthony, did you get any further checking it out?
>
Since there has been nothing about this, go ahead and merge it.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2015-11-19 4:20 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-12 4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Mike Frysinger
2015-10-28 14:46 ` Brian Dolbec
2015-10-28 16:49 ` Mike Frysinger
2015-10-28 17:15 ` Brian Dolbec
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 3/9] stagebase: disable undefined-variable lint warning Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 4/9] log: make sure NOTICE is an int Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 5/9] genbase: use sorted() with dict keys Mike Frysinger
2015-10-12 4:35 ` [gentoo-catalyst] [PATCH 6/9] hash_utils: fix bad keyword w/CatalystError Mike Frysinger
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen Mike Frysinger
2015-10-28 14:49 ` Brian Dolbec
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance Mike Frysinger
2015-10-28 14:55 ` Brian Dolbec
2015-10-12 4:36 ` [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings Mike Frysinger
2015-10-28 14:58 ` Brian Dolbec
2015-10-12 4:41 ` [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-22 5:17 ` Mike Frysinger
2015-10-24 7:00 ` Mike Frysinger
2015-10-28 14:25 ` Brian Dolbec
2015-10-24 11:37 ` Anthony G. Basile
2015-10-24 14:16 ` Anthony G. Basile
2015-11-09 4:52 ` Brian Dolbec
2015-11-19 4:19 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox