Merge lp:~flexiondotorg/deja-dup-caja/bug-fixes into lp:deja-dup-caja
- bug-fixes
- Merge into trunk
Proposed by
Martin Wimpress
Status: | Merged |
---|---|
Merged at revision: | 23 |
Proposed branch: | lp:~flexiondotorg/deja-dup-caja/bug-fixes |
Merge into: | lp:deja-dup-caja |
Diff against target: |
272 lines (+50/-54) 3 files modified
README (+14/-10) caja-extension/dejadup.py (+31/-38) setup.py (+5/-6) |
To merge this branch: | bzr merge lp:~flexiondotorg/deja-dup-caja/bug-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
costales | Pending | ||
Review via email:
|
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
costales (costales) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' | |||
2 | --- README 2019-06-02 07:07:30 +0000 | |||
3 | +++ README 2021-04-07 10:32:33 +0000 | |||
4 | @@ -1,26 +1,30 @@ | |||
5 | 1 | Deja Dup Caja © 2015-2019 Marcos Alvarez Costales | 1 | Deja Dup Caja © 2015-2019 Marcos Alvarez Costales |
7 | 2 | ============================================ | 2 | ================================================= |
8 | 3 | 3 | ||
9 | 4 | WHAT IS IT? | 4 | WHAT IS IT? |
10 | 5 | =========== | 5 | =========== |
13 | 6 | A Caja extension for backup/restore files/folders in an easy way from a contextual menu. | 6 | A Caja extension to backup/restore files/folders in an easy way from a contextual menu. |
12 | 7 | |||
14 | 8 | 7 | ||
15 | 9 | 8 | ||
16 | 10 | HOW DO I INSTALL & RUN IT? | 9 | HOW DO I INSTALL & RUN IT? |
17 | 11 | ========================== | 10 | ========================== |
23 | 12 | From a PPA: | 11 | |
24 | 13 | # add-apt-repository ppa:costales/deja-dup-caja | 12 | For Ubuntu |
25 | 14 | # apt-get update && sudo apt-get install deja-dup-caja | 13 | |
26 | 15 | From the code (take a look to the dependencies): | 14 | $ sudo apt install deja-dup-caja |
27 | 16 | $ bzr branch lp:deja-dup-caja && cd deja-dup-caja && sudo python setup.py install --prefix=/usr | 15 | |
28 | 16 | From source (see dependencies below) | ||
29 | 17 | |||
30 | 18 | $ bzr branch lp:deja-dup-caja | ||
31 | 19 | $ cd deja-dup-caja | ||
32 | 20 | $ sudo python3 setup.py install --prefix=/usr | ||
33 | 17 | 21 | ||
34 | 18 | Then, restart Caja | 22 | Then, restart Caja |
35 | 23 | |||
36 | 19 | $ caja -q | 24 | $ caja -q |
37 | 20 | 25 | ||
38 | 21 | 26 | ||
39 | 22 | |||
40 | 23 | DEPENDENCIES | 27 | DEPENDENCIES |
41 | 24 | ============ | 28 | ============ |
42 | 25 | For Caja: | 29 | For Caja: |
44 | 26 | python-caja, caja, gir1.2-caja, libgtk2.0-bin | 30 | caja, deja-dup, gir1.2-caja-2.0, gir1.2-gtk-3.0, python3-caja |
45 | 27 | 31 | ||
46 | === modified file 'caja-extension/dejadup.py' | |||
47 | --- caja-extension/dejadup.py 2019-06-03 16:47:16 +0000 | |||
48 | +++ caja-extension/dejadup.py 2021-04-07 10:32:33 +0000 | |||
49 | @@ -1,5 +1,5 @@ | |||
50 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
52 | 2 | # Deja Dup Caja 0.0.8 | 2 | # Deja Dup Caja 0.0.9 |
53 | 3 | # Copyright (C) 2015-2019 Marcos Alvarez Costales https://launchpad.net/~costales | 3 | # Copyright (C) 2015-2019 Marcos Alvarez Costales https://launchpad.net/~costales |
54 | 4 | # Copyright (C) 2015 Ubuntu MATE Project https://ubuntu-mate.org/ | 4 | # Copyright (C) 2015 Ubuntu MATE Project https://ubuntu-mate.org/ |
55 | 5 | # | 5 | # |
56 | @@ -7,12 +7,12 @@ | |||
57 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
58 | 8 | # the Free Software Foundation; either version 3 of the License, or | 8 | # the Free Software Foundation; either version 3 of the License, or |
59 | 9 | # (at your option) any later version. | 9 | # (at your option) any later version. |
61 | 10 | # | 10 | # |
62 | 11 | # Deja Dup Caja is distributed in the hope that it will be useful, | 11 | # Deja Dup Caja is distributed in the hope that it will be useful, |
63 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
64 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
65 | 14 | # GNU General Public License for more details. | 14 | # GNU General Public License for more details. |
67 | 15 | # | 15 | # |
68 | 16 | # You should have received a copy of the GNU General Public License | 16 | # You should have received a copy of the GNU General Public License |
69 | 17 | # along with Deja Dup Caja; if not, see http://www.gnu.org/licenses | 17 | # along with Deja Dup Caja; if not, see http://www.gnu.org/licenses |
70 | 18 | # for more information. | 18 | # for more information. |
71 | @@ -34,7 +34,7 @@ | |||
72 | 34 | class DejaDup: | 34 | class DejaDup: |
73 | 35 | def __init__(self): | 35 | def __init__(self): |
74 | 36 | pass | 36 | pass |
76 | 37 | 37 | ||
77 | 38 | def _run_cmd(self, cmd, background=True): | 38 | def _run_cmd(self, cmd, background=True): |
78 | 39 | """Run command into shell""" | 39 | """Run command into shell""" |
79 | 40 | if background: | 40 | if background: |
80 | @@ -43,44 +43,41 @@ | |||
81 | 43 | proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 43 | proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
82 | 44 | stdout,stderr = proc.communicate() | 44 | stdout,stderr = proc.communicate() |
83 | 45 | return stdout,stderr | 45 | return stdout,stderr |
85 | 46 | 46 | ||
86 | 47 | def backup(self, item): | 47 | def backup(self, item): |
87 | 48 | """Call to backup""" | 48 | """Call to backup""" |
88 | 49 | self._run_cmd(['deja-dup', '--backup', item]) | 49 | self._run_cmd(['deja-dup', '--backup', item]) |
90 | 50 | 50 | ||
91 | 51 | def restore(self, item): | 51 | def restore(self, item): |
92 | 52 | """Call to restore""" | 52 | """Call to restore""" |
93 | 53 | self._run_cmd(['deja-dup', '--restore', item]) | 53 | self._run_cmd(['deja-dup', '--restore', item]) |
99 | 54 | 54 | ||
95 | 55 | def restore_missing(self, item): | ||
96 | 56 | """Call to restore""" | ||
97 | 57 | self._run_cmd(['deja-dup', '--restore-missing', item]) | ||
98 | 58 | |||
100 | 59 | def get_dejadup_paths(self, type_list): | 55 | def get_dejadup_paths(self, type_list): |
101 | 60 | """Get include/exclude paths from Deja Dup""" | 56 | """Get include/exclude paths from Deja Dup""" |
102 | 61 | new_paths = [] | 57 | new_paths = [] |
104 | 62 | 58 | ||
105 | 63 | cmd = ['gsettings', 'get', 'org.gnome.DejaDup', type_list] | 59 | cmd = ['gsettings', 'get', 'org.gnome.DejaDup', type_list] |
106 | 64 | stdout,stderr = self._run_cmd(cmd, False) | 60 | stdout,stderr = self._run_cmd(cmd, False) |
108 | 65 | 61 | ||
109 | 66 | # Error | 62 | # Error |
110 | 67 | if stderr: | 63 | if stderr: |
111 | 68 | return [] | 64 | return [] |
112 | 69 | # OK | 65 | # OK |
114 | 70 | paths = ast.literal_eval([stdout][0]) # Convert shell dump to list | 66 | stdout_str = [stdout][0].decode() # With python3 needs this convertion |
115 | 67 | paths = ast.literal_eval(stdout_str) # Convert shell dump to list | ||
116 | 71 | for path in paths: | 68 | for path in paths: |
117 | 72 | try: # Is a shell variable? | 69 | try: # Is a shell variable? |
118 | 73 | new_paths.append(os.environ[path.replace('$', '')]) | 70 | new_paths.append(os.environ[path.replace('$', '')]) |
119 | 74 | except: | 71 | except: |
120 | 75 | new_paths.append(path) | 72 | new_paths.append(path) |
122 | 76 | 73 | ||
123 | 77 | return new_paths | 74 | return new_paths |
124 | 78 | 75 | ||
125 | 79 | 76 | ||
126 | 80 | class Utils: | 77 | class Utils: |
127 | 81 | def __init__(self): | 78 | def __init__(self): |
128 | 82 | pass | 79 | pass |
130 | 83 | 80 | ||
131 | 84 | def get_filepath(self, items): | 81 | def get_filepath(self, items): |
132 | 85 | """Get just the path from a complete path and filename""" | 82 | """Get just the path from a complete path and filename""" |
133 | 86 | try: | 83 | try: |
134 | @@ -88,7 +85,7 @@ | |||
135 | 88 | except: | 85 | except: |
136 | 89 | item = items | 86 | item = items |
137 | 90 | return unquote(item.get_uri()[7:]) | 87 | return unquote(item.get_uri()[7:]) |
139 | 91 | 88 | ||
140 | 92 | def search_paths(self, item_path, paths): | 89 | def search_paths(self, item_path, paths): |
141 | 93 | """Check if at least one path is in the pattern path""" | 90 | """Check if at least one path is in the pattern path""" |
142 | 94 | for path in paths: | 91 | for path in paths: |
143 | @@ -101,61 +98,57 @@ | |||
144 | 101 | def __init__(self): | 98 | def __init__(self): |
145 | 102 | self.dejadup = DejaDup() | 99 | self.dejadup = DejaDup() |
146 | 103 | self.utils = Utils() | 100 | self.utils = Utils() |
148 | 104 | 101 | ||
149 | 105 | def _backup_activate(self, menu, item): | 102 | def _backup_activate(self, menu, item): |
150 | 106 | """Backup file or folder""" | 103 | """Backup file or folder""" |
151 | 107 | self.dejadup.backup(item) | 104 | self.dejadup.backup(item) |
153 | 108 | 105 | ||
154 | 109 | def _restore_activate(self, menu, item): | 106 | def _restore_activate(self, menu, item): |
155 | 110 | """Restore file or folder""" | 107 | """Restore file or folder""" |
156 | 111 | self.dejadup.restore(item) | 108 | self.dejadup.restore(item) |
162 | 112 | 109 | ||
158 | 113 | def _missing_activate(self, menu, item): | ||
159 | 114 | """Missing items""" | ||
160 | 115 | self.dejadup.restore_missing(item) | ||
161 | 116 | |||
163 | 117 | def _previous_checks(self, items): | 110 | def _previous_checks(self, items): |
164 | 118 | """Checks before generate the contextual menu""" | 111 | """Checks before generate the contextual menu""" |
165 | 119 | # Show only for 1 item selected | 112 | # Show only for 1 item selected |
166 | 120 | if len(items) != 1: | 113 | if len(items) != 1: |
167 | 121 | return False | 114 | return False |
168 | 122 | item = items[0] | 115 | item = items[0] |
170 | 123 | 116 | ||
171 | 124 | # Check exists yet | 117 | # Check exists yet |
172 | 125 | if item.is_gone(): | 118 | if item.is_gone(): |
173 | 126 | return False | 119 | return False |
175 | 127 | 120 | ||
176 | 128 | # Only handle files | 121 | # Only handle files |
177 | 129 | if item.get_uri_scheme() != 'file': | 122 | if item.get_uri_scheme() != 'file': |
178 | 130 | return False | 123 | return False |
180 | 131 | 124 | ||
181 | 132 | return True | 125 | return True |
183 | 133 | 126 | ||
184 | 134 | def get_background_items(self, window, current_folder): | 127 | def get_background_items(self, window, current_folder): |
185 | 135 | """Caja invoke this when user clicks in an empty area""" | 128 | """Caja invoke this when user clicks in an empty area""" |
186 | 136 | Menu = Caja.MenuItem( | 129 | Menu = Caja.MenuItem( |
189 | 137 | name="DejaDupCajaMenu::Missing", | 130 | name="DejaDupCajaMenu::Restore", |
190 | 138 | label=_("Restore Missing Files..."), | 131 | label=_("Revert to Previous Version..."), |
191 | 139 | icon="deja-dup") | 132 | icon="deja-dup") |
193 | 140 | 133 | ||
194 | 141 | # Get complete path | 134 | # Get complete path |
195 | 142 | item = self.utils.get_filepath(current_folder) | 135 | item = self.utils.get_filepath(current_folder) |
198 | 143 | 136 | ||
199 | 144 | Menu.connect('activate', self._missing_activate, item) | 137 | Menu.connect('activate', self._restore_activate, item) |
200 | 145 | return [Menu] | 138 | return [Menu] |
202 | 146 | 139 | ||
203 | 147 | def get_file_items(self, window, selected_items): | 140 | def get_file_items(self, window, selected_items): |
204 | 148 | """Caja invoke this when user clicks in a file or folder""" | 141 | """Caja invoke this when user clicks in a file or folder""" |
205 | 149 | if not self._previous_checks(selected_items): | 142 | if not self._previous_checks(selected_items): |
206 | 150 | return | 143 | return |
208 | 151 | 144 | ||
209 | 152 | # Get complete path | 145 | # Get complete path |
210 | 153 | item = self.utils.get_filepath(selected_items) | 146 | item = self.utils.get_filepath(selected_items) |
212 | 154 | 147 | ||
213 | 155 | # Get paths | 148 | # Get paths |
214 | 156 | include_paths = self.dejadup.get_dejadup_paths('include-list') | 149 | include_paths = self.dejadup.get_dejadup_paths('include-list') |
215 | 157 | exclude_paths = self.dejadup.get_dejadup_paths('exclude-list') | 150 | exclude_paths = self.dejadup.get_dejadup_paths('exclude-list') |
217 | 158 | 151 | ||
218 | 159 | # Check backup or restore menu entry | 152 | # Check backup or restore menu entry |
219 | 160 | # Is the path into the exclude? > Backup | 153 | # Is the path into the exclude? > Backup |
220 | 161 | if self.utils.search_paths(item, exclude_paths): | 154 | if self.utils.search_paths(item, exclude_paths): |
221 | @@ -166,7 +159,7 @@ | |||
222 | 166 | # Not include/exclude > Backup | 159 | # Not include/exclude > Backup |
223 | 167 | else: | 160 | else: |
224 | 168 | backup = True | 161 | backup = True |
226 | 169 | 162 | ||
227 | 170 | # Generate menu and trigger event | 163 | # Generate menu and trigger event |
228 | 171 | if backup: | 164 | if backup: |
229 | 172 | Menu = Caja.MenuItem( | 165 | Menu = Caja.MenuItem( |
230 | 173 | 166 | ||
231 | === modified file 'setup.py' | |||
232 | --- setup.py 2019-06-03 16:47:16 +0000 | |||
233 | +++ setup.py 2021-04-07 10:32:33 +0000 | |||
234 | @@ -1,6 +1,6 @@ | |||
235 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
236 | 2 | 2 | ||
238 | 3 | # Deja Dup Caja 0.0.8 - http://launchpad.net/deja-dup-caja | 3 | # Deja Dup Caja 0.0.9 - http://launchpad.net/deja-dup-caja |
239 | 4 | # Copyright (C) 2015-2019 Marcos Alvarez Costales https://launchpad.net/~costales | 4 | # Copyright (C) 2015-2019 Marcos Alvarez Costales https://launchpad.net/~costales |
240 | 5 | # Copyright (C) 2015 Ubuntu MATE https://ubuntu-mate.org/ | 5 | # Copyright (C) 2015 Ubuntu MATE https://ubuntu-mate.org/ |
241 | 6 | # | 6 | # |
242 | @@ -8,14 +8,14 @@ | |||
243 | 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
244 | 9 | # the Free Software Foundation; either version 3 of the License, or | 9 | # the Free Software Foundation; either version 3 of the License, or |
245 | 10 | # (at your option) any later version. | 10 | # (at your option) any later version. |
247 | 11 | # | 11 | # |
248 | 12 | # Deja Dup Caja is distributed in the hope that it will be useful, | 12 | # Deja Dup Caja is distributed in the hope that it will be useful, |
249 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
250 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
251 | 15 | # GNU General Public License for more details. | 15 | # GNU General Public License for more details. |
253 | 16 | # | 16 | # |
254 | 17 | # You should have received a copy of the GNU General Public License | 17 | # You should have received a copy of the GNU General Public License |
256 | 18 | # along with Deja Dup Caja; if not, see http://www.gnu.org/licenses | 18 | # along with Deja Dup Caja; if not, see http://www.gnu.org/licenses |
257 | 19 | # for more information. | 19 | # for more information. |
258 | 20 | 20 | ||
259 | 21 | 21 | ||
260 | @@ -27,12 +27,11 @@ | |||
261 | 27 | # Setup stage | 27 | # Setup stage |
262 | 28 | DistUtilsExtra.auto.setup( | 28 | DistUtilsExtra.auto.setup( |
263 | 29 | name = "deja-dup-caja", | 29 | name = "deja-dup-caja", |
265 | 30 | version = "0.0.6", | 30 | version = "0.0.9", |
266 | 31 | description = "Backup/Restore your files from Caja File Browser", | 31 | description = "Backup/Restore your files from Caja File Browser", |
267 | 32 | author = "Marcos Alvarez Costales https://launchpad.net/~costales", | 32 | author = "Marcos Alvarez Costales https://launchpad.net/~costales", |
268 | 33 | author_email = "https://launchpad.net/~costales", | 33 | author_email = "https://launchpad.net/~costales", |
269 | 34 | url = "https://launchpad.net/deja-dup-caja", | 34 | url = "https://launchpad.net/deja-dup-caja", |
270 | 35 | license = "GPL3", | 35 | license = "GPL3", |
271 | 36 | data_files = data | ||
272 | 37 | ) | 36 | ) |
273 | 38 | 37 |
Thanks Martin!