* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-01 5:58 Brian Dolbec
2015-09-01 4:50 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 7a036cf0fb918d95498d84577463db35c2eccc97
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 1 04:47:45 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 04:49:14 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7a036cf0
main.py: Remove 2 debug prints causing misleading information
In this part if the code, these inital defaults are not yet updated.
The valuse are updated later in the code.
catalyst/main.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index a222209..dd3c517 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -101,13 +101,11 @@ def parse_config(myconfig):
# now, load up the values into conf_values so that we can use them
for x in list(confdefaults):
if x in myconf:
- print "Setting",x,"to config file value \""+myconf[x]+"\""
if x == 'options':
conf_values[x] = set(myconf[x].split())
else:
conf_values[x]=myconf[x]
else:
- print "Setting",x,"to default value \""+confdefaults[x]+"\""
conf_values[x]=confdefaults[x]
# add our python base directory to use for loading target arch's
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
2015-09-01 5:58 [gentoo-commits] proj/catalyst:pending commit in: catalyst/ Brian Dolbec
@ 2015-09-01 4:50 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 4:50 UTC (permalink / raw
To: gentoo-commits
commit: 7a036cf0fb918d95498d84577463db35c2eccc97
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 1 04:47:45 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 04:49:14 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7a036cf0
main.py: Remove 2 debug prints causing misleading information
In this part if the code, these inital defaults are not yet updated.
The valuse are updated later in the code.
catalyst/main.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index a222209..dd3c517 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -101,13 +101,11 @@ def parse_config(myconfig):
# now, load up the values into conf_values so that we can use them
for x in list(confdefaults):
if x in myconf:
- print "Setting",x,"to config file value \""+myconf[x]+"\""
if x == 'options':
conf_values[x] = set(myconf[x].split())
else:
conf_values[x]=myconf[x]
else:
- print "Setting",x,"to default value \""+confdefaults[x]+"\""
conf_values[x]=confdefaults[x]
# add our python base directory to use for loading target arch's
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-11-22 15:52 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-11-22 15:52 UTC (permalink / raw
To: gentoo-commits
commit: b9f2806724077740c8fdbf8bcdb5a431cb085e9d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Nov 22 01:16:21 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b9f28067
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed2822..ed5766d6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -31,6 +31,15 @@ valid_config_file_values.extend([ "distcc", "envscript",
"compression_mode", "compressor_options", "decompressor_search_order",
])
+# set our base defaults here to keep
+# them in one location.
+BASE_GENTOO_DIR = "/var/gentoo"
+REPODIR = BASE_GENTOO_DIR + "/repos"
+DISTDIR = BASE_GENTOO_DIR + "/distfiles"
+PKGDIR = BASE_GENTOO_DIR + "/packages"
+MAINREPO = "gentoo"
+PORTDIR = REPODIR + "/" + MAINREPO
+
confdefaults={
"archdir": "%(PythonDir)s/arch",
"comp_prog": COMPRESSOR_PROGRAM_OPTIONS[TAR],
@@ -39,28 +48,28 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": REPODIR[:] + "/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": REPODIR[:],
+ "repo_name": MAINREPO[:],
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
- "target_distdir": "/var/portage/distfiles",
- "target_pkgdir":"/var/portage/packages",
+ "target_distdir": DISTDIR[:],
+ "target_pkgdir": PKGDIR[:],
}
DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
@@ -72,11 +81,11 @@ TARGET_MOUNT_DEFAULTS = {
"ccache": "/var/tmp/ccache",
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +95,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": DISTDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-16 22:57 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-16 22:57 UTC (permalink / raw
To: gentoo-commits
commit: e2293d1c1dd2c30c9479b74ed243722bca36846f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 16 22:56:11 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e2293d1c
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..ed5766d 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -31,6 +31,15 @@ valid_config_file_values.extend([ "distcc", "envscript",
"compression_mode", "compressor_options", "decompressor_search_order",
])
+# set our base defaults here to keep
+# them in one location.
+BASE_GENTOO_DIR = "/var/gentoo"
+REPODIR = BASE_GENTOO_DIR + "/repos"
+DISTDIR = BASE_GENTOO_DIR + "/distfiles"
+PKGDIR = BASE_GENTOO_DIR + "/packages"
+MAINREPO = "gentoo"
+PORTDIR = REPODIR + "/" + MAINREPO
+
confdefaults={
"archdir": "%(PythonDir)s/arch",
"comp_prog": COMPRESSOR_PROGRAM_OPTIONS[TAR],
@@ -39,28 +48,28 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": REPODIR[:] + "/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": REPODIR[:],
+ "repo_name": MAINREPO[:],
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
- "target_distdir": "/var/portage/distfiles",
- "target_pkgdir":"/var/portage/packages",
+ "target_distdir": DISTDIR[:],
+ "target_pkgdir": PKGDIR[:],
}
DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
@@ -72,11 +81,11 @@ TARGET_MOUNT_DEFAULTS = {
"ccache": "/var/tmp/ccache",
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +95,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": DISTDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-16 22:57 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-16 22:57 UTC (permalink / raw
To: gentoo-commits
commit: e5a53e42022668563965ede6409a3de233af332c
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 6 20:32:03 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Mar 11 22:01:27 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e5a53e42
catalyst: create namespaces for building
This helps isolate the catalyst builds from the rest of the system
and allows us to build as non-root user in more cases.
We don't support pid or user namespaces yet.
catalyst/main.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/catalyst/main.py b/catalyst/main.py
index 51d2b04..b8ae662 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -12,6 +12,7 @@ import os
import sys
from snakeoil import process
+from snakeoil.process import namespaces
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
@@ -421,6 +422,14 @@ def _main(parser, opts):
# catalyst cannot be run as a normal user due to chroots, mounts, etc
log.critical('This script requires root privileges to operate')
+ # Start off by creating unique namespaces to run in. Would be nice to
+ # use pid & user namespaces, but snakeoil's namespace module has signal
+ # transfer issues (CTRL+C doesn't propagate), and user namespaces need
+ # more work due to Gentoo build process (uses sudo/root/portage).
+ namespaces.simple_unshare(
+ mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
+ hostname='catalyst')
+
# everything is setup, so the build is a go
try:
success = build_target(addlargs)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-11 9:35 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-11 9:35 UTC (permalink / raw
To: gentoo-commits
commit: 858e2f609360fbc676e2e98931908e2e48710253
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Mar 11 09:00:37 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=858e2f60
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..ed5766d 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -31,6 +31,15 @@ valid_config_file_values.extend([ "distcc", "envscript",
"compression_mode", "compressor_options", "decompressor_search_order",
])
+# set our base defaults here to keep
+# them in one location.
+BASE_GENTOO_DIR = "/var/gentoo"
+REPODIR = BASE_GENTOO_DIR + "/repos"
+DISTDIR = BASE_GENTOO_DIR + "/distfiles"
+PKGDIR = BASE_GENTOO_DIR + "/packages"
+MAINREPO = "gentoo"
+PORTDIR = REPODIR + "/" + MAINREPO
+
confdefaults={
"archdir": "%(PythonDir)s/arch",
"comp_prog": COMPRESSOR_PROGRAM_OPTIONS[TAR],
@@ -39,28 +48,28 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": REPODIR[:] + "/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": REPODIR[:],
+ "repo_name": MAINREPO[:],
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
- "target_distdir": "/var/portage/distfiles",
- "target_pkgdir":"/var/portage/packages",
+ "target_distdir": DISTDIR[:],
+ "target_pkgdir": PKGDIR[:],
}
DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
@@ -72,11 +81,11 @@ TARGET_MOUNT_DEFAULTS = {
"ccache": "/var/tmp/ccache",
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR[:],
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +95,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": DISTDIR[:],
+ "portdir": PORTDIR[:],
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-11 7:07 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-11 7:07 UTC (permalink / raw
To: gentoo-commits
commit: 178a8b859c8d3e885669a39219edefc1ebb55318
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Mar 11 04:43:28 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=178a8b85
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..d6b9243 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -31,6 +31,15 @@ valid_config_file_values.extend([ "distcc", "envscript",
"compression_mode", "compressor_options", "decompressor_search_order",
])
+# set our base defaults here to keep
+# them in one location.
+BASE_GENTOO_DIR = "/var/gentoo"
+REPODIR = BASE_GENTOO_DIR + "/repos"
+DISTDIR = BASE_GENTOO_DIR + "/distfiles"
+PKGDIR = BASE_GENTOO_DIR + "/packages"
+MAINREPO = "gentoo"
+PORTDIR = REPODIR + "/" + MAINREPO
+
confdefaults={
"archdir": "%(PythonDir)s/arch",
"comp_prog": COMPRESSOR_PROGRAM_OPTIONS[TAR],
@@ -39,28 +48,28 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR,
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": REPODIR + "/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR,
+ "portdir": PORTDIR,
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": REPODIR,
+ "repo_name": "gentoo",
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
- "target_distdir": "/var/portage/distfiles",
- "target_pkgdir":"/var/portage/packages",
+ "target_distdir": DISTDIR,
+ "target_pkgdir": PKGDIR,
}
DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
@@ -72,11 +81,11 @@ TARGET_MOUNT_DEFAULTS = {
"ccache": "/var/tmp/ccache",
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
+ "distdir": DISTDIR,
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": PKGDIR,
+ "portdir": PORTDIR,
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +95,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": DISTDIR,
+ "portdir": PORTDIR,
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-10 18:38 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-10 18:38 UTC (permalink / raw
To: gentoo-commits
commit: 926c42c264e2fdb2987e145ae848fccfaa51be39
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Mar 10 18:37:41 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=926c42c2
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..947e236 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -39,24 +39,24 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": "/var/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": "/var/portage/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": "/var/portage/repos",
+ "repo_name": "gentoo",
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
"target_distdir": "/var/portage/distfiles",
@@ -75,8 +75,8 @@ TARGET_MOUNT_DEFAULTS = {
"distdir": "/usr/portage/distfiles",
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +86,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": "/var/portage/distfiles",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-09 10:02 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-09 10:02 UTC (permalink / raw
To: gentoo-commits
commit: c4cc183eb75f28596a936526cb8af46ac0c10c78
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 9 09:59:40 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c4cc183e
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..947e236 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -39,24 +39,24 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": "/var/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": "/var/portage/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": "/var/portage/repos",
+ "repo_name": "gentoo",
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
"target_distdir": "/var/portage/distfiles",
@@ -75,8 +75,8 @@ TARGET_MOUNT_DEFAULTS = {
"distdir": "/usr/portage/distfiles",
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +86,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": "/var/portage/distfiles",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2017-03-09 9:39 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2017-03-09 9:39 UTC (permalink / raw
To: gentoo-commits
commit: d56584f32de50a1b2840bafb712656011d5ee2b3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:24:22 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 9 09:35:53 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d56584f3
defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths
All settings are still configurable in catalyst.conf.
These are new reasonable settings for a relocated tree system.
A user can still set their own locations during install, or at a later time.
Default catalyst.conf settings will be changed at a later time after additional testing and
the automatic stage building scripts have been updated.
catalyst/defaults.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 84ed282..947e236 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -39,24 +39,24 @@ confdefaults={
"compressor_options": XATTRS_OPTIONS[TAR],
"decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
- "distdir": "/usr/portage/distfiles",
+ "distdir": "/var/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
- "local_overlay": "/usr/local/portage",
+ "local_overlay": "/var/portage/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
"options": set(),
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"PythonDir": "./catalyst",
- "repo_basedir": "/usr",
- "repo_name": "portage",
+ "repo_basedir": "/var/portage/repos",
+ "repo_name": "gentoo",
"sharedir": "/usr/share/catalyst",
"shdir": "/usr/share/catalyst/targets/",
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "snapshot_name": "portage-",
+ "snapshot_name": "%(repo_name)s-",
"source_matching": "strict",
"storedir": "/var/tmp/catalyst",
"target_distdir": "/var/portage/distfiles",
@@ -75,8 +75,8 @@ TARGET_MOUNT_DEFAULTS = {
"distdir": "/usr/portage/distfiles",
"icecream": "/usr/lib/icecc/bin",
"kerncache": "/tmp/kerncache",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
+ "packagedir": "/var/portage/packages",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
@@ -86,8 +86,8 @@ TARGET_MOUNT_DEFAULTS = {
SOURCE_MOUNT_DEFAULTS = {
"dev": "/dev",
"devpts": "/dev/pts",
- "distdir": "/usr/portage/distfiles",
- "portdir": "/usr/portage",
+ "distdir": "/var/portage/distfiles",
+ "portdir": "/var/portage/repos",
"port_tmpdir": "tmpfs",
"proc": "/proc",
"shm": "shmfs",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: 426c2f17a3bc6f22a7397854964ec5ba7a33f96d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 9 02:04:04 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Nov 9 02:04:04 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=426c2f17
support.py: Make file_check restrict it's short test to os.path.isfile()
This avoids seedcache being disabled but having a directory of the same name as the seed it is looking for.
catalyst/support.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 380c1c1..4bf1b22 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -59,7 +59,7 @@ def file_check(filepath):
'''Check for the files existence and that only one exists
if others are found with various extensions
'''
- if os.path.exists(filepath):
+ if os.path.isfile(filepath):
return filepath
# it didn't exist
# so check if there are files of that name with an extension
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: 1cb701ee64e06badb16a0086bb4e46184633c5da
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:27:46 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 00:27:46 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1cb701ee
config: tweak walking of settings for py3
Since py3 returns an iterator with dict.keys(), trying to add/del values
in the loop will throw an exception. Run it through list() so we get a
static copy to iterate over.
catalyst/config.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index db81a96..5f72e15 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -97,7 +97,8 @@ class ParserBase(object):
values[cur_array[0]] = cur_array[1:]
if not self.empty_values:
- for x in values.keys():
+ # Make sure the list of keys is static since we modify inside the loop.
+ for x in list(values.keys()):
# Delete empty key pairs
if not values[x]:
log.warning('No value set for key "%s"; deleting', x)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: d307242bf41554640a8966d79f6f36738d3391ee
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 27 05:51:52 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 16:49:56 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d307242b
main: extend the -c option to accept multiple files
There's no real reason people can't load multiple config files, so extend
the --config option into --configs and let people specify multiple ones.
catalyst/defaults.py | 2 ++
catalyst/main.py | 55 +++++++++++++++++-----------------------------------
2 files changed, 20 insertions(+), 37 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 666afca..c5162d6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -46,6 +46,8 @@ confdefaults={
"storedir": "/var/tmp/catalyst",
}
+DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
+
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
diff --git a/catalyst/main.py b/catalyst/main.py
index 9f563cf..176871d 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,7 @@ from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
-from catalyst.defaults import confdefaults, option_messages
+from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE
from catalyst.hash_utils import HashMap, HASH_DEFINITIONS
from catalyst.support import CatalystError
from catalyst.version import get_version
@@ -36,40 +36,19 @@ def version():
log.info('Copyright 2008-2012 various authors')
log.info('Distributed under the GNU General Public License version 2.1')
-def parse_config(myconfig):
+def parse_config(config_files):
# search a couple of different areas for the main config file
myconf={}
- config_file=""
- default_config_file = '/etc/catalyst/catalyst.conf'
- # first, try the one passed (presumably from the cmdline)
- if myconfig:
- if os.path.exists(myconfig):
- log.notice('Using command line specified Catalyst configuration file: %s',
- myconfig)
- config_file=myconfig
-
- else:
- log.critical('Specified configuration file does not exist: %s', myconfig)
-
- # next, try the default location
- elif os.path.exists(default_config_file):
- log.notice('Using default Catalyst configuration file: %s',
- default_config_file)
- config_file = default_config_file
-
- # can't find a config file (we are screwed), so bail out
- else:
- log.critical('Could not find a suitable configuration file')
-
- # now, try and parse the config file "config_file"
- try:
-# execfile(config_file, myconf, myconf)
- myconfig = catalyst.config.ConfigParser(config_file)
- myconf.update(myconfig.get_values())
-
- except Exception:
- log.critical('Could not find parse configuration file: %s', myconfig)
+ # try and parse the config file "config_file"
+ for config_file in config_files:
+ log.notice('Loading configuration file: %s', config_file)
+ try:
+ config = catalyst.config.ConfigParser(config_file)
+ myconf.update(config.get_values())
+ except Exception as e:
+ log.critical('Could not find parse configuration file: %s: %s',
+ config_file, e)
# now, load up the values into conf_values so that we can use them
for x in list(confdefaults):
@@ -209,9 +188,9 @@ $ catalyst -f stage1-specfile.spec"""
group.add_argument('-F', '--fetchonly',
default=False, action='store_true',
help='fetch files only')
- group.add_argument('-c', '--config',
- type=FilePath(),
- help='use specified configuration file')
+ group.add_argument('-c', '--configs',
+ type=FilePath(), action='append',
+ help='use specified configuration files')
group.add_argument('-f', '--file',
type=FilePath(),
help='read specfile')
@@ -241,7 +220,9 @@ def main():
color=opts.color)
# Parse the command line options.
- myconfig = opts.config
+ myconfigs = opts.configs
+ if not myconfigs:
+ myconfigs = [DEFAULT_CONFIG_FILE]
myspecfile = opts.file
mycmdline = opts.cli[:]
@@ -271,7 +252,7 @@ def main():
# made it this far so start by outputting our version info
version()
# import configuration file and import our main module using those settings
- parse_config(myconfig)
+ parse_config(myconfigs)
conf_values["options"].update(options)
log.debug('conf_values[options] = %s', conf_values['options'])
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: f3eea23c5cf7cf4e54073f59796a25db17d18613
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 12 02:17:26 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Oct 12 02:17:26 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f3eea23c
log: make sure NOTICE is an int
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')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: 328650032448425d64ec186fe24d84930f95d037
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 12 03:28:59 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 16:49:56 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=32865003
hash_utils: decode output of popen
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()
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-11-21 1:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-11-21 1:33 UTC (permalink / raw
To: gentoo-commits
commit: ac0f1d1f61ed3ec00831867f2a34eea88e7160ec
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 12 03:06:02 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Oct 12 03:06:02 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ac0f1d1f
hash_utils: fix bad keyword w/CatalystError
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_):
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-08 14:14 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-08 14:14 UTC (permalink / raw
To: gentoo-commits
commit: ce64d85fdd92920cae60cd93039f6cae35de51ad
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 8 06:13:30 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 8 14:11:48 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ce64d85f
main.py: Add an exception for CatalystError which would have been already handled
Cleanup some dead code.
catalyst/main.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index dc9342b..2a5bdd3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,13 +163,10 @@ def build_target(addlargs):
raise CatalystError(
"Target \"%s\" not available." % target,
print_traceback=True)
-
- #try:
+ except CatalystError:
+ return
target.run()
- #except:
- #print "!!! catalyst: Error encountered during run of target " + \
- # addlargs["target"]
- #sys.exit(1)
+
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2015-09-06 21:21 Brian Dolbec
2015-09-06 21:18 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-09-06 21:21 UTC (permalink / raw
To: gentoo-commits
commit: 8ebde1b8598e34caa83f8bcae6185ee4f6e38264
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 21:18:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8ebde1b8
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 0ba81b9..7e3b55e 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,12 +163,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2015-09-06 21:21 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2015-09-06 21:18 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-06 21:18 UTC (permalink / raw
To: gentoo-commits
commit: 8ebde1b8598e34caa83f8bcae6185ee4f6e38264
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 21:18:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8ebde1b8
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 0ba81b9..7e3b55e 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,12 +163,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-06 21:18 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-06 21:18 UTC (permalink / raw
To: gentoo-commits
commit: 1039b4beef11da6dfd8d54b1ab3724b1e817bcdf
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 5 16:23:30 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 21:18:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1039b4be
defaults.py: Update for the new xattr variations of the definitions
This should allow to not define the decompressor_search_order in the spec file.
catalyst/defaults.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5ce2858..5db7ab6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -1,5 +1,8 @@
+from DeComp.definitions import DECOMPRESSOR_XATTR_SEARCH_ORDER
+
+
# these should never be touched
required_build_targets = ["targetbase", "generic_stage_target"]
@@ -23,8 +26,8 @@ verbosity = 1
confdefaults={
"archdir": "%(PythonDir)s/arch",
- "compression_mode": 'lbzip2',
- "decompressor_search_order": 'lbzip2 bzip2 tar pixz xz gzip squashfs',
+ "compression_mode": 'lbzip2_x',
+ "decompressor_search_order": DECOMPRESSOR_XATTR_SEARCH_ORDER,
"distdir": "/usr/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-06 20:33 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-06 20:33 UTC (permalink / raw
To: gentoo-commits
commit: b5f83751008c8f3757841b9bff59a02af1ac0ce1
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 5 16:23:30 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 20:22:44 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b5f83751
defaults.py: Update for the new xattr variations of the definitions
This should allow to not define the decompressor_search_order in the spec file.
catalyst/defaults.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5ce2858..5db7ab6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -1,5 +1,8 @@
+from DeComp.definitions import DECOMPRESSOR_XATTR_SEARCH_ORDER
+
+
# these should never be touched
required_build_targets = ["targetbase", "generic_stage_target"]
@@ -23,8 +26,8 @@ verbosity = 1
confdefaults={
"archdir": "%(PythonDir)s/arch",
- "compression_mode": 'lbzip2',
- "decompressor_search_order": 'lbzip2 bzip2 tar pixz xz gzip squashfs',
+ "compression_mode": 'lbzip2_x',
+ "decompressor_search_order": DECOMPRESSOR_XATTR_SEARCH_ORDER,
"distdir": "/usr/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-05 16:24 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-05 16:24 UTC (permalink / raw
To: gentoo-commits
commit: 42d2c23f979b9f2ca2b96fbe87cbbc561691f751
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 5 16:23:30 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 16:23:30 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=42d2c23f
defaults.py: Update for the new xattr variations of the definitions
This should allow to not define the decompressor_search_order in the spec file.
catalyst/defaults.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5ce2858..5af60a9 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -1,5 +1,8 @@
+from DeComp.definitions import DECOMPRESSOR_XATTR_SEARCH_ORDER
+
+
# these should never be touched
required_build_targets = ["targetbase", "generic_stage_target"]
@@ -24,7 +27,7 @@ verbosity = 1
confdefaults={
"archdir": "%(PythonDir)s/arch",
"compression_mode": 'lbzip2',
- "decompressor_search_order": 'lbzip2 bzip2 tar pixz xz gzip squashfs',
+ "decompressor_search_order": DECOMPRESSOR_XATTR_SEARCH_ORDER,
"distdir": "/usr/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-04 15:20 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-04 15:20 UTC (permalink / raw
To: gentoo-commits
commit: 524debef567a28fdf9506c8bb1d9818599c48204
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Sep 4 15:19:57 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=524debef
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 0ba81b9..7e3b55e 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,12 +163,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-03 15:14 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-03 15:14 UTC (permalink / raw
To: gentoo-commits
commit: 6428baba7e9f7aa6fc4ede457804adbe793c3ac4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Sep 3 15:09:02 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6428baba
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 0ba81b9..7e3b55e 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,12 +163,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-01 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 8035e2073b3bb7ca3125627a9671b63239f0537f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 1 04:39:38 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 04:40:55 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8035e207
fileops.py: Fix a bug where the mode was not being passed
Change the default mode to 0o755
catalyst/fileops.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index fd98db2..129d967 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -21,7 +21,7 @@ from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs,
from catalyst.support import CatalystError
-def ensure_dirs(path, gid=-1, uid=-1, mode=0777, minimal=True,
+def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True,
failback=None, fatal=False):
'''Wrapper to snakeoil.osutil's ensure_dirs()
This additionally allows for failures to run
@@ -40,7 +40,7 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0777, minimal=True,
:return: True if the directory could be created/ensured to have those
permissions, False if not.
'''
- succeeded = snakeoil_ensure_dirs(path, gid=-1, uid=-1, mode=0777, minimal=True)
+ succeeded = snakeoil_ensure_dirs(path, gid=-1, uid=-1, mode=mode, minimal=True)
if not succeeded:
if failback:
failback()
@@ -50,7 +50,7 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0777, minimal=True,
return succeeded
-def clear_dir(target, mode=0755, chg_flags=False, remove=False):
+def clear_dir(target, mode=0o755, chg_flags=False, remove=False):
'''Universal directory clearing function
@target: string, path to be cleared or removed
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-01 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 7795237bfce897bf0b2f9531c902c72adb87907d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 05:54:11 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7795237b
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 0ba81b9..7e3b55e 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,12 +163,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-09-01 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: f499da75fe51ed8ae2830a20fef5a27bce633173
Author: Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 31 03:15:50 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug 31 03:15:50 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f499da75
Revert "catalyst/main.py: Fix variables not being substituted with correct values"
This reverts commit 4328dcd693ae02a77c519e5186e5430171c16ac5.
Reverting due to :
Envscript support enabled.
Traceback (most recent call last):
File "/usr/lib/python-exec/python2.7/catalyst", line 39, in <module>
main()
File "/usr/lib64/python2.7/site-packages/catalyst/main.py", line 343, in main
build_target(addlargs)
File "/usr/lib64/python2.7/site-packages/catalyst/main.py", line 158, in build_target
target = getattr(module, target)(conf_values, addlargs)
File "/usr/lib64/python2.7/site-packages/catalyst/targets/stage1.py", line 21, in __init__
StageBase.__init__(self,spec,addlargs)
File "/usr/lib64/python2.7/site-packages/catalyst/base/stagebase.py", line 72, in __init__
for x in [x[:-3] for x in os.listdir(arch_dir) if x.endswith(".py") and x != "__init__.py"]:
OSError: [Errno 2] No such file or directory: './catalyst/arch/'
catalyst/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 2335495..a222209 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -107,8 +107,8 @@ def parse_config(myconfig):
else:
conf_values[x]=myconf[x]
else:
- conf_values[x] = confdefaults[x] % confdefaults
- print "Setting",x,"to default value \"" + conf_values[x] + "\""
+ print "Setting",x,"to default value \""+confdefaults[x]+"\""
+ conf_values[x]=confdefaults[x]
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2015-09-01 4:50 Brian Dolbec
2015-09-01 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 4:50 UTC (permalink / raw
To: gentoo-commits
commit: b0e860c4b5c218729d344a821814071b4392ed61
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 1 04:48:45 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 04:49:39 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b0e860c4
main.py: Add 'local_overlay' to the overridable defaults in the catalyst.conf file
catalyst/main.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index dd3c517..3ab4166 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,8 @@ def parse_config(myconfig):
if opt in option_messages:
print option_messages[opt]
- for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir"]:
+ for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
+ "local_overlay"]:
if key in myconf:
conf_values[key] = myconf[key]
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2015-09-01 4:50 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2015-09-01 5:58 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: b0e860c4b5c218729d344a821814071b4392ed61
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 1 04:48:45 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 1 04:49:39 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b0e860c4
main.py: Add 'local_overlay' to the overridable defaults in the catalyst.conf file
catalyst/main.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index dd3c517..3ab4166 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,8 @@ def parse_config(myconfig):
if opt in option_messages:
print option_messages[opt]
- for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir"]:
+ for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
+ "local_overlay"]:
if key in myconf:
conf_values[key] = myconf[key]
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2015-08-30 20:58 Brian Dolbec
2015-09-01 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-08-30 20:58 UTC (permalink / raw
To: gentoo-commits
commit: 4328dcd693ae02a77c519e5186e5430171c16ac5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 30 20:55:52 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Aug 30 20:56:09 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4328dcd6
catalyst/main.py: Fix variables not being substituted with correct values
catalyst/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index a222209..2335495 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -107,8 +107,8 @@ def parse_config(myconfig):
else:
conf_values[x]=myconf[x]
else:
- print "Setting",x,"to default value \""+confdefaults[x]+"\""
- conf_values[x]=confdefaults[x]
+ conf_values[x] = confdefaults[x] % confdefaults
+ print "Setting",x,"to default value \"" + conf_values[x] + "\""
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2015-08-30 20:58 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2015-09-01 5:58 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-09-01 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 4328dcd693ae02a77c519e5186e5430171c16ac5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 30 20:55:52 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Aug 30 20:56:09 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4328dcd6
catalyst/main.py: Fix variables not being substituted with correct values
catalyst/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index a222209..2335495 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -107,8 +107,8 @@ def parse_config(myconfig):
else:
conf_values[x]=myconf[x]
else:
- print "Setting",x,"to default value \""+confdefaults[x]+"\""
- conf_values[x]=confdefaults[x]
+ conf_values[x] = confdefaults[x] % confdefaults
+ print "Setting",x,"to default value \"" + conf_values[x] + "\""
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-06-15 20:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-06-15 20:25 UTC (permalink / raw
To: gentoo-commits
commit: 13b3075b46020847b077b8efe797075b6ecceaf4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:38:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun May 24 16:32:53 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=13b3075b
catalyst/main.py: Comment out the try: except: pair for target.run()
catalyst/main.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 35a4edc..b498f11 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -164,12 +164,12 @@ def build_target(addlargs):
"Target \"%s\" not available." % target,
print_traceback=True)
- try:
- target.run()
- except:
- print "!!! catalyst: Error encountered during run of target " + \
- addlargs["target"]
- sys.exit(1)
+ #try:
+ target.run()
+ #except:
+ #print "!!! catalyst: Error encountered during run of target " + \
+ # addlargs["target"]
+ #sys.exit(1)
def main():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2015-05-24 0:08 Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-05-24 0:08 UTC (permalink / raw
To: gentoo-commits
commit: 24ec1400aa8c1b9aedae9a498e172d63cfe3705d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 28 03:58:10 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu May 21 15:28:18 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=24ec1400
catalyst/support.py: Fix some leading whitespace rebase errors
Change a CatalystError to not print a traceback.
catalyst/support.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 7957f08..2ac4816 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -152,17 +152,17 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError("File variable \"" + myfile +
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
"\" has a length of zero (not specified.)", print_traceback=True)
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError("Cannot locate specified " + myfile +
- ": "+settings[myfile], print_traceback=True)
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError("Cannot locate specified " + myfile +
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": " + settings[myfile], print_traceback=False)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2015-05-24 0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2015-05-21 23:53 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-05-21 23:53 UTC (permalink / raw
To: gentoo-commits
commit: 24ec1400aa8c1b9aedae9a498e172d63cfe3705d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 28 03:58:10 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu May 21 15:28:18 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=24ec1400
catalyst/support.py: Fix some leading whitespace rebase errors
Change a CatalystError to not print a traceback.
catalyst/support.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 7957f08..2ac4816 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -152,17 +152,17 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError("File variable \"" + myfile +
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
"\" has a length of zero (not specified.)", print_traceback=True)
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError("Cannot locate specified " + myfile +
- ": "+settings[myfile], print_traceback=True)
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError("Cannot locate specified " + myfile +
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": " + settings[myfile], print_traceback=False)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-02-26 20:44 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-02-26 20:44 UTC (permalink / raw
To: gentoo-commits
commit: 5a09558cbbeca6fda075525103a43d44e5cd5871
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 12 04:07:08 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Feb 26 19:57:22 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5a09558c
main.py, lock.py, fileops.py remove shebangs
---
catalyst/fileops.py | 1 -
catalyst/lock.py | 3 ++-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 009bf1c..e3a4ead 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Maintained in full by:
# Catalyst Team <catalyst@gentoo.org>
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 12d0754..a6f9d3a 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -1,4 +1,5 @@
-#!/usr/bin/python
+
+
import os
import fcntl
import errno
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-02-26 20:44 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-02-26 20:44 UTC (permalink / raw
To: gentoo-commits
commit: 83c4337f59102245d6018810db5bb79f471b002f
Author: W. Trevor King <wking <AT> tremily <DOT> us>
AuthorDate: Tue Jun 11 21:41:18 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Feb 26 19:56:51 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=83c4337f
version: Remove shebang (Python modules are not scripts)
Nobody should be executing this file directly.
---
catalyst/version.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/catalyst/version.py b/catalyst/version.py
index 03c77e4..ea12761 100644
--- a/catalyst/version.py
+++ b/catalyst/version.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python -OO
-
# Maintained in full by:
# Catalyst Team <catalyst@gentoo.org>
# Release Engineering Team <releng@gentoo.org>
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-02-26 19:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-02-26 19:25 UTC (permalink / raw
To: gentoo-commits
commit: 32df09409b29b93bb89f930452a4f0ad52e8fcc5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 11 16:07:03 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Feb 26 19:15:21 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=32df0940
fix '-' in stage names for python imports
---
catalyst/main.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index ae0abae..fc1681c 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -153,11 +153,12 @@ def import_module(target):
def build_target(addlargs):
try:
- module = import_module(addlargs["target"])
- target = getattr(module, addlargs["target"])(conf_values, addlargs)
+ target = addlargs["target"].replace('-', '_')
+ module = import_module(target)
+ target = getattr(module, target)(conf_values, addlargs)
except AttributeError:
raise CatalystError(
- "Target \"%s\" not available." % addlargs["target"],
+ "Target \"%s\" not available." % target,
print_traceback=True)
try:
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2015-02-26 4:12 Brian Dolbec
2015-01-01 5:59 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2015-02-26 4:12 UTC (permalink / raw
To: gentoo-commits
commit: 9944ba53ababcf245d75f5d9c9efce07a4753033
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:06 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=9944ba53
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2015-02-26 4:12 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2015-01-01 5:59 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: 9944ba53ababcf245d75f5d9c9efce07a4753033
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:06 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=9944ba53
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-01-01 5:59 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: fa577bb409c36c3b38a90f65cb7a665c5474d2c9
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:06 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=fa577bb4
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-01-01 5:59 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: 89beddf2ccfb320bac1f8d5b2e5964bf4890ac78
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu May 30 19:34:06 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:07 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=89beddf2
Migrate version to use snakeoil's format_version() to append git commit info.
This will make tagging releases easy as well as providing better debug info while running live versions of the software.
---
catalyst/main.py | 11 +++++++----
catalyst/version.py | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 7fea4e7..ae0abae 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -14,7 +14,6 @@ import os.path
__selfpath__ = os.path.abspath(os.path.dirname(__file__))
-from . import __version__
import catalyst.config
import catalyst.util
from catalyst.contents import ContentsMap, CONTENTS_DEFINITIONS
@@ -22,6 +21,7 @@ from catalyst.defaults import confdefaults, option_messages
from catalyst.hash_utils import HashMap, HASH_DEFINITIONS
from catalyst.lock import LockInUse
from catalyst.support import CatalystError, find_binary
+from catalyst.version import get_version
conf_values={}
@@ -57,7 +57,7 @@ catalyst -f stage1-specfile.spec
def version():
- print "Catalyst, version "+__version__
+ print get_version()
print "Copyright 2003-2008 Gentoo Foundation"
print "Copyright 2008-2012 various authors"
print "Distributed under the GNU General Public License version 2.1\n"
@@ -169,8 +169,8 @@ def build_target(addlargs):
def main():
- version()
if os.getuid() != 0:
+ version()
# catalyst cannot be run as a normal user due to chroots, mounts, etc
print "!!! catalyst: This script requires root privileges to operate"
sys.exit(2)
@@ -204,11 +204,12 @@ def main():
run = False
for o, a in opts:
if o in ("-h", "--help"):
+ version()
usage()
sys.exit(1)
if o in ("-V", "--version"):
- print "Catalyst version "+__version__
+ print get_version()
sys.exit(1)
if o in ("-d", "--debug"):
@@ -264,6 +265,8 @@ def main():
usage()
sys.exit(2)
+ # made it this far so start by outputting our version info
+ version()
# import configuration file and import our main module using those settings
parse_config(myconfig)
diff --git a/catalyst/version.py b/catalyst/version.py
new file mode 100644
index 0000000..03c77e4
--- /dev/null
+++ b/catalyst/version.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python -OO
+
+# Maintained in full by:
+# Catalyst Team <catalyst@gentoo.org>
+# Release Engineering Team <releng@gentoo.org>
+# Copyright: 2011 Brian Harring <ferringb@gmail.com>
+# License: BSD/GPL2
+# Copied & edited by: Brian Dolbec <dolsen@gentoo.org>
+
+'''Version information and/or git version information
+'''
+
+from snakeoil.version import format_version
+
+__version__="rewrite-git"
+_ver = None
+
+def get_version():
+ """Return: a string describing our version."""
+ global _ver
+ if _ver is None:
+ _ver = format_version('catalyst',__file__, __version__)
+ return _ver
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-01-01 5:59 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: 0b3a26d733ea8e8b3fce044be1d2c872138d74d5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:05 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0b3a26d7
Some spacing, comment and indent cleanup
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..e2d64a1 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)")
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile])
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ )
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-01-01 5:59 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: c9f2dd369d57ab4b963753de125fbcad3e3582fc
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:06 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c9f2dd36
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2015-01-01 5:59 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2015-01-01 5:59 UTC (permalink / raw
To: gentoo-commits
commit: cd9ed84add5379f07f46faea102f24ec51754f54
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:05 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=cd9ed84a
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 55 ++++++++++++++++++++++++++++++-----------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..78968cb 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError, normpath
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -415,15 +429,8 @@ if __name__ == "__main__":
print i,time.time()
time.sleep(1)
print
- def normpath(mypath):
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[1] == "/":
- newpath = "/"+newpath.lstrip("/")
- return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2014-09-11 3:26 Brian Dolbec
2014-06-14 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:26 UTC (permalink / raw
To: gentoo-commits
commit: c43de87222e118738e21afe8ea0cfafb866c7044
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 12 02:54:40 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 03:57:22 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c43de872
Remove unused variable new and an undefined variable s.
Commit b3475906d5f51a21ecaf4ff048002a2f44face52 introduced an
undefined variable "s". The code must always be hitting the
general except: pass block. Seems useless, if not maybe it'll
spit out a true error, so the real problem can be fixed. Removed it all.
---
catalyst/support.py | 8 --------
1 file changed, 8 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index bc24130..d5dbfec 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -292,15 +292,7 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if trg_fd[x] == src_fd[x]:
continue
if trg_fd[x] in src_fd[x+1:]:
- new=os.dup2(trg_fd[x],max(src_fd) + 1)
os.close(trg_fd[x])
- try:
- while True:
- src_fd[s.index(trg_fd[x])]=new
- except SystemExit, e:
- raise
- except:
- pass
# transfer the fds to their final pre-exec position.
for x in range(0,len(trg_fd)):
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2014-09-11 3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-06-14 5:58 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: c43de87222e118738e21afe8ea0cfafb866c7044
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 12 02:54:40 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 03:57:22 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c43de872
Remove unused variable new and an undefined variable s.
Commit b3475906d5f51a21ecaf4ff048002a2f44face52 introduced an
undefined variable "s". The code must always be hitting the
general except: pass block. Seems useless, if not maybe it'll
spit out a true error, so the real problem can be fixed. Removed it all.
---
catalyst/support.py | 8 --------
1 file changed, 8 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index bc24130..d5dbfec 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -292,15 +292,7 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if trg_fd[x] == src_fd[x]:
continue
if trg_fd[x] in src_fd[x+1:]:
- new=os.dup2(trg_fd[x],max(src_fd) + 1)
os.close(trg_fd[x])
- try:
- while True:
- src_fd[s.index(trg_fd[x])]=new
- except SystemExit, e:
- raise
- except:
- pass
# transfer the fds to their final pre-exec position.
for x in range(0,len(trg_fd)):
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2014-09-11 3:26 Brian Dolbec
2014-06-14 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:26 UTC (permalink / raw
To: gentoo-commits
commit: c71831578f53d2551cd845b25bee3aaee3baa6f4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 12 02:49:19 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 03:51:36 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c7183157
Remove unused urllib import.
This urllib import was added in commit 64c16cae70da13de3c55d8555a2e4c5dcdf2fcad
to fix an issue, but it is not used. So must have covered up the real bug. Removing it now
that I've completed some testing and haven't come across anything I can attribute to it.
---
catalyst/support.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 4fe4603..bc24130 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -23,10 +23,6 @@ except:
# pids this process knows of.
spawned_pids = []
-try:
- import urllib
-except SystemExit, e:
- raise
def cleanup(pids,block_exceptions=True):
"""function to go through and reap the list of pids passed to it"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2014-09-11 3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-06-14 5:58 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: c71831578f53d2551cd845b25bee3aaee3baa6f4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 12 02:49:19 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 03:51:36 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c7183157
Remove unused urllib import.
This urllib import was added in commit 64c16cae70da13de3c55d8555a2e4c5dcdf2fcad
to fix an issue, but it is not used. So must have covered up the real bug. Removing it now
that I've completed some testing and haven't come across anything I can attribute to it.
---
catalyst/support.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 4fe4603..bc24130 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -23,10 +23,6 @@ except:
# pids this process knows of.
spawned_pids = []
-try:
- import urllib
-except SystemExit, e:
- raise
def cleanup(pids,block_exceptions=True):
"""function to go through and reap the list of pids passed to it"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-11 3:08 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:08 UTC (permalink / raw
To: gentoo-commits
commit: 4d0b5107e1706e9db1f35f658ef0a1967711ec8e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 03:05:38 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=4d0b5107
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-11 3:08 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:08 UTC (permalink / raw
To: gentoo-commits
commit: 7f6fb5c8d8aac060e7ddb933d9c780bc99ace451
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 03:05:37 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=7f6fb5c8
Some spacing, comment and indent cleanup
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..e2d64a1 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)")
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile])
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ )
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-11 3:08 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:08 UTC (permalink / raw
To: gentoo-commits
commit: 05ba439bd5b3a0a772bd066e567e55324dc4a5c3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 03:05:38 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=05ba439b
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-11 3:08 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:08 UTC (permalink / raw
To: gentoo-commits
commit: e2e9efab8cefd782e98bec3ca07cd70e7d8a8477
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 03:05:38 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=e2e9efab
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-11 3:08 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-11 3:08 UTC (permalink / raw
To: gentoo-commits
commit: 30f9d3df9a2b630ad660a3a4b1f47857a945afbf
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 03:05:37 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=30f9d3df
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 55 ++++++++++++++++++++++++++++++-----------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..78968cb 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError, normpath
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -415,15 +429,8 @@ if __name__ == "__main__":
print i,time.time()
time.sleep(1)
print
- def normpath(mypath):
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[1] == "/":
- newpath = "/"+newpath.lstrip("/")
- return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 23:10 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 23:10 UTC (permalink / raw
To: gentoo-commits
commit: e6bca8df21e61111bc6a4e77455a5385a06955f3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 23:08:03 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=e6bca8df
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 23:10 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 23:10 UTC (permalink / raw
To: gentoo-commits
commit: 4533d6d38ce5b77b2d2ed10748d4b63b006eac6c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 23:08:02 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=4533d6d3
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 23:10 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 23:10 UTC (permalink / raw
To: gentoo-commits
commit: 2b98b1ff9e1adb9585ad901f3d764a6834d2583f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 23:01:02 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=2b98b1ff
Some spacing, comment and indent cleanup
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 23:10 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 23:10 UTC (permalink / raw
To: gentoo-commits
commit: 18fe1169454bb33b6b8afd0c6dcfdfde3cdc5894
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 22:57:50 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=18fe1169
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 55 ++++++++++++++++++++++++++++++-----------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..78968cb 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError, normpath
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -415,15 +429,8 @@ if __name__ == "__main__":
print i,time.time()
time.sleep(1)
print
- def normpath(mypath):
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[1] == "/":
- newpath = "/"+newpath.lstrip("/")
- return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 23:10 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 23:10 UTC (permalink / raw
To: gentoo-commits
commit: d1a47aaeeaa9622eaec08d850d6493313910b9e0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 23:08:02 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=d1a47aae
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 7:12 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 7:12 UTC (permalink / raw
To: gentoo-commits
commit: eb5deeea82a55b5446d42722666d0e0d124f9a2d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 06:31:58 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=eb5deeea
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 7:12 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 7:12 UTC (permalink / raw
To: gentoo-commits
commit: ea259de3ccbc5c3cebc9e39b519666dace29511c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 06:31:59 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=ea259de3
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 7:12 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 7:12 UTC (permalink / raw
To: gentoo-commits
commit: 4b8c19bb8b3bc52892cc41eda22bccded5c98f56
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 06:31:59 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=4b8c19bb
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 7:12 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 7:12 UTC (permalink / raw
To: gentoo-commits
commit: 0702001a7ae397230e2ba3790bc30c0113ed5a80
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 06:31:58 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0702001a
Some spacing, comment and indent cleanup
Conflicts:
catalyst/support.py
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 5:54 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 5:54 UTC (permalink / raw
To: gentoo-commits
commit: a7b73e18baf1bad2384e886be257d3842218c78c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 05:51:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a7b73e18
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 5:54 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 5:54 UTC (permalink / raw
To: gentoo-commits
commit: 6f5f400d24c9a53c4e040f96154b1c139e443dc0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 05:51:55 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=6f5f400d
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 5:54 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 5:54 UTC (permalink / raw
To: gentoo-commits
commit: 020f84ef956905f751e0755216a8e9281562dd47
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 05:51:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=020f84ef
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 55 ++++++++++++++++++++++++++++++-----------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..78968cb 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError, normpath
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -415,15 +429,8 @@ if __name__ == "__main__":
print i,time.time()
time.sleep(1)
print
- def normpath(mypath):
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[1] == "/":
- newpath = "/"+newpath.lstrip("/")
- return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 5:54 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 5:54 UTC (permalink / raw
To: gentoo-commits
commit: f26eff57984166c7477158745302deade6990aaf
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 05:51:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=f26eff57
Some spacing, comment and indent cleanup
Conflicts:
catalyst/support.py
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 5:54 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 5:54 UTC (permalink / raw
To: gentoo-commits
commit: 0fe0dba72ce7aaaad4efa32bf8aa65a655253e65
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 05:51:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0fe0dba7
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 2:43 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 2:43 UTC (permalink / raw
To: gentoo-commits
commit: 99e1ff21cc544222c69eede96b30e627bec9d958
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 02:13:44 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=99e1ff21
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 2:43 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 2:43 UTC (permalink / raw
To: gentoo-commits
commit: 3bf097a6216e36e4d4a003734f8667e315867b32
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 02:13:44 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=3bf097a6
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 2:43 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 2:43 UTC (permalink / raw
To: gentoo-commits
commit: 0a803915e347d896a609fda9a3e3c0accb65295b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 02:13:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0a803915
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 55 ++++++++++++++++++++++++++++++-----------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..78968cb 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError, normpath
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -415,15 +429,8 @@ if __name__ == "__main__":
print i,time.time()
time.sleep(1)
print
- def normpath(mypath):
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[1] == "/":
- newpath = "/"+newpath.lstrip("/")
- return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 2:43 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 2:43 UTC (permalink / raw
To: gentoo-commits
commit: e5d99184aca601ae224a87112c5287a048985e60
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 02:13:44 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=e5d99184
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 78968cb..c90f5b8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-09-02 2:43 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-09-02 2:43 UTC (permalink / raw
To: gentoo-commits
commit: 29305bb4fa710c2a65b8fdba5cadcb85dab32363
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 2 02:13:43 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=29305bb4
some spacing and comment and indent cleanup, etc.
Conflicts:
catalyst/support.py
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-15 14:56 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-15 14:56 UTC (permalink / raw
To: gentoo-commits
commit: de34560691fc7f702538bfbfbdefafcfaeb5a0ef
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 14:05:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=de345606
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-15 14:56 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-15 14:56 UTC (permalink / raw
To: gentoo-commits
commit: 65ecc7daa279bd2230564494599d2a0608b91720
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 14:05:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=65ecc7da
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index ef00b49..d073861 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-15 14:56 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-15 14:56 UTC (permalink / raw
To: gentoo-commits
commit: 7d5aa7e604514d670d498f09e183cd9194529955
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 14:05:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=7d5aa7e6
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-15 14:56 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-15 14:56 UTC (permalink / raw
To: gentoo-commits
commit: d731435f4adeac15dd59ef9c7a17196468be4379
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 14:03:46 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=d731435f
some spacing and comment and indent cleanup, etc.
Conflicts:
catalyst/support.py
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-15 14:56 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-15 14:56 UTC (permalink / raw
To: gentoo-commits
commit: 1256ad85e2bc4f5e1ea4d15b917a6365a8cb5950
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 14:02:03 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=1256ad85
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 49 +++++++++++++++++++++++++++++++------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..ef00b49 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -423,7 +437,6 @@ if __name__ == "__main__":
return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 81d48b5..15664de 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (confdefaults, option_messages,
required_build_targets, valid_build_targets)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 752882a02214f07b7027b65535e6b4d0eaf6ba50
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 22 08:34:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 05:24:29 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=752882a0
FIXME! Comment out a small code block causing TypeError.
This was also short circuiting another large code block. FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:
---
catalyst/lock.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index ef00b49..d073861 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -27,11 +27,17 @@ class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
die_on_failed_lock=True
+
def __del__(self):
+ #print "Lock.__del__() 1"
self.clean_my_hardlocks()
+ #print "Lock.__del__() 2"
self.delete_lock_from_path_list()
+ #print "Lock.__del__() 3"
if self.islocked():
+ #print "Lock.__del__() 4"
self.fcntl_unlock()
+ #print "Lock.__del__() finnished"
def __init__(self,lockdir):
self.locked=False
@@ -179,7 +185,9 @@ class LockDir:
unlinkfile = 1
if not os.path.exists(self.lockfile):
print "lockfile does not exist '%s'" % self.lockfile
+ #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
if (self.myfd != None):
+ #print "fcntl_unlock() trying to close it "
try:
os.close(self.myfd)
self.myfd=None
@@ -193,11 +201,13 @@ class LockDir:
unlinkfile = 1
self.locking_method(self.myfd,fcntl.LOCK_UN)
except SystemExit, e:
- raise
+ raise e
except Exception, e:
- os.close(self.myfd)
- self.myfd=None
- raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+ #if self.myfd is not None:
+ #print "fcntl_unlock() trying to close", self.myfd
+ #os.close(self.myfd)
+ #self.myfd=None
+ #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
try:
# This sleep call was added to allow other processes that are
# waiting for a lock to be able to grab it before it is deleted.
@@ -224,7 +234,7 @@ class LockDir:
# if "DEBUG" in self.settings:
# print "Unlinked lockfile..."
except SystemExit, e:
- raise
+ raise e
except Exception, e:
# We really don't care... Someone else has the lock.
# So it is their problem now.
@@ -236,7 +246,7 @@ class LockDir:
# open fd closed automatically on them.
#if type(lockfilename) == types.StringType:
# os.close(myfd)
-
+ #print "fcntl_unlock() trying a last ditch close", self.myfd
if (self.myfd != None):
os.close(self.myfd)
self.myfd=None
@@ -421,6 +431,7 @@ class LockDir:
pass
return results
+
if __name__ == "__main__":
def lock_work():
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 0349b7547b55e6d3810a18691fb38675374ffd7e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 04:00:24 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 05:46:12 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0349b754
Extend ParserBase to do variable substitution.
Also add embedded variable substitiution to default settings.
Why are we not using python's built-in ConfigParser?
We'll migrate it later.
---
catalyst/config.py | 3 +++
catalyst/main.py | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 8b23342..bf3c7c6 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -66,6 +66,9 @@ class ParserBase:
# Start a new array using the first element of mobjs
cur_array = [mobjs[0]]
if mobjs[1]:
+ # do any variable substitiution embeded in it with
+ # the values already obtained
+ mobjs[1] = mobjs[1] % values
if self.multiple_values:
# split on white space creating additional array elements
# subarray = white_space.split(mobjs[1])
diff --git a/catalyst/main.py b/catalyst/main.py
index 1446cf9..5fa3f1b 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -116,7 +116,6 @@ def parse_config(myconfig):
# add our python base directory to use for loading target arch's
conf_values["PythonDir"] = __selfpath__
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
@@ -133,6 +132,11 @@ def parse_config(myconfig):
if "envscript" in myconf:
print "Envscript support enabled."
+ # take care of any variable substitutions that may be left
+ for x in list(conf_values):
+ if isinstance(conf_values[x], str):
+ conf_values[x] = conf_values[x] % conf_values
+
def import_module(target):
"""
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 00ef5c3294e8b7530aa8881649c5bc21b7def377
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 21 23:34:32 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 05:18:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=00ef5c32
fix options being reset by a config file
---
catalyst/main.py | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 776a678..1446cf9 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -204,9 +204,7 @@ def main():
usage()
sys.exit(2)
- # initialize it if it's not already
- if 'options' not in conf_values:
- conf_values['options'] = set()
+ options = set()
run = False
for o, a in opts:
@@ -237,7 +235,7 @@ def main():
myspecfile=a
if o in ("-F", "--fetchonly"):
- conf_values['options'].add("fetch")
+ options.add("fetch")
if o in ("-v", "--verbose"):
conf_values["VERBOSE"]="1"
@@ -253,16 +251,18 @@ def main():
mycmdline.append("version_stamp="+a)
if o in ("-p", "--purge"):
- conf_values['options'].add("purge")
+ options.add("purge")
if o in ("-P", "--purgeonly"):
- conf_values['options'].add("purgeonly")
+ options.add("purgeonly")
if o in ("-T", "--purgetmponly"):
- conf_values['options'].add("purgetmponly")
+ options.add("purgetmponly")
if o in ("-a", "--clear-autoresume"):
- conf_values['options'].add("clear-autoresume")
+ options.add("clear-autoresume")
+
+ #print "MAIN: cli options =", options
if not run:
print "!!! catalyst: please specify one of either -f or -C\n"
@@ -272,6 +272,9 @@ def main():
# import configuration file and import our main module using those settings
parse_config(myconfig)
+ conf_values["options"].update(options)
+ #print "MAIN: conf_values['options'] =", conf_values["options"]
+
# initialize our contents generator
contents_map = ContentsMap(CONTENTS_DEFINITIONS)
conf_values["contents_map"] = contents_map
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 0ace9c0fde5e10f16441869798a14ab80e4ca90b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 04:57:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 05:45:33 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0ace9c0f
reduce 2 operations into one simpler one
---
catalyst/config.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index 460bbd5..8b23342 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -54,11 +54,7 @@ class ParserBase:
# Skip any blank lines
if not myline: continue
- # Look for separator
- msearch = myline.find(self.key_value_separator)
-
- # If separator found assume its a new key
- if msearch != -1:
+ if self.key_value_separator in myline:
# Split on the first occurence of the separator creating two strings in the array mobjs
mobjs = myline.split(self.key_value_separator, 1)
mobjs[1] = mobjs[1].strip().strip('"')
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 1c8c0c7265ebe13a68399989d34c714fbfdf8f54
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 19:22:27 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 04:55:10 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=1c8c0c72
some spacing and comment and indent cleanup, etc.
Conflicts:
catalyst/support.py
---
catalyst/support.py | 405 +++++++++++++++++++++++++++-------------------------
1 file changed, 213 insertions(+), 192 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index feaa645..6f66d3c 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,12 +1,19 @@
-import sys,string,os,types,re,signal,traceback,time
-#import md5,sha
+import sys
+import string
+import os
+import types
+import re
+import signal
+import traceback
+import time
from catalyst.defaults import verbosity, valid_config_file_values
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
+
BASH_BINARY = "/bin/bash"
# set it to 0 for the soft limit, 1 for the hard limit
@@ -25,35 +32,35 @@ spawned_pids = []
def cleanup(pids,block_exceptions=True):
- """function to go through and reap the list of pids passed to it"""
- global spawned_pids
- if type(pids) == int:
- pids = [pids]
- for x in pids:
- try:
- os.kill(x,signal.SIGTERM)
- if os.waitpid(x,os.WNOHANG)[1] == 0:
- # feisty bugger, still alive.
- os.kill(x,signal.SIGKILL)
- os.waitpid(x,0)
-
- except OSError, oe:
- if block_exceptions:
- pass
- if oe.errno not in (10,3):
- raise oe
- except SystemExit:
- raise
- except Exception:
- if block_exceptions:
- pass
- try: spawned_pids.remove(x)
- except IndexError: pass
-
-
-
-# a function to turn a string of non-printable characters into a string of
-# hex characters
+ """function to go through and reap the list of pids passed to it"""
+ global spawned_pids
+ if type(pids) == int:
+ pids = [pids]
+ for x in pids:
+ try:
+ os.kill(x,signal.SIGTERM)
+ if os.waitpid(x,os.WNOHANG)[1] == 0:
+ # feisty bugger, still alive.
+ os.kill(x,signal.SIGKILL)
+ os.waitpid(x,0)
+ except OSError, oe:
+ if block_exceptions:
+ pass
+ if oe.errno not in (10,3):
+ raise oe
+ except SystemExit:
+ raise
+ except Exception:
+ if block_exceptions:
+ pass
+ try:
+ spawned_pids.remove(x)
+ except IndexError:
+ pass
+
+
+# a function to turn a string of non-printable characters
+# into a string of hex characters
def hexify(str):
hexStr = string.hexdigits
r = ''
@@ -61,7 +68,6 @@ def hexify(str):
i = ord(ch)
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF]
return r
-# hexify()
def read_from_clst(file):
@@ -77,7 +83,6 @@ def read_from_clst(file):
myline = myline + line
myf.close()
return myline
-# read_from_clst
def list_bashify(mylist):
@@ -92,6 +97,7 @@ def list_bashify(mylist):
mypack=string.join(mypack)
return mypack
+
def list_to_string(mylist):
if type(mylist)==types.StringType:
mypack=[mylist]
@@ -104,6 +110,7 @@ def list_to_string(mylist):
mypack=string.join(mypack)
return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
@@ -115,84 +122,83 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
+
def die(msg=None):
warn(msg)
sys.exit(1)
+
def warn(msg):
print "!!! catalyst: "+msg
+
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
- # this sucks. badly.
- p=os.getenv("PATH")
- if p == None:
- return None
- for x in p.split(":"):
- #if it exists, and is executable
- if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
- return "%s/%s" % (x,myc)
- return None
+ # this sucks. badly.
+ p=os.getenv("PATH")
+ if p == None:
+ return None
+ for x in p.split(":"):
+ #if it exists, and is executable
+ if os.path.exists("%s/%s" % (x,myc)) and os.stat("%s/%s" % (x,myc))[0] & 0x0248:
+ return "%s/%s" % (x,myc)
+ return None
+
def spawn_bash(mycommand,env={},debug=False,opt_name=None,**keywords):
"""spawn mycommand as an arguement to bash"""
args=[BASH_BINARY]
if not opt_name:
- opt_name=mycommand.split()[0]
+ opt_name=mycommand.split()[0]
if "BASH_ENV" not in env:
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
+ env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
if debug:
- args.append("-x")
+ args.append("-x")
args.append("-c")
args.append(mycommand)
return spawn(args,env=env,opt_name=opt_name,**keywords)
-#def spawn_get_output(mycommand,spawn_type=spawn,raw_exit_code=False,emulate_gso=True, \
-# collect_fds=[1],fd_pipes=None,**keywords):
def spawn_get_output(mycommand,raw_exit_code=False,emulate_gso=True, \
- collect_fds=[1],fd_pipes=None,**keywords):
- """call spawn, collecting the output to fd's specified in collect_fds list
- emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
- requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
- 'lets let log only stdin and let stderr slide by'.
-
- emulate_gso was deprecated from the day it was added, so convert your code over.
- spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
- global selinux_capable
- pr,pw=os.pipe()
-
- #if type(spawn_type) not in [types.FunctionType, types.MethodType]:
- # s="spawn_type must be passed a function, not",type(spawn_type),spawn_type
- # raise Exception,s
-
- if fd_pipes==None:
- fd_pipes={}
- fd_pipes[0] = 0
-
- for x in collect_fds:
- fd_pipes[x] = pw
- keywords["returnpid"]=True
-
- mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
- os.close(pw)
- if type(mypid) != types.ListType:
- os.close(pr)
- return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
-
- fd=os.fdopen(pr,"r")
- mydata=fd.readlines()
- fd.close()
- if emulate_gso:
- mydata=string.join(mydata)
- if len(mydata) and mydata[-1] == "\n":
- mydata=mydata[:-1]
- retval=os.waitpid(mypid[0],0)[1]
- cleanup(mypid)
- if raw_exit_code:
- return [retval,mydata]
- retval=process_exit_code(retval)
- return [retval, mydata]
+ collect_fds=[1],fd_pipes=None,**keywords):
+ """call spawn, collecting the output to fd's specified in collect_fds list
+ emulate_gso is a compatability hack to emulate commands.getstatusoutput's return, minus the
+ requirement it always be a bash call (spawn_type controls the actual spawn call), and minus the
+ 'lets let log only stdin and let stderr slide by'.
+
+ emulate_gso was deprecated from the day it was added, so convert your code over.
+ spawn_type is the passed in function to call- typically spawn_bash, spawn, spawn_sandbox, or spawn_fakeroot"""
+ global selinux_capable
+ pr,pw=os.pipe()
+
+ if fd_pipes==None:
+ fd_pipes={}
+ fd_pipes[0] = 0
+
+ for x in collect_fds:
+ fd_pipes[x] = pw
+ keywords["returnpid"]=True
+
+ mypid=spawn_bash(mycommand,fd_pipes=fd_pipes,**keywords)
+ os.close(pw)
+ if type(mypid) != types.ListType:
+ os.close(pr)
+ return [mypid, "%s: No such file or directory" % mycommand.split()[0]]
+
+ fd=os.fdopen(pr,"r")
+ mydata=fd.readlines()
+ fd.close()
+ if emulate_gso:
+ mydata=string.join(mydata)
+ if len(mydata) and mydata[-1] == "\n":
+ mydata=mydata[:-1]
+ retval=os.waitpid(mypid[0],0)[1]
+ cleanup(mypid)
+ if raw_exit_code:
+ return [retval,mydata]
+ retval=process_exit_code(retval)
+ return [retval, mydata]
+
# base spawn function
def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,returnpid=False,\
@@ -230,8 +236,8 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
return None
myc = find_binary(myc)
if myc == None:
- return None
- mypid=[]
+ return None
+ mypid=[]
if logfile:
pr,pw=os.pipe()
mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
@@ -295,77 +301,77 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
if x not in trg_fd:
try:
os.close(x)
- except SystemExit, e:
- raise
- except:
- pass
-
- # note this order must be preserved- can't change gid/groups if you change uid first.
- if selinux_capable and selinux_context:
- import selinux
- selinux.setexec(selinux_context)
- if gid:
- os.setgid(gid)
- if groups:
- os.setgroups(groups)
- if uid:
- os.setuid(uid)
- if umask:
- os.umask(umask)
- else:
- os.umask(022)
-
- try:
- #print "execing", myc, myargs
- if func_call:
- # either use a passed in func for interpretting the results, or return if no exception.
- # note the passed in list, and dict are expanded.
- if len(mycommand) == 4:
- os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
- try:
- mycommand[0](*mycommand[1],**mycommand[2])
- except Exception,e:
- print "caught exception",e," in forked func",mycommand[0]
- sys.exit(0)
-
- #os.execvp(myc,myargs)
- os.execve(myc,myargs,env)
- except SystemExit, e:
- raise
- except Exception, e:
- if not func_call:
- raise str(e)+":\n "+myc+" "+string.join(myargs)
- print "func call failed"
-
- # If the execve fails, we need to report it, and exit
- # *carefully* --- report error here
- os._exit(1)
- sys.exit(1)
- return # should never get reached
-
- # if we were logging, kill the pipes.
- if logfile:
- os.close(pr)
- os.close(pw)
-
- if returnpid:
- return mypid
-
- # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
- # if the main pid (mycommand) returned badly.
- while len(mypid):
- retval=os.waitpid(mypid[-1],0)[1]
- if retval != 0:
- cleanup(mypid[0:-1],block_exceptions=False)
- # at this point we've killed all other kid pids generated via this call.
- # return now.
- if raw_exit_code:
- return retval
- return process_exit_code(retval,throw_signals=raise_signals)
- else:
- mypid.pop(-1)
- cleanup(mypid)
- return 0
+ except SystemExit, e:
+ raise
+ except:
+ pass
+
+ # note this order must be preserved- can't change gid/groups if you change uid first.
+ if selinux_capable and selinux_context:
+ import selinux
+ selinux.setexec(selinux_context)
+ if gid:
+ os.setgid(gid)
+ if groups:
+ os.setgroups(groups)
+ if uid:
+ os.setuid(uid)
+ if umask:
+ os.umask(umask)
+ else:
+ os.umask(022)
+
+ try:
+ #print "execing", myc, myargs
+ if func_call:
+ # either use a passed in func for interpretting the results, or return if no exception.
+ # note the passed in list, and dict are expanded.
+ if len(mycommand) == 4:
+ os._exit(mycommand[3](mycommand[0](*mycommand[1],**mycommand[2])))
+ try:
+ mycommand[0](*mycommand[1],**mycommand[2])
+ except Exception,e:
+ print "caught exception",e," in forked func",mycommand[0]
+ sys.exit(0)
+
+ os.execve(myc,myargs,env)
+ except SystemExit, e:
+ raise
+ except Exception, e:
+ if not func_call:
+ raise str(e)+":\n "+myc+" "+string.join(myargs)
+ print "func call failed"
+
+ # If the execve fails, we need to report it, and exit
+ # *carefully* --- report error here
+ os._exit(1)
+ sys.exit(1)
+ return # should never get reached
+
+ # if we were logging, kill the pipes.
+ if logfile:
+ os.close(pr)
+ os.close(pw)
+
+ if returnpid:
+ return mypid
+
+ # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
+ # if the main pid (mycommand) returned badly.
+ while len(mypid):
+ retval=os.waitpid(mypid[-1],0)[1]
+ if retval != 0:
+ cleanup(mypid[0:-1],block_exceptions=False)
+ # at this point we've killed all other kid pids generated via this call.
+ # return now.
+ if raw_exit_code:
+ return retval
+ return process_exit_code(retval,throw_signals=raise_signals)
+ else:
+ mypid.pop(-1)
+ cleanup(mypid)
+ return 0
+
def cmd(mycmd,myexc="",env={}):
try:
@@ -376,19 +382,21 @@ def cmd(mycmd,myexc="",env={}):
except:
raise
+
def process_exit_code(retval,throw_signals=False):
- """process a waitpid returned exit code, returning exit code if it exit'd, or the
- signal if it died from signalling
- if throw_signals is on, it raises a SystemExit if the process was signaled.
- This is intended for usage with threads, although at the moment you can't signal individual
- threads in python, only the master thread, so it's a questionable option."""
- if (retval & 0xff)==0:
- return retval >> 8 # return exit code
- else:
- if throw_signals:
- #use systemexit, since portage is stupid about exception catching.
- raise SystemExit()
- return (retval & 0xff) << 8 # interrupted by signal
+ """process a waitpid returned exit code, returning exit code if it exit'd, or the
+ signal if it died from signalling
+ if throw_signals is on, it raises a SystemExit if the process was signaled.
+ This is intended for usage with threads, although at the moment you can't signal individual
+ threads in python, only the master thread, so it's a questionable option."""
+ if (retval & 0xff)==0:
+ return retval >> 8 # return exit code
+ else:
+ if throw_signals:
+ #use systemexit, since portage is stupid about exception catching.
+ raise SystemExit()
+ return (retval & 0xff) << 8 # interrupted by signal
+
def file_locate(settings,filelist,expand=1):
#if expand=1, non-absolute paths will be accepted and
@@ -398,15 +406,18 @@ def file_locate(settings,filelist,expand=1):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
pass
else:
- if len(settings[myfile])==0:
- raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
- if settings[myfile][0]=="/":
- if not os.path.exists(settings[myfile]):
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
- elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
- settings[myfile]=os.getcwd()+"/"+settings[myfile]
- else:
- raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
+ if len(settings[myfile])==0:
+ raise CatalystError("File variable \"" + myfile +
+ "\" has a length of zero (not specified.)", print_traceback=True)
+ if settings[myfile][0]=="/":
+ if not os.path.exists(settings[myfile]):
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile], print_traceback=True)
+ elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
+ settings[myfile]=os.getcwd()+"/"+settings[myfile]
+ else:
+ raise CatalystError("Cannot locate specified " + myfile +
+ ": "+settings[myfile]+" (2nd try)" +
"""
Spec file format:
@@ -427,6 +438,8 @@ that the order of multiple-value items is preserved, but the order that the item
defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1"
"item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
"""
+ , print_traceback=True)
+
def parse_makeconf(mylines):
mymakeconf={}
@@ -450,6 +463,7 @@ def parse_makeconf(mylines):
mymakeconf[mobj.group(1)]=clean_string
return mymakeconf
+
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
@@ -475,10 +489,12 @@ def read_makeconf(mymakeconffile):
makeconf={}
return makeconf
+
def msg(mymsg,verblevel=1):
if verbosity>=verblevel:
print mymsg
+
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
@@ -491,6 +507,7 @@ def pathcompare(path1,path2):
return 1
return 0
+
def ismount(path):
"enhanced to handle bind mounts"
if os.path.ismount(path):
@@ -504,6 +521,7 @@ def ismount(path):
return 1
return 0
+
def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
"helper function to help targets parse additional arguments"
global valid_config_file_values
@@ -522,6 +540,7 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
if messages:
raise CatalystError, '\n\tAlso: '.join(messages)
+
def touch(myfile):
try:
myf=open(myfile,"w")
@@ -529,8 +548,9 @@ def touch(myfile):
except IOError:
raise CatalystError, "Could not touch "+myfile+"."
+
def countdown(secs=5, doing="Starting"):
- if secs:
+ if secs:
print ">>> Waiting",secs,"seconds before starting..."
print ">>> (Control-C to abort)...\n"+doing+" in: ",
ticks=range(secs)
@@ -541,14 +561,15 @@ def countdown(secs=5, doing="Starting"):
time.sleep(1)
print
+
def normpath(mypath):
TrailingSlash=False
- if mypath[-1] == "/":
- TrailingSlash=True
- newpath = os.path.normpath(mypath)
- if len(newpath) > 1:
- if newpath[:2] == "//":
- newpath = newpath[1:]
+ if mypath[-1] == "/":
+ TrailingSlash=True
+ newpath = os.path.normpath(mypath)
+ if len(newpath) > 1:
+ if newpath[:2] == "//":
+ newpath = newpath[1:]
if TrailingSlash:
- newpath=newpath+'/'
- return newpath
+ newpath=newpath+'/'
+ return newpath
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-06-14 5:58 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-06-14 5:58 UTC (permalink / raw
To: gentoo-commits
commit: 5204bbcb0fb52892c4cc569cb404bab46949d32f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 04:35:40 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5204bbcb
Move LockInUse from support.py to lock.py, fix bad execption raising, pyflakes cleanup
---
catalyst/lock.py | 49 +++++++++++++++++++++++++++++++------------------
catalyst/main.py | 3 ++-
catalyst/support.py | 11 -----------
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..ef00b49 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
import fcntl
import errno
import sys
-import string
import time
-from catalyst.support import *
+from catalyst.support import CatalystError
def writemsg(mystr):
sys.stderr.write(mystr)
sys.stderr.flush()
+
+class LockInUse(Exception):
+ def __init__(self, message):
+ if message:
+ #(type,value)=sys.exc_info()[:2]
+ #if value!=None:
+ #print
+ #kprint traceback.print_exc(file=sys.stdout)
+ print
+ print "!!! catalyst lock file in use: "+message
+ print
+
+
class LockDir:
locking_method=fcntl.flock
lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
def fcntl_lock(self,locktype):
if self.myfd==None:
if not os.path.exists(os.path.dirname(self.lockdir)):
- raise DirectoryNotFound, os.path.dirname(self.lockdir)
+ raise CatalystError("DirectoryNotFound: %s"
+ % os.path.dirname(self.lockdir))
if not os.path.exists(self.lockfile):
old_mask=os.umask(000)
self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
print "lockfile does not exist '%s'" % self.lockfile
if (self.myfd != None):
try:
- os.close(myfd)
+ os.close(self.myfd)
self.myfd=None
except:
pass
@@ -251,12 +264,13 @@ class LockDir:
self.add_hardlock_file_to_cleanup()
if not os.path.exists(self.myhardlock):
- raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+ raise CatalystError("FileNotFound: Created lockfile is missing: "
+ "%(filename)s" % {"filename":self.myhardlock})
try:
- res = os.link(self.myhardlock, self.lockfile)
- except SystemExit, e:
+ os.link(self.myhardlock, self.lockfile)
+ except SystemExit:
raise
- except Exception, e:
+ except Exception:
# if "DEBUG" in self.settings:
# print "lockfile(): Hardlink: Link failed."
# print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
os.unlink(self.myhardlock)
if os.path.exists(self.lockfile):
os.unlink(self.lockfile)
- except SystemExit, e:
+ except SystemExit:
raise
except:
writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
try:
myhls = os.stat(link)
mylfs = os.stat(lock)
- except SystemExit, e:
+ except SystemExit:
raise
except:
myhls = None
@@ -340,7 +354,7 @@ class LockDir:
pass
def hardlock_cleanup(self,path):
- mypid = str(os.getpid())
+ #mypid = str(os.getpid())
myhost = os.uname()[1]
mydl = os.listdir(path)
results = []
@@ -384,26 +398,26 @@ class LockDir:
# We're sweeping through, unlinking everyone's locks.
os.unlink(filename)
results.append("Unlinked: " + filename)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
try:
os.unlink(x)
results.append("Unlinked: " + x)
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
else:
try:
os.unlink(mylockname)
results.append("Unlinked: " + mylockname)
- except SystemExit, e:
+ except SystemExit:
raise
- except Exception,e:
+ except Exception:
pass
return results
@@ -423,7 +437,6 @@ if __name__ == "__main__":
return newpath
print "Lock 5 starting"
- import time
Lock1=LockDir("/tmp/lock_path")
Lock1.write_lock()
print "Lock1 write lock"
diff --git a/catalyst/main.py b/catalyst/main.py
index 1ead9e8..30df771 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
from catalyst.defaults import (required_build_targets, valid_build_targets,
confdefaults)
from hash_utils import HashMap, HASH_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
print "!!! catalyst: "+message
print
-class LockInUse(Exception):
- def __init__(self, message):
- if message:
- #(type,value)=sys.exc_info()[:2]
- #if value!=None:
- #print
- #kprint traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst lock file in use: "+message
- print
-
def die(msg=None):
warn(msg)
sys.exit(1)
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/
@ 2014-05-05 19:17 Brian Dolbec
2014-04-02 20:09 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
0 siblings, 1 reply; 85+ messages in thread
From: Brian Dolbec @ 2014-05-05 19:17 UTC (permalink / raw
To: gentoo-commits
commit: 69c1839e501cbbf05c1790b267ed1b5b356091c0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 19 05:51:35 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 2 20:04:24 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=69c1839e
Move confdefaults out of main.py
---
catalyst/defaults.py | 17 +++++++++++++++++
catalyst/main.py | 20 +++-----------------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 748d1dd..b83e4f5 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -21,6 +21,22 @@ valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
verbosity = 1
+confdefaults={
+ "distdir": "/usr/portage/distfiles",
+ "hash_function": "crc32",
+ "icecream": "/var/cache/icecream",
+ "local_overlay": "/usr/local/portage",
+ "options": "",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "repo_name": "portage",
+ "sharedir": "/usr/lib/catalyst",
+ "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
+ "snapshot_name": "portage-",
+ "storedir": "/var/tmp/catalyst",
+ }
+
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
@@ -48,3 +64,4 @@ SOURCE_MOUNT_DEFAULTS = {
"proc": "/proc",
"shm": "shmfs",
}
+
diff --git a/catalyst/main.py b/catalyst/main.py
index e2ef976..5748d31 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -22,7 +22,8 @@ from . import __version__
import catalyst.config
import catalyst.util
from catalyst.support import CatalystError, find_binary, LockInUse
-from catalyst.defaults import required_build_targets, valid_build_targets
+from catalyst.defaults import (required_build_targets, valid_build_targets,
+ confdefaults)
from hash_utils import HashMap, HASH_DEFINITIONS
from contents import ContentsMap, CONTENTS_DEFINITIONS
@@ -70,21 +71,6 @@ def parse_config(myconfig):
myconf={}
config_file=""
- confdefaults = {
- "distdir": "/usr/portage/distfiles",
- "hash_function": "crc32",
- "icecream": "/var/cache/icecream",
- "local_overlay": "/usr/local/portage",
- "options": "",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
- "repo_name": "portage",
- "sharedir": "/usr/share/catalyst",
- "snapshot_name": "portage-",
- "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "storedir": "/var/tmp/catalyst",
- }
-
# first, try the one passed (presumably from the cmdline)
if myconfig:
if os.path.exists(myconfig):
@@ -117,7 +103,7 @@ def parse_config(myconfig):
sys.exit(1)
# now, load up the values into conf_values so that we can use them
- for x in confdefaults.keys():
+ for x in list(confdefaults):
if x in myconf:
print "Setting",x,"to config file value \""+myconf[x]+"\""
conf_values[x]=myconf[x]
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
2014-05-05 19:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-04-02 20:09 ` Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-04-02 20:09 UTC (permalink / raw
To: gentoo-commits
commit: 69c1839e501cbbf05c1790b267ed1b5b356091c0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 19 05:51:35 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 2 20:04:24 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=69c1839e
Move confdefaults out of main.py
---
catalyst/defaults.py | 17 +++++++++++++++++
catalyst/main.py | 20 +++-----------------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 748d1dd..b83e4f5 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -21,6 +21,22 @@ valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
verbosity = 1
+confdefaults={
+ "distdir": "/usr/portage/distfiles",
+ "hash_function": "crc32",
+ "icecream": "/var/cache/icecream",
+ "local_overlay": "/usr/local/portage",
+ "options": "",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "repo_name": "portage",
+ "sharedir": "/usr/lib/catalyst",
+ "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
+ "snapshot_name": "portage-",
+ "storedir": "/var/tmp/catalyst",
+ }
+
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
@@ -48,3 +64,4 @@ SOURCE_MOUNT_DEFAULTS = {
"proc": "/proc",
"shm": "shmfs",
}
+
diff --git a/catalyst/main.py b/catalyst/main.py
index e2ef976..5748d31 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -22,7 +22,8 @@ from . import __version__
import catalyst.config
import catalyst.util
from catalyst.support import CatalystError, find_binary, LockInUse
-from catalyst.defaults import required_build_targets, valid_build_targets
+from catalyst.defaults import (required_build_targets, valid_build_targets,
+ confdefaults)
from hash_utils import HashMap, HASH_DEFINITIONS
from contents import ContentsMap, CONTENTS_DEFINITIONS
@@ -70,21 +71,6 @@ def parse_config(myconfig):
myconf={}
config_file=""
- confdefaults = {
- "distdir": "/usr/portage/distfiles",
- "hash_function": "crc32",
- "icecream": "/var/cache/icecream",
- "local_overlay": "/usr/local/portage",
- "options": "",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
- "repo_name": "portage",
- "sharedir": "/usr/share/catalyst",
- "snapshot_name": "portage-",
- "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "storedir": "/var/tmp/catalyst",
- }
-
# first, try the one passed (presumably from the cmdline)
if myconfig:
if os.path.exists(myconfig):
@@ -117,7 +103,7 @@ def parse_config(myconfig):
sys.exit(1)
# now, load up the values into conf_values so that we can use them
- for x in confdefaults.keys():
+ for x in list(confdefaults):
if x in myconf:
print "Setting",x,"to config file value \""+myconf[x]+"\""
conf_values[x]=myconf[x]
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-04-02 20:09 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-04-02 20:09 UTC (permalink / raw
To: gentoo-commits
commit: 380085b1b64a80cd6fc8518309e8ca9e31246ba3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 14 03:32:29 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 2 20:04:23 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=380085b1
Fix undefined variable: RLIMIT_NOFILE
It was not imported from resource, it was also not used correctly.
---
catalyst/support.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index e25394e..5abf614 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -6,14 +6,16 @@ selinux_capable = False
#fakeroot_capable = False
BASH_BINARY = "/bin/bash"
+# set it to 0 for the soft limit, 1 for the hard limit
+DESIRED_RLIMIT = 0
try:
- import resource
- max_fd_limit=resource.getrlimit(RLIMIT_NOFILE)
+ import resource
+ max_fd_limit=resource.getrlimit(resource.RLIMIT_NOFILE)[DESIRED_RLIMIT]
except SystemExit, e:
- raise
+ raise
except:
- # hokay, no resource module.
- max_fd_limit=256
+ # hokay, no resource module.
+ max_fd_limit=256
# pids this process knows of.
spawned_pids = []
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-04-02 20:09 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-04-02 20:09 UTC (permalink / raw
To: gentoo-commits
commit: 876edf3306f3d1c739f60199bef6082e4ac96459
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 3 18:48:31 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 2 20:04:23 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=876edf33
main.py: print the output of an ImportError to help in debugging.
---
catalyst/main.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 4146bca..bba3cba 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -227,9 +227,10 @@ def import_modules():
raise CatalystError,"Can't find " + x + ".py plugin in " + \
module_dir
- except ImportError:
+ except ImportError as e:
print "!!! catalyst: Python modules not found in "+\
module_dir + "; exiting."
+ print e
sys.exit(1)
return targetmap
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-04-02 20:09 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-04-02 20:09 UTC (permalink / raw
To: gentoo-commits
commit: e072dadbba8758c67bc83ee284af3453c734d7bd
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 4 01:02:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Apr 2 20:04:24 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=e072dadb
Creation of a new defaults.py
catalyst/support.py: Move some defaults to a new defaults file.
---
catalyst/defaults.py | 23 +++++++++++++++++++++++
catalyst/main.py | 5 ++---
catalyst/support.py | 35 +++--------------------------------
3 files changed, 28 insertions(+), 35 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
new file mode 100644
index 0000000..b1dbda4
--- /dev/null
+++ b/catalyst/defaults.py
@@ -0,0 +1,23 @@
+
+
+# these should never be touched
+required_build_targets = ["generic_target", "generic_stage_target"]
+
+# new build types should be added here
+valid_build_targets = ["stage1_target", "stage2_target", "stage3_target",
+ "stage4_target", "grp_target", "livecd_stage1_target", "livecd_stage2_target",
+ "embedded_target", "tinderbox_target", "snapshot_target", "netboot_target",
+ "netboot2_target"
+ ]
+
+required_config_file_values = ["storedir", "sharedir", "distdir", "portdir"]
+
+valid_config_file_values = required_config_file_values[:]
+valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
+ "ICECREAM", "ENVSCRIPT", "AUTORESUME", "FETCH", "CLEAR_AUTORESUME",
+ "options", "DEBUG", "VERBOSE", "PURGE", "PURGEONLY", "SNAPCACHE",
+ "snapshot_cache", "hash_function", "digests", "contents", "SEEDCACHE"
+ ])
+
+verbosity = 1
+
diff --git a/catalyst/main.py b/catalyst/main.py
index bba3cba..e2ef976 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,9 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import (required_build_targets,
- valid_build_targets, CatalystError, find_binary, LockInUse)
-
+from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.defaults import required_build_targets, valid_build_targets
from hash_utils import HashMap, HASH_DEFINITIONS
from contents import ContentsMap, CONTENTS_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index 5abf614..4fe4603 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,6 +1,9 @@
import sys,string,os,types,re,signal,traceback,time
#import md5,sha
+
+from catalyst.defaults import verbosity, valid_config_file_values
+
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
@@ -80,38 +83,6 @@ def read_from_clst(file):
return myline
# read_from_clst
-# these should never be touched
-required_build_targets=["generic_target","generic_stage_target"]
-
-# new build types should be added here
-valid_build_targets=["stage1_target","stage2_target","stage3_target","stage4_target","grp_target",
- "livecd_stage1_target","livecd_stage2_target","embedded_target",
- "tinderbox_target","snapshot_target","netboot_target","netboot2_target"]
-
-required_config_file_values=["storedir","sharedir","distdir","portdir"]
-valid_config_file_values=required_config_file_values[:]
-valid_config_file_values.append("PKGCACHE")
-valid_config_file_values.append("KERNCACHE")
-valid_config_file_values.append("CCACHE")
-valid_config_file_values.append("DISTCC")
-valid_config_file_values.append("ICECREAM")
-valid_config_file_values.append("ENVSCRIPT")
-valid_config_file_values.append("AUTORESUME")
-valid_config_file_values.append("FETCH")
-valid_config_file_values.append("CLEAR_AUTORESUME")
-valid_config_file_values.append("options")
-valid_config_file_values.append("DEBUG")
-valid_config_file_values.append("VERBOSE")
-valid_config_file_values.append("PURGE")
-valid_config_file_values.append("PURGEONLY")
-valid_config_file_values.append("SNAPCACHE")
-valid_config_file_values.append("snapshot_cache")
-valid_config_file_values.append("hash_function")
-valid_config_file_values.append("digests")
-valid_config_file_values.append("contents")
-valid_config_file_values.append("SEEDCACHE")
-
-verbosity=1
def list_bashify(mylist):
if type(mylist)==types.StringType:
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-03-22 22:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-03-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 0ca9ec75522dbf9c55ad422070b6a92140faa5d1
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 19 05:51:35 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar 22 18:01:31 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0ca9ec75
Move confdefaults out of main.py
---
catalyst/defaults.py | 17 +++++++++++++++++
catalyst/main.py | 20 +++-----------------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 748d1dd..b83e4f5 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -21,6 +21,22 @@ valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
verbosity = 1
+confdefaults={
+ "distdir": "/usr/portage/distfiles",
+ "hash_function": "crc32",
+ "icecream": "/var/cache/icecream",
+ "local_overlay": "/usr/local/portage",
+ "options": "",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "repo_name": "portage",
+ "sharedir": "/usr/lib/catalyst",
+ "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
+ "snapshot_name": "portage-",
+ "storedir": "/var/tmp/catalyst",
+ }
+
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
@@ -48,3 +64,4 @@ SOURCE_MOUNT_DEFAULTS = {
"proc": "/proc",
"shm": "shmfs",
}
+
diff --git a/catalyst/main.py b/catalyst/main.py
index e2ef976..5748d31 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -22,7 +22,8 @@ from . import __version__
import catalyst.config
import catalyst.util
from catalyst.support import CatalystError, find_binary, LockInUse
-from catalyst.defaults import required_build_targets, valid_build_targets
+from catalyst.defaults import (required_build_targets, valid_build_targets,
+ confdefaults)
from hash_utils import HashMap, HASH_DEFINITIONS
from contents import ContentsMap, CONTENTS_DEFINITIONS
@@ -70,21 +71,6 @@ def parse_config(myconfig):
myconf={}
config_file=""
- confdefaults = {
- "distdir": "/usr/portage/distfiles",
- "hash_function": "crc32",
- "icecream": "/var/cache/icecream",
- "local_overlay": "/usr/local/portage",
- "options": "",
- "packagedir": "/usr/portage/packages",
- "portdir": "/usr/portage",
- "repo_name": "portage",
- "sharedir": "/usr/share/catalyst",
- "snapshot_name": "portage-",
- "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",
- "storedir": "/var/tmp/catalyst",
- }
-
# first, try the one passed (presumably from the cmdline)
if myconfig:
if os.path.exists(myconfig):
@@ -117,7 +103,7 @@ def parse_config(myconfig):
sys.exit(1)
# now, load up the values into conf_values so that we can use them
- for x in confdefaults.keys():
+ for x in list(confdefaults):
if x in myconf:
print "Setting",x,"to config file value \""+myconf[x]+"\""
conf_values[x]=myconf[x]
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-03-22 22:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-03-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: a17349d30b9b94d12463be700558f6c5379c312f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 3 18:48:31 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar 22 18:01:30 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a17349d3
main.py: print the output of an ImportError to help in debugging.
---
catalyst/main.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 4146bca..bba3cba 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -227,9 +227,10 @@ def import_modules():
raise CatalystError,"Can't find " + x + ".py plugin in " + \
module_dir
- except ImportError:
+ except ImportError as e:
print "!!! catalyst: Python modules not found in "+\
module_dir + "; exiting."
+ print e
sys.exit(1)
return targetmap
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-03-22 22:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-03-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 612761103527c0cc2801aff7cdb28b9f4a82d9d2
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 4 01:02:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar 22 18:01:30 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=61276110
Creation of a new defaults.py
catalyst/support.py: Move some defaults to a new defaults file.
---
catalyst/defaults.py | 23 +++++++++++++++++++++++
catalyst/main.py | 5 ++---
catalyst/support.py | 35 +++--------------------------------
3 files changed, 28 insertions(+), 35 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
new file mode 100644
index 0000000..b1dbda4
--- /dev/null
+++ b/catalyst/defaults.py
@@ -0,0 +1,23 @@
+
+
+# these should never be touched
+required_build_targets = ["generic_target", "generic_stage_target"]
+
+# new build types should be added here
+valid_build_targets = ["stage1_target", "stage2_target", "stage3_target",
+ "stage4_target", "grp_target", "livecd_stage1_target", "livecd_stage2_target",
+ "embedded_target", "tinderbox_target", "snapshot_target", "netboot_target",
+ "netboot2_target"
+ ]
+
+required_config_file_values = ["storedir", "sharedir", "distdir", "portdir"]
+
+valid_config_file_values = required_config_file_values[:]
+valid_config_file_values.extend(["PKGCACHE", "KERNCACHE", "CCACHE", "DISTCC",
+ "ICECREAM", "ENVSCRIPT", "AUTORESUME", "FETCH", "CLEAR_AUTORESUME",
+ "options", "DEBUG", "VERBOSE", "PURGE", "PURGEONLY", "SNAPCACHE",
+ "snapshot_cache", "hash_function", "digests", "contents", "SEEDCACHE"
+ ])
+
+verbosity = 1
+
diff --git a/catalyst/main.py b/catalyst/main.py
index bba3cba..e2ef976 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,9 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
-from catalyst.support import (required_build_targets,
- valid_build_targets, CatalystError, find_binary, LockInUse)
-
+from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.defaults import required_build_targets, valid_build_targets
from hash_utils import HashMap, HASH_DEFINITIONS
from contents import ContentsMap, CONTENTS_DEFINITIONS
diff --git a/catalyst/support.py b/catalyst/support.py
index 5abf614..4fe4603 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -1,6 +1,9 @@
import sys,string,os,types,re,signal,traceback,time
#import md5,sha
+
+from catalyst.defaults import verbosity, valid_config_file_values
+
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
@@ -80,38 +83,6 @@ def read_from_clst(file):
return myline
# read_from_clst
-# these should never be touched
-required_build_targets=["generic_target","generic_stage_target"]
-
-# new build types should be added here
-valid_build_targets=["stage1_target","stage2_target","stage3_target","stage4_target","grp_target",
- "livecd_stage1_target","livecd_stage2_target","embedded_target",
- "tinderbox_target","snapshot_target","netboot_target","netboot2_target"]
-
-required_config_file_values=["storedir","sharedir","distdir","portdir"]
-valid_config_file_values=required_config_file_values[:]
-valid_config_file_values.append("PKGCACHE")
-valid_config_file_values.append("KERNCACHE")
-valid_config_file_values.append("CCACHE")
-valid_config_file_values.append("DISTCC")
-valid_config_file_values.append("ICECREAM")
-valid_config_file_values.append("ENVSCRIPT")
-valid_config_file_values.append("AUTORESUME")
-valid_config_file_values.append("FETCH")
-valid_config_file_values.append("CLEAR_AUTORESUME")
-valid_config_file_values.append("options")
-valid_config_file_values.append("DEBUG")
-valid_config_file_values.append("VERBOSE")
-valid_config_file_values.append("PURGE")
-valid_config_file_values.append("PURGEONLY")
-valid_config_file_values.append("SNAPCACHE")
-valid_config_file_values.append("snapshot_cache")
-valid_config_file_values.append("hash_function")
-valid_config_file_values.append("digests")
-valid_config_file_values.append("contents")
-valid_config_file_values.append("SEEDCACHE")
-
-verbosity=1
def list_bashify(mylist):
if type(mylist)==types.StringType:
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-03-22 22:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-03-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 0153ca58ca0121ed1d35e5d1b9836f6e732956c5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 14 03:32:29 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar 22 18:01:30 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0153ca58
Fix undefined variable: RLIMIT_NOFILE
It was not imported from resource, it was also not used correctly.
---
catalyst/support.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index e25394e..5abf614 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -6,14 +6,16 @@ selinux_capable = False
#fakeroot_capable = False
BASH_BINARY = "/bin/bash"
+# set it to 0 for the soft limit, 1 for the hard limit
+DESIRED_RLIMIT = 0
try:
- import resource
- max_fd_limit=resource.getrlimit(RLIMIT_NOFILE)
+ import resource
+ max_fd_limit=resource.getrlimit(resource.RLIMIT_NOFILE)[DESIRED_RLIMIT]
except SystemExit, e:
- raise
+ raise
except:
- # hokay, no resource module.
- max_fd_limit=256
+ # hokay, no resource module.
+ max_fd_limit=256
# pids this process knows of.
spawned_pids = []
^ permalink raw reply related [flat|nested] 85+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: catalyst/
@ 2014-03-22 22:25 Brian Dolbec
0 siblings, 0 replies; 85+ messages in thread
From: Brian Dolbec @ 2014-03-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 02b002e091994999abd74d9c34e5ad9a34d41e17
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 2 16:43:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 2 22:54:04 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=02b002e0
catalyst/support.py: Update for snakeoil API change.
---
catalyst/support.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 316dfa3..5e7ce92 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -618,8 +618,8 @@ def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
try:
- import snakeoil.fileutils
- return snakeoil.fileutils.read_bash_dict(mymakeconffile, sourcing_command="source")
+ import snakeoil.bash #import snakeoil.fileutils
+ return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source")
except ImportError:
try:
import portage.util
^ permalink raw reply related [flat|nested] 85+ messages in thread
end of thread, other threads:[~2017-11-22 15:52 UTC | newest]
Thread overview: 85+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-01 5:58 [gentoo-commits] proj/catalyst:pending commit in: catalyst/ Brian Dolbec
2015-09-01 4:50 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2017-11-22 15:52 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-11 9:35 Brian Dolbec
2017-03-11 7:07 Brian Dolbec
2017-03-10 18:38 Brian Dolbec
2017-03-09 10:02 Brian Dolbec
2017-03-09 9:39 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-09-08 14:14 Brian Dolbec
2015-09-06 21:21 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-06 21:18 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:18 Brian Dolbec
2015-09-06 20:33 Brian Dolbec
2015-09-05 16:24 Brian Dolbec
2015-09-04 15:20 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-01 5:58 Brian Dolbec
2015-09-01 5:58 Brian Dolbec
2015-09-01 5:58 Brian Dolbec
2015-09-01 4:50 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-08-30 20:58 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-06-15 20:25 Brian Dolbec
2015-05-24 0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 19:25 Brian Dolbec
2015-02-26 4:12 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01 5:59 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-01-01 5:59 Brian Dolbec
2015-01-01 5:59 Brian Dolbec
2015-01-01 5:59 Brian Dolbec
2015-01-01 5:59 Brian Dolbec
2015-01-01 5:59 Brian Dolbec
2014-09-11 3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11 3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14 5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11 3:08 Brian Dolbec
2014-09-11 3:08 Brian Dolbec
2014-09-11 3:08 Brian Dolbec
2014-09-11 3:08 Brian Dolbec
2014-09-11 3:08 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 7:12 Brian Dolbec
2014-09-02 7:12 Brian Dolbec
2014-09-02 7:12 Brian Dolbec
2014-09-02 7:12 Brian Dolbec
2014-09-02 5:54 Brian Dolbec
2014-09-02 5:54 Brian Dolbec
2014-09-02 5:54 Brian Dolbec
2014-09-02 5:54 Brian Dolbec
2014-09-02 5:54 Brian Dolbec
2014-09-02 2:43 Brian Dolbec
2014-09-02 2:43 Brian Dolbec
2014-09-02 2:43 Brian Dolbec
2014-09-02 2:43 Brian Dolbec
2014-09-02 2:43 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-06-14 5:58 Brian Dolbec
2014-05-05 19:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-04-02 20:09 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox