Merge lp:~rmjb/backintime/bug-388178 into lp:backintime/1.0

Proposed by Richard Bailey
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rmjb/backintime/bug-388178
Merge into: lp:backintime/1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~rmjb/backintime/bug-388178
Reviewer Review Type Date Requested Status
Dan Pending
Review via email: mp+10781@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2009-05-27 14:52:37 +0000
3+++ CHANGES 2009-08-27 01:38:19 +0000
4@@ -3,6 +3,7 @@
5 Version 1.0.0
6 * update Slovak translation (Tomáš Vadina <kyberdev@gmail.com>)
7 * multiple profiles support
8+* added expert option to disable snapshots when on battery
9 * GNOME: fix notification
10 * fix small bugs
11
12
13=== modified file 'common/config.py'
14--- common/config.py 2009-06-23 07:18:58 +0000
15+++ common/config.py 2009-08-27 01:38:19 +0000
16@@ -349,6 +349,12 @@
17 def set_run_nice_from_cron_enabled( self, value, profile_id = None ):
18 self.set_profile_bool_value( 'snapshots.cron.nice', value, profile_id )
19
20+ def is_no_on_battery_enabled( self, profile_id = None ):
21+ return self.get_profile_bool_value( 'snapshots.no_on_battery', False, profile_id )
22+
23+ def set_no_on_battery_enabled( self, value, profile_id = None ):
24+ self.set_profile_bool_value( 'snapshots.no_on_battery', value, profile_id )
25+
26 def get_take_snapshot_user_script( self, step, profile_id = None ):
27 return self.get_str_value( "snapshots.take_snapshot.%s.user.script" % step, profile_id )
28
29
30=== modified file 'common/debian_specific/control'
31--- common/debian_specific/control 2009-06-23 07:18:58 +0000
32+++ common/debian_specific/control 2009-08-27 01:38:19 +0000
33@@ -6,6 +6,7 @@
34 Architecture: all
35 Homepage: http://backintime.le-web.org
36 Depends: python, rsync, cron
37+Recommends: powermgmt-base
38 Conflicts: backintime
39 Replaces: backintime
40 Description: Simple backup system (common)
41
42=== modified file 'common/snapshots.py'
43--- common/snapshots.py 2009-05-14 13:27:37 +0000
44+++ common/snapshots.py 2009-08-27 01:38:19 +0000
45@@ -371,12 +371,18 @@
46 if not self.config.is_configured():
47 logger.warning( 'Not configured' )
48 self.plugin_manager.on_error( 1 ) #not configured
49+ elif self.config.is_no_on_battery_enabled() and tools.on_battery():
50+ logger.info( 'Deferring backup while on battery' )
51+ logger.warning( 'Backup not performed' )
52 else:
53 instance = applicationinstance.ApplicationInstance( self.config.get_take_snapshot_instance_file(), False )
54 if not instance.check():
55 logger.warning( 'A backup is already running' )
56 self.plugin_manager.on_error( 2 ) #a backup is already running
57 else:
58+ if self.config.is_no_on_battery_enabled () and not tools.power_status_available():
59+ logger.warning( 'Backups disabled on battery but power status is not available' )
60+
61 instance.start_application()
62 logger.info( 'Lock' )
63
64
65=== modified file 'common/tools.py'
66--- common/tools.py 2009-06-10 11:33:16 +0000
67+++ common/tools.py 2009-08-27 01:38:19 +0000
68@@ -19,7 +19,12 @@
69 import os.path
70 import os
71 import sys
72-
73+import subprocess
74+
75+
76+ON_AC = 0
77+ON_BATTERY = 1
78+POWER_ERROR = 255
79
80 def get_backintime_path( path ):
81 return os.path.join( os.path.dirname( os.path.abspath( os.path.dirname( __file__ ) ) ), path )
82@@ -117,3 +122,22 @@
83 return path
84
85
86+def power_status_available():
87+ """Uses the on_ac_power command to detect if the the system is able
88+ to return the power status."""
89+ try:
90+ rt = subprocess.call( 'on_ac_power' )
91+ if rt == ON_AC or rt == ON_BATTERY:
92+ return True
93+ except:
94+ pass
95+ return False
96+
97+
98+def on_battery():
99+ """Checks if the system is on battery power."""
100+ if power_status_available ():
101+ return subprocess.call ( 'on_ac_power' ) == ON_BATTERY
102+ else:
103+ return False
104+
105
106=== modified file 'gnome/settingsdialog.glade'
107--- gnome/settingsdialog.glade 2009-05-27 12:43:59 +0000
108+++ gnome/settingsdialog.glade 2009-08-27 01:38:19 +0000
109@@ -658,11 +658,25 @@
110 </packing>
111 </child>
112 <child>
113+ <widget class="GtkCheckButton" id="cb_no_on_battery">
114+ <property name="label" translatable="yes">Disable snapshots when on battery</property>
115+ <property name="visible">True</property>
116+ <property name="can_focus">True</property>
117+ <property name="receives_default">False</property>
118+ <property name="has_tooltip">True</property>
119+ <property name="draw_indicator">True</property>
120+ </widget>
121+ <packing>
122+ <property name="expand">False</property>
123+ <property name="position">3</property>
124+ </packing>
125+ </child>
126+ <child>
127 <widget class="GtkLabel" id="label16">
128 <property name="visible">True</property>
129 </widget>
130 <packing>
131- <property name="position">3</property>
132+ <property name="position">4</property>
133 </packing>
134 </child>
135 </widget>
136
137=== modified file 'gnome/settingsdialog.py'
138--- gnome/settingsdialog.py 2009-06-10 11:33:16 +0000
139+++ gnome/settingsdialog.py 2009-08-27 01:38:19 +0000
140@@ -206,6 +206,12 @@
141
142 #enable notifications
143 self.cb_enable_notifications = self.glade.get_widget( 'cb_enable_notifications' )
144+
145+ #don't run when on battery
146+ self.cb_no_on_battery = self.glade.get_widget( 'cb_no_on_battery' )
147+ if not tools.power_status_available ():
148+ self.cb_no_on_battery.set_sensitive( False )
149+ self.cb_no_on_battery.set_tooltip_text( 'Power status not available from system' )
150
151 self.update_profiles()
152
153@@ -358,6 +364,9 @@
154 #run 'nice' from cron
155 self.cb_run_nice_from_cron = self.glade.get_widget( 'cb_run_nice_from_cron' )
156 self.cb_run_nice_from_cron.set_active( self.config.is_run_nice_from_cron_enabled() )
157+
158+ #don't run when on battery
159+ self.cb_no_on_battery.set_active( self.config.is_no_on_battery_enabled() )
160
161 def save_profile( self ):
162 #snapshots path
163@@ -416,6 +425,7 @@
164 #expert options
165 self.config.set_per_directory_schedule( self.cb_per_directory_schedule.get_active() )
166 self.config.set_run_nice_from_cron_enabled( self.cb_run_nice_from_cron.get_active() )
167+ self.config.set_no_on_battery_enabled( self.cb_no_on_battery.get_active() )
168
169 def update_remove_old_backups( self, button ):
170 enabled = self.cb_remove_old_backup.get_active()
171
172=== modified file 'kde4/settingsdialog.py'
173--- kde4/settingsdialog.py 2009-06-23 08:37:33 +0000
174+++ kde4/settingsdialog.py 2009-08-27 01:38:19 +0000
175@@ -30,6 +30,7 @@
176 from PyKDE4.kio import *
177
178 import config
179+import tools
180 import kde4tools
181
182
183@@ -265,6 +266,12 @@
184 self.cb_run_nice_from_cron = QCheckBox( QString.fromUtf8( _( 'Run \'nice\' as cron job (default: enabled)' ) ), self )
185 layout.addWidget( self.cb_run_nice_from_cron )
186
187+ self.cb_no_on_battery = QCheckBox( QString.fromUtf8( _( 'Disable snapshots when on battery' ) ), self )
188+ if not tools.power_status_available ():
189+ self.cb_no_on_battery.setEnabled ( False )
190+ self.cb_no_on_battery.setToolTip ( QString.fromUtf8 ( _( 'Power status not available from system' ) ) )
191+ layout.addWidget( self.cb_no_on_battery )
192+
193 #
194 layout.addStretch()
195
196@@ -382,6 +389,7 @@
197 #TAB: Expert Options
198 self.cb_per_diretory_schedule.setChecked( self.config.get_per_directory_schedule() )
199 self.cb_run_nice_from_cron.setChecked( self.config.is_run_nice_from_cron_enabled() )
200+ self.cb_no_on_battery.setChecked( self.config.is_no_on_battery_enabled() )
201
202 #update
203 self.update_include_columns()
204@@ -428,6 +436,7 @@
205 #expert options
206 self.config.set_per_directory_schedule( self.cb_per_diretory_schedule.isChecked() )
207 self.config.set_run_nice_from_cron_enabled( self.cb_run_nice_from_cron.isChecked() )
208+ self.config.set_no_on_battery_enabled( self.cb_no_on_battery.isChecked() )
209
210 def error_handler( self, message ):
211 KMessageBox.error( self, QString.fromUtf8( message ) )

Subscribers

People subscribed via source and target branches