1 |
commit: fbe5cf2702c3555fb717f8d230be7a4ab9baf1f2 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 29 16:53:56 2015 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 30 20:05:26 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fbe5cf27 |
7 |
|
8 |
portage/sync/syncbase.py: Change has_bin to an @property function |
9 |
|
10 |
This avoids that self.logger is None error in the __init__(). |
11 |
|
12 |
--- |
13 |
pym/portage/sync/modules/websync/websync.py | 2 +- |
14 |
pym/portage/sync/syncbase.py | 30 +++++++++++++++++++---------- |
15 |
2 files changed, 21 insertions(+), 11 deletions(-) |
16 |
|
17 |
diff --git a/pym/portage/sync/modules/websync/websync.py b/pym/portage/sync/modules/websync/websync.py |
18 |
index 3576116..17f4ced 100644 |
19 |
--- a/pym/portage/sync/modules/websync/websync.py |
20 |
+++ b/pym/portage/sync/modules/websync/websync.py |
21 |
@@ -32,7 +32,7 @@ class WebRsync(SyncBase): |
22 |
if kwargs: |
23 |
self._kwargs(kwargs) |
24 |
|
25 |
- if not self.has_bin: |
26 |
+ if not self._has_bin: |
27 |
return (1, False) |
28 |
|
29 |
emerge_config = self.options.get('emerge_config', None) |
30 |
|
31 |
diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py |
32 |
index c820bcf..229927f 100644 |
33 |
--- a/pym/portage/sync/syncbase.py |
34 |
+++ b/pym/portage/sync/syncbase.py |
35 |
@@ -35,17 +35,27 @@ class SyncBase(object): |
36 |
self.xterm_titles = None |
37 |
self.spawn_kwargs = None |
38 |
self.bin_command = None |
39 |
- self.has_bin = False |
40 |
+ self._bin_command = bin_command |
41 |
+ self.bin_pkg = bin_pkg |
42 |
if bin_command: |
43 |
self.bin_command = portage.process.find_binary(bin_command) |
44 |
- if self.bin_command is None: |
45 |
- msg = ["Command not found: %s" % bin_command, |
46 |
- "Type \"emerge %s\" to enable %s support." % (bin_pkg, bin_command)] |
47 |
- for l in msg: |
48 |
- writemsg_level("!!! %s\n" % l, |
49 |
- level=self.logger.ERROR, noiselevel=-1) |
50 |
- else: |
51 |
- self.has_bin = True |
52 |
+ |
53 |
+ |
54 |
+ @property |
55 |
+ def _has_bin(self): |
56 |
+ '''Checks for existance of the external binary. |
57 |
+ |
58 |
+ MUST only be called after _kwargs() has set the logger |
59 |
+ ''' |
60 |
+ if self.bin_command is None: |
61 |
+ msg = ["Command not found: %s" % self._bin_command, |
62 |
+ "Type \"emerge %s\" to enable %s support." |
63 |
+ % (self.bin_pkg, self._bin_command)] |
64 |
+ for l in msg: |
65 |
+ writemsg_level("!!! %s\n" % l, |
66 |
+ level=self.logger.ERROR, noiselevel=-1) |
67 |
+ return False |
68 |
+ return True |
69 |
|
70 |
|
71 |
def _kwargs(self, kwargs): |
72 |
@@ -106,7 +116,7 @@ class NewBase(SyncBase): |
73 |
if kwargs: |
74 |
self._kwargs(kwargs) |
75 |
|
76 |
- if not self.has_bin: |
77 |
+ if not self._has_bin: |
78 |
return (1, False) |
79 |
|
80 |
if not self.exists(): |