Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/rsync/
Date: Fri, 02 May 2014 23:13:39
Message-Id: 1399071915.624b13e36a57293450bc957a2022998198624a7b.dol-sen@gentoo
1 commit: 624b13e36a57293450bc957a2022998198624a7b
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 14 15:42:16 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Fri May 2 23:05:15 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=624b13e3
7
8 portage/sync/modules/rsync: Use SyncBase class.
9
10 ---
11 pym/portage/sync/modules/rsync/rsync.py | 54 +++++----------------------------
12 1 file changed, 7 insertions(+), 47 deletions(-)
13
14 diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py
15 index 7122db8..0cdf414 100644
16 --- a/pym/portage/sync/modules/rsync/rsync.py
17 +++ b/pym/portage/sync/modules/rsync/rsync.py
18 @@ -17,13 +17,14 @@ from portage.output import create_color_func, yellow, blue, bold
19 good = create_color_func("GOOD")
20 bad = create_color_func("BAD")
21 warn = create_color_func("WARN")
22 -from portage.const import VCS_DIRS, TIMESTAMP_FORMAT
23 +from portage.const import VCS_DIRS, TIMESTAMP_FORMAT, RSYNC_PACKAGE_ATOM
24 from portage.util import writemsg, writemsg_stdout
25 from portage.sync.getaddrinfo_validate import getaddrinfo_validate
26 from _emerge.userquery import userquery
27 +from portage.sync.syncbase import SyncBase
28
29
30 -class RsyncSync(object):
31 +class RsyncSync(SyncBase):
32 '''Rsync sync module'''
33
34 short_desc = "Perform sync operations on rsync based repositories"
35 @@ -33,40 +34,13 @@ class RsyncSync(object):
36 return "RsyncSync"
37
38
39 - def can_progressbar(self, func):
40 - return False
41 -
42 -
43 def __init__(self):
44 - self.settings = None
45 - self.logger = None
46 - self.repo = None
47 - self.options = None
48 - self.xterm_titles = None
49 -
50 -
51 - def _kwargs(self, kwargs):
52 - self.options = kwargs.get('options', {})
53 - self.settings = self.options.get('settings', None)
54 - self.logger = self.options.get('logger', None)
55 - self.repo = self.options.get('repo', None)
56 - self.xterm_titles = self.options.get('xterm_titles', False)
57 -
58 -
59 - def sync(self, **kwargs):
60 - '''Rsync the repo'''
61 - if kwargs:
62 - self._kwargs(kwargs)
63 -
64 - if not self.exists():
65 - return self.new()
66 - return self._sync()
67 + SyncBase.__init__(self, "rsync", RSYNC_PACKAGE_ATOM)
68
69
70 def _sync(self):
71 '''Internal sync function which performs only the sync'''
72 myopts = self.options.get('emerge_config').opts
73 - spawn_kwargs = self.options.get('spawn_kwargs', None)
74 usersync_uid = self.options.get('usersync_uid', None)
75 enter_invalid = '--ask-enter-invalid' in myopts
76 out = portage.output.EOutput()
77 @@ -81,11 +55,6 @@ class RsyncSync(object):
78 "control (contains %s).\n!!! Aborting rsync sync.\n") % \
79 (self.repo.location, vcs_dir), level=logging.ERROR, noiselevel=-1)
80 return (1, False)
81 - rsync_binary = portage.process.find_binary("rsync")
82 - if rsync_binary is None:
83 - print("!!! /usr/bin/rsync does not exist, so rsync support is disabled.")
84 - print("!!! Type \"emerge %s\" to enable rsync support." % portage.const.RSYNC_PACKAGE_ATOM)
85 - return (os.EX_UNAVAILABLE, False)
86 mytimeout=180
87
88 rsync_opts = []
89 @@ -313,7 +282,7 @@ class RsyncSync(object):
90 if mytimestamp != 0 and "--quiet" not in myopts:
91 print(">>> Checking server timestamp ...")
92
93 - rsynccommand = [rsync_binary] + rsync_opts + extra_rsync_opts
94 + rsynccommand = [self.bin_command] + rsync_opts + extra_rsync_opts
95
96 if proto == 'ssh' and ssh_opts:
97 rsynccommand.append("--rsh=ssh " + ssh_opts)
98 @@ -363,7 +332,7 @@ class RsyncSync(object):
99
100 mypids.extend(portage.process.spawn(
101 mycommand, returnpid=True,
102 - **portage._native_kwargs(spawn_kwargs)))
103 + **portage._native_kwargs(self.spawn_kwargs)))
104 exitcode = os.waitpid(mypids[0], 0)[1]
105 if usersync_uid is not None:
106 portage.util.apply_permissions(tmpservertimestampfile,
107 @@ -431,7 +400,7 @@ class RsyncSync(object):
108 exitcode = None
109 try:
110 exitcode = portage.process.spawn(mycommand,
111 - **portage._native_kwargs(spawn_kwargs))
112 + **portage._native_kwargs(self.spawn_kwargs))
113 finally:
114 if exitcode is None:
115 # interrupted
116 @@ -509,15 +478,6 @@ class RsyncSync(object):
117 return (exitcode, updatecache_flg)
118
119
120 - def exists(self, **kwargs):
121 - if kwargs:
122 - self._kwargs(kwargs)
123 - elif not self.repo:
124 - return False
125 - return os.path.exists(self.repo.location)
126 -
127 -
128 -
129 def new(self, **kwargs):
130 if kwargs:
131 self._kwargs(kwargs)