1 |
commit: cddccc60e653cad0760553b44bedd8c7cd544fe7 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Feb 8 01:50:23 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Sat Feb 8 02:13:48 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cddccc60 |
7 |
|
8 |
Rsync module, add exists() and new() |
9 |
|
10 |
--- |
11 |
pym/portage/sync/modules/rsync/rsync.py | 27 +++++++++++++++++++++++++++ |
12 |
1 file changed, 27 insertions(+) |
13 |
|
14 |
diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py |
15 |
index de561ad..12b4c9c 100644 |
16 |
--- a/pym/portage/sync/modules/rsync/rsync.py |
17 |
+++ b/pym/portage/sync/modules/rsync/rsync.py |
18 |
@@ -60,6 +60,10 @@ class RsyncSync(object): |
19 |
spawn_kwargs = self.options.get('spawn_kwargs', None) |
20 |
usersync_uid = self.options.get('usersync_uid', None) |
21 |
|
22 |
+ if not self.exists(): |
23 |
+ if not self.new(): |
24 |
+ return (1, False) |
25 |
+ |
26 |
enter_invalid = '--ask-enter-invalid' in myopts |
27 |
out = portage.output.EOutput() |
28 |
syncuri = self.repo.sync_uri |
29 |
@@ -499,3 +503,26 @@ class RsyncSync(object): |
30 |
for line in msg: |
31 |
out.eerror(line) |
32 |
return (exitcode, updatecache_flg) |
33 |
+ |
34 |
+ |
35 |
+ def exists(self, **kwargs): |
36 |
+ if kwargs: |
37 |
+ self._kwargs(kwargs) |
38 |
+ elif not self.repo: |
39 |
+ return False |
40 |
+ return os.path.exists(self.repo.location) |
41 |
+ |
42 |
+ |
43 |
+ |
44 |
+ def new(self, **kwargs): |
45 |
+ if kwargs: |
46 |
+ self._kwargs(kwargs) |
47 |
+ try: |
48 |
+ if not os.path.exists(self.repo.location): |
49 |
+ os.makedirs(self.repo.location) |
50 |
+ self.logger(self.self.xterm_titles, |
51 |
+ 'Created New Directory %s ' % self.repo.location ) |
52 |
+ except IOError: |
53 |
+ return False |
54 |
+ return True |
55 |
+ |