Merge lp:~flexiondotorg/deja-dup-caja/bug-fixes into lp:deja-dup-caja

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
Reviewer Review Type Date Requested Status
costales Pending
Review via email: mp+400693@code.launchpad.net

Commit message

This merge proposal fixes several bugs.

 * Bump version to 0.0.9 (LP: #1868124)
 * Make Python 3 compatible. (LP: #1863498)
 * Drop Restore Missing, no longer a feature of deja-dup. (LP: #1885063)

To post a comment you must log in.
Revision history for this message
costales (costales) wrote :

Thanks Martin!

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

Subscribers

People subscribed via source and target branches