Merge lp://staging/~dpaleino/wicd/pre-post-down into lp://staging/wicd/1.6

Proposed by David Paleino
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~dpaleino/wicd/pre-post-down
Merge into: lp://staging/wicd/1.6
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~dpaleino/wicd/pre-post-down
Reviewer Review Type Date Requested Status
Dan O'Reilly Approve
Review via email: mp+7505@code.staging.launchpad.net

Commit message

Provide a pre-/post-down script mechanism

To post a comment you must log in.
Revision history for this message
Dan O'Reilly (oreilldf) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curses/configscript_curses.py'
--- curses/configscript_curses.py 2009-01-31 04:48:56 +0000
+++ curses/configscript_curses.py 2009-06-16 15:13:41 +0000
@@ -38,7 +38,8 @@
38language['configure_scripts'] = _("Configure Scripts")38language['configure_scripts'] = _("Configure Scripts")
39language['before_script'] = _("Pre-connection Script")39language['before_script'] = _("Pre-connection Script")
40language['after_script'] = _("Post-connection Script")40language['after_script'] = _("Post-connection Script")
41language['disconnect_script'] = _("Disconnection Script")41language['pre_disconnect_script'] = _("Pre-disconnection Script")
42language['post_disconnect_script'] = _("Post-disconnection Script")
4243
43def main(argv):44def main(argv):
44 global ui,frame45 global ui,frame
@@ -62,16 +63,19 @@
62 blank = urwid.Text('')63 blank = urwid.Text('')
63 pre_entry_t = ('body',language['before_script']+': ')64 pre_entry_t = ('body',language['before_script']+': ')
64 post_entry_t = ('body',language['after_script']+': ')65 post_entry_t = ('body',language['after_script']+': ')
65 disconnect_entry_t = ('body',language['disconnect_script']+': ')66 pre_disconnect_entry_t = ('body',language['pre_disconnect_script']+': ')
67 post_disconnect_entry_t = ('body',language['post_disconnect_script']+': ')
6668
67 global pre_entry,post_entry,disconnect_entry69 global pre_entry,post_entry,pre_disconnect_entry,post_disconnect_entry
68 pre_entry = urwid.AttrWrap(urwid.Edit(pre_entry_t,70 pre_entry = urwid.AttrWrap(urwid.Edit(pre_entry_t,
69 none_to_blank(script_info.get('pre_entry'))),'editbx','editfc' )71 none_to_blank(script_info.get('pre_entry'))),'editbx','editfc' )
70 post_entry = urwid.AttrWrap(urwid.Edit(post_entry_t,72 post_entry = urwid.AttrWrap(urwid.Edit(post_entry_t,
71 none_to_blank(script_info.get('post_entry'))),'editbx','editfc' )73 none_to_blank(script_info.get('post_entry'))),'editbx','editfc' )
7274
73 disconnect_entry = urwid.AttrWrap(urwid.Edit(disconnect_entry_t,75 pre_disconnect_entry = urwid.AttrWrap(urwid.Edit(pre_disconnect_entry_t,
74 none_to_blank(script_info.get('disconnect_entry'))),'editbx','editfc' )76 none_to_blank(script_info.get('pre_disconnect_entry'))),'editbx','editfc' )
77 post_disconnect_entry = urwid.AttrWrap(urwid.Edit(post_disconnect_entry_t,
78 none_to_blank(script_info.get('post_disconnect_entry'))),'editbx','editfc' )
7579
76 # The buttons80 # The buttons
77 ok_button = urwid.AttrWrap(urwid.Button('OK',ok_callback),'body','focus')81 ok_button = urwid.AttrWrap(urwid.Button('OK',ok_callback),'body','focus')
@@ -82,7 +86,8 @@
82 lbox = urwid.Pile([('fixed',2,urwid.Filler(pre_entry)),86 lbox = urwid.Pile([('fixed',2,urwid.Filler(pre_entry)),
83 #('fixed',urwid.Filler(blank),1),87 #('fixed',urwid.Filler(blank),1),
84 ('fixed',2,urwid.Filler(post_entry)),88 ('fixed',2,urwid.Filler(post_entry)),
85 ('fixed',2,urwid.Filler(disconnect_entry)),89 ('fixed',2,urwid.Filler(pre_disconnect_entry)),
90 ('fixed',2,urwid.Filler(post_disconnect_entry)),
86 #blank,blank,blank,blank,blank,91 #blank,blank,blank,blank,blank,
87 urwid.Filler(button_cols,'bottom')92 urwid.Filler(button_cols,'bottom')
88 ])93 ])
@@ -92,7 +97,8 @@
92 if result == True:97 if result == True:
93 script_info["pre_entry"] = blank_to_none(pre_entry.get_edit_text())98 script_info["pre_entry"] = blank_to_none(pre_entry.get_edit_text())
94 script_info["post_entry"] = blank_to_none(post_entry.get_edit_text())99 script_info["post_entry"] = blank_to_none(post_entry.get_edit_text())
95 script_info["disconnect_entry"] = blank_to_none(disconnect_entry.get_edit_text())100 script_info["pre_disconnect_entry"] = blank_to_none(pre_disconnect_entry.get_edit_text())
101 script_info["post_disconnect_entry"] = blank_to_none(post_disconnect_entry.get_edit_text())
96 write_scripts(network, network_type, script_info)102 write_scripts(network, network_type, script_info)
97103
98OK_PRESSED = False104OK_PRESSED = False
99105
=== modified file 'curses/wicd-curses.py'
--- curses/wicd-curses.py 2009-06-05 02:19:33 +0000
+++ curses/wicd-curses.py 2009-06-16 15:13:41 +0000
@@ -263,7 +263,7 @@
263# Translation needs to be changed to accomidate this text below.263# Translation needs to be changed to accomidate this text below.
264"""You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file. 264"""You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.
265265
266Once there, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information."""]266Once there, you can adjust (or add) the "beforescript", "afterscript", "predisconnectscript" and "postdisconnectscript" variables as needed, to change the preconnect, postconnect, predisconnect and postdisconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information."""]
267 dialog = TextDialog(theText,20,80)267 dialog = TextDialog(theText,20,80)
268 dialog.run(ui,parent)268 dialog.run(ui,parent)
269 # This code works with many distributions, but not all of them. So, to269 # This code works with many distributions, but not all of them. So, to
270270
=== modified file 'data/wicd.glade'
--- data/wicd.glade 2009-06-13 20:07:49 +0000
+++ data/wicd.glade 2009-06-16 15:13:41 +0000
@@ -342,18 +342,18 @@
342 <property name="visible">True</property>342 <property name="visible">True</property>
343 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>343 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
344 <child>344 <child>
345 <widget class="GtkLabel" id="disconnect_label">345 <widget class="GtkLabel" id="pre_disconnect_label">
346 <property name="width_request">150</property>346 <property name="width_request">150</property>
347 <property name="visible">True</property>347 <property name="visible">True</property>
348 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>348 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
349 <property name="label" translatable="yes">Disconnection Script:</property>349 <property name="label" translatable="yes">Pre-disconnection Script:</property>
350 </widget>350 </widget>
351 <packing>351 <packing>
352 <property name="position">0</property>352 <property name="position">0</property>
353 </packing>353 </packing>
354 </child>354 </child>
355 <child>355 <child>
356 <widget class="GtkEntry" id="disconnect_entry">356 <widget class="GtkEntry" id="pre_disconnect_entry">
357 <property name="visible">True</property>357 <property name="visible">True</property>
358 <property name="can_focus">True</property>358 <property name="can_focus">True</property>
359 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>359 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -370,6 +370,39 @@
370 <property name="position">3</property>370 <property name="position">3</property>
371 </packing>371 </packing>
372 </child>372 </child>
373 <child>
374 <widget class="GtkHBox" id="hbox10">
375 <property name="visible">True</property>
376 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
377 <child>
378 <widget class="GtkLabel" id="post_disconnect_label">
379 <property name="width_request">150</property>
380 <property name="visible">True</property>
381 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
382 <property name="label" translatable="yes">Post-disconnection Script:</property>
383 </widget>
384 <packing>
385 <property name="position">0</property>
386 </packing>
387 </child>
388 <child>
389 <widget class="GtkEntry" id="post_disconnect_entry">
390 <property name="visible">True</property>
391 <property name="can_focus">True</property>
392 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
393 </widget>
394 <packing>
395 <property name="position">1</property>
396 </packing>
397 </child>
398 </widget>
399 <packing>
400 <property name="expand">False</property>
401 <property name="fill">False</property>
402 <property name="padding">5</property>
403 <property name="position">4</property>
404 </packing>
405 </child>
373 </widget>406 </widget>
374 <packing>407 <packing>
375 <property name="position">1</property>408 <property name="position">1</property>
376409
=== modified file 'in/man=wicd-wired-settings.conf.5.in'
--- in/man=wicd-wired-settings.conf.5.in 2009-02-12 04:01:24 +0000
+++ in/man=wicd-wired-settings.conf.5.in 2009-06-16 15:13:41 +0000
@@ -33,8 +33,12 @@
33IMPORTANT - scripts should ONLY be writable by root and located in a33IMPORTANT - scripts should ONLY be writable by root and located in a
34directory that is only writable by root.34directory that is only writable by root.
35.TP35.TP
36.BI "disconnectscript = " <None|arbitrary_script>36.BI "predisconnectscript = " <None|arbitrary_script>
37This defines a script to run when Wicd disconnects the interface.37This defines a script to run before Wicd disconnects the interface.
38The script should be a Bourne-compatible script and should be executable.
39.TP
40.BI "postdisconnectscript = " <None|arbitrary_script>
41This defines a script to run after Wicd disconnects the interface.
38The script should be a Bourne-compatible script and should be executable.42The script should be a Bourne-compatible script and should be executable.
39.br43.br
40IMPORTANT - scripts should ONLY be writable by root and located in a44IMPORTANT - scripts should ONLY be writable by root and located in a
4145
=== modified file 'in/man=wicd-wireless-settings.conf.5.in'
--- in/man=wicd-wireless-settings.conf.5.in 2009-02-12 04:01:58 +0000
+++ in/man=wicd-wireless-settings.conf.5.in 2009-06-16 15:13:41 +0000
@@ -99,8 +99,11 @@
99IMPORTANT - scripts should ONLY be writable by root and located 99IMPORTANT - scripts should ONLY be writable by root and located
100in a directory that is writable by only root.100in a directory that is writable by only root.
101.TP101.TP
102.BI "disconnectscript = " <None|arbitrary_script>102.BI "predisconnectscript = " <None|arbitrary_script>
103This defines a script to run when Wicd disconnects the interface.103This defines a script to run before Wicd disconnects the interface.
104.TP
105.BI "postdisconnectscript = " <None|arbitrary_script>
106This defines a script to run after Wicd disconnects the interface.
104.br107.br
105IMPORTANT - scripts should ONLY be writable by root and located 108IMPORTANT - scripts should ONLY be writable by root and located
106in a directory that is writable by only root.109in a directory that is writable by only root.
107110
=== modified file 'in/wicd=wpath.py.in'
--- in/wicd=wpath.py.in 2009-05-05 02:34:44 +0000
+++ in/wicd=wpath.py.in 2009-06-16 15:13:41 +0000
@@ -27,7 +27,8 @@
27share = '%SHARE%'27share = '%SHARE%'
28etc = '%ETC%'28etc = '%ETC%'
29scripts = '%SCRIPTS%'29scripts = '%SCRIPTS%'
30disconnectscripts = '%SCRIPTS%disconnect'30predisconnectscripts = '%SCRIPTS%predisconnect'
31postdisconnectscripts = '%SCRIPTS%postdisconnect'
31preconnectscripts = '%SCRIPTS%preconnect'32preconnectscripts = '%SCRIPTS%preconnect'
32postconnectscripts = '%SCRIPTS%postconnect'33postconnectscripts = '%SCRIPTS%postconnect'
33images = '%IMAGES%'34images = '%IMAGES%'
3435
=== modified file 'setup.py'
--- setup.py 2009-06-04 14:24:14 +0000
+++ setup.py 2009-06-16 15:13:41 +0000
@@ -488,7 +488,8 @@
488 (wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),488 (wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
489 (wpath.autostart, ['other/wicd-tray.desktop', ]),489 (wpath.autostart, ['other/wicd-tray.desktop', ]),
490 (wpath.scripts, []),490 (wpath.scripts, []),
491 (wpath.disconnectscripts, []),491 (wpath.predisconnectscripts, []),
492 (wpath.postdisconnectscripts, []),
492 (wpath.preconnectscripts, []),493 (wpath.preconnectscripts, []),
493 (wpath.postconnectscripts, []),494 (wpath.postconnectscripts, []),
494 ]495 ]
495496
=== modified file 'wicd/configscript.py'
--- wicd/configscript.py 2009-04-12 02:45:13 +0000
+++ wicd/configscript.py 2009-06-16 15:13:41 +0000
@@ -42,7 +42,8 @@
42language['configure_scripts'] = _("Configure Scripts")42language['configure_scripts'] = _("Configure Scripts")
43language['before_script'] = _("Pre-connection Script")43language['before_script'] = _("Pre-connection Script")
44language['after_script'] = _("Post-connection Script")44language['after_script'] = _("Post-connection Script")
45language['disconnect_script'] = _("Disconnection Script")45language['pre_disconnect_script'] = _("Pre-disconnection Script")
46language['post_disconnect_script'] = _("Post-disconnection Script")
4647
47dbus = dbusmanager.DBusManager()48dbus = dbusmanager.DBusManager()
48dbus.connect_to_dbus()49dbus.connect_to_dbus()
@@ -100,14 +101,16 @@
100 if con.has_section(network):101 if con.has_section(network):
101 info["pre_entry"] = get_val(con, network, "beforescript")102 info["pre_entry"] = get_val(con, network, "beforescript")
102 info["post_entry"] = get_val(con, network, "afterscript")103 info["post_entry"] = get_val(con, network, "afterscript")
103 info["disconnect_entry"] = get_val(con, network, "disconnectscript")104 info["pre_disconnect_entry"] = get_val(con, network, "predisconnectscript")
105 info["post_disconnect_entry"] = get_val(con, network, "postdisconnectscript")
104 else:106 else:
105 bssid = wireless.GetWirelessProperty(int(network), "bssid")107 bssid = wireless.GetWirelessProperty(int(network), "bssid")
106 con.read(wireless_conf)108 con.read(wireless_conf)
107 if con.has_section(bssid):109 if con.has_section(bssid):
108 info["pre_entry"] = get_val(con, bssid, "beforescript")110 info["pre_entry"] = get_val(con, bssid, "beforescript")
109 info["post_entry"] = get_val(con, bssid, "afterscript")111 info["post_entry"] = get_val(con, bssid, "afterscript")
110 info["disconnect_entry"] = get_val(con, bssid, "disconnectscript")112 info["pre_disconnect_entry"] = get_val(con, bssid, "predisconnectscript")
113 info["post_disconnect_entry"] = get_val(con, bssid, "postdisconnectscript")
111 return info114 return info
112115
113def write_scripts(network, network_type, script_info):116def write_scripts(network, network_type, script_info):
@@ -120,7 +123,8 @@
120 con.add_section(network)123 con.add_section(network)
121 con.set(network, "beforescript", script_info["pre_entry"])124 con.set(network, "beforescript", script_info["pre_entry"])
122 con.set(network, "afterscript", script_info["post_entry"])125 con.set(network, "afterscript", script_info["post_entry"])
123 con.set(network, "disconnectscript", script_info["disconnect_entry"])126 con.set(network, "predisconnectscript", script_info["pre_disconnect_entry"])
127 con.set(network, "postdisconnectscript", script_info["post_disconnect_entry"])
124 con.write(open(wired_conf, "w"))128 con.write(open(wired_conf, "w"))
125 wired.ReloadConfig()129 wired.ReloadConfig()
126 wired.ReadWiredNetworkProfile(network)130 wired.ReadWiredNetworkProfile(network)
@@ -132,7 +136,8 @@
132 con.add_section(bssid)136 con.add_section(bssid)
133 con.set(bssid, "beforescript", script_info["pre_entry"])137 con.set(bssid, "beforescript", script_info["pre_entry"])
134 con.set(bssid, "afterscript", script_info["post_entry"])138 con.set(bssid, "afterscript", script_info["post_entry"])
135 con.set(bssid, "disconnectscript", script_info["disconnect_entry"])139 con.set(bssid, "predisconnectscript", script_info["pre_disconnect_entry"])
140 con.set(bssid, "postdisconnectscript", script_info["post_disconnect_entry"])
136 con.write(open(wireless_conf, "w"))141 con.write(open(wireless_conf, "w"))
137 wireless.ReloadConfig()142 wireless.ReloadConfig()
138 wireless.ReadWirelessNetworkProfile(int(network))143 wireless.ReadWirelessNetworkProfile(int(network))
@@ -155,25 +160,30 @@
155 dialog = wTree.get_widget("configure_script_dialog")160 dialog = wTree.get_widget("configure_script_dialog")
156 wTree.get_widget("pre_label").set_label(language['before_script'] + ":")161 wTree.get_widget("pre_label").set_label(language['before_script'] + ":")
157 wTree.get_widget("post_label").set_label(language['after_script'] + ":")162 wTree.get_widget("post_label").set_label(language['after_script'] + ":")
158 wTree.get_widget("disconnect_label").set_label(language['disconnect_script'] 163 wTree.get_widget("pre_disconnect_label").set_label(language['pre_disconnect_script']
164 + ":")
165 wTree.get_widget("post_disconnect_label").set_label(language['post_disconnect_script']
159 + ":")166 + ":")
160 wTree.get_widget("window1").hide()167 wTree.get_widget("window1").hide()
161 168
162 pre_entry = wTree.get_widget("pre_entry")169 pre_entry = wTree.get_widget("pre_entry")
163 post_entry = wTree.get_widget("post_entry")170 post_entry = wTree.get_widget("post_entry")
164 disconnect_entry = wTree.get_widget("disconnect_entry")171 pre_disconnect_entry = wTree.get_widget("pre_disconnect_entry")
172 post_disconnect_entry = wTree.get_widget("post_disconnect_entry")
165 173
166 pre_entry.set_text(none_to_blank(script_info.get("pre_entry")))174 pre_entry.set_text(none_to_blank(script_info.get("pre_entry")))
167 post_entry.set_text(none_to_blank(script_info.get("post_entry")))175 post_entry.set_text(none_to_blank(script_info.get("post_entry")))
168 disconnect_entry.set_text(none_to_blank(script_info.get("disconnect_entry")))176 pre_disconnect_entry.set_text(none_to_blank(script_info.get("pre_disconnect_entry")))
169 177 post_disconnect_entry.set_text(none_to_blank(script_info.get("post_disconnect_entry")))
178
170 dialog.show_all()179 dialog.show_all()
171 180
172 result = dialog.run()181 result = dialog.run()
173 if result == 1:182 if result == 1:
174 script_info["pre_entry"] = blank_to_none(pre_entry.get_text())183 script_info["pre_entry"] = blank_to_none(pre_entry.get_text())
175 script_info["post_entry"] = blank_to_none(post_entry.get_text())184 script_info["post_entry"] = blank_to_none(post_entry.get_text())
176 script_info["disconnect_entry"] = blank_to_none(disconnect_entry.get_text())185 script_info["pre_disconnect_entry"] = blank_to_none(pre_disconnect_entry.get_text())
186 script_info["post_disconnect_entry"] = blank_to_none(post_disconnect_entry.get_text())
177 write_scripts(network, network_type, script_info)187 write_scripts(network, network_type, script_info)
178 dialog.destroy()188 dialog.destroy()
179 189
180190
=== modified file 'wicd/networking.py'
--- wicd/networking.py 2009-06-14 18:25:06 +0000
+++ wicd/networking.py 2009-06-16 15:13:41 +0000
@@ -151,7 +151,8 @@
151 self.connecting_thread = None151 self.connecting_thread = None
152 self.before_script = None152 self.before_script = None
153 self.after_script = None153 self.after_script = None
154 self.disconnect_script = None154 self.pre_disconnect_script = None
155 self.post_disconnect_script = None
155 self.driver = None156 self.driver = None
156 self.iface = None157 self.iface = None
157 158
@@ -203,17 +204,23 @@
203 def Disconnect(self, *args, **kargs):204 def Disconnect(self, *args, **kargs):
204 """ Disconnect from the network. """205 """ Disconnect from the network. """
205 iface = self.iface206 iface = self.iface
206 misc.ExecuteScripts(wpath.disconnectscripts, self.debug)207 misc.ExecuteScripts(wpath.predisconnectscripts, self.debug)
207 if self.disconnect_script:208 if self.pre_disconnect_script:
208 print 'Running disconnect script'209 print 'Running pre-disconnect script'
209 misc.ExecuteScript(expand_script_macros(self.disconnect_script,210 misc.ExecuteScript(expand_script_macros(self.pre_disconnect_script,
210 'disconnection', *args),211 'pre-disconnection', *args),
211 self.debug)212 self.debug)
212 iface.ReleaseDHCP()213 iface.ReleaseDHCP()
213 iface.SetAddress('0.0.0.0')214 iface.SetAddress('0.0.0.0')
214 iface.FlushRoutes()215 iface.FlushRoutes()
215 iface.Down()216 iface.Down()
216 iface.Up()217 iface.Up()
218 misc.ExecuteScripts(wpath.postdisconnectscripts, self.debug)
219 if self.post_disconnect_script:
220 print 'Running post-disconnect script'
221 misc.ExecuteScript(expand_script_macros(self.post_disconnect_script,
222 'post-disconnection', *args),
223 self.debug)
217 224
218 def ReleaseDHCP(self):225 def ReleaseDHCP(self):
219 """ Release the DHCP lease for this interface. """226 """ Release the DHCP lease for this interface. """
@@ -273,8 +280,8 @@
273 lock = threading.Lock()280 lock = threading.Lock()
274281
275 def __init__(self, network, interface_name, before_script, after_script, 282 def __init__(self, network, interface_name, before_script, after_script,
276 disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom, 283 pre_disconnect_script, post_disconnect_script, gdns1,
277 iface, debug):284 gdns2, gdns3, gdns_dom, gsearch_dom, iface, debug):
278 """ Initialise the required object variables and the thread.285 """ Initialise the required object variables and the thread.
279286
280 Keyword arguments:287 Keyword arguments:
@@ -283,7 +290,8 @@
283 wired -- name of the wired interface290 wired -- name of the wired interface
284 before_script -- script to run before bringing up the interface291 before_script -- script to run before bringing up the interface
285 after_script -- script to run after bringing up the interface292 after_script -- script to run after bringing up the interface
286 disconnect_script -- script to run after disconnection293 pre_disconnect_script -- script to run before disconnection
294 post_disconnect_script -- script to run after disconnection
287 gdns1 -- global DNS server 1295 gdns1 -- global DNS server 1
288 gdns2 -- global DNS server 2296 gdns2 -- global DNS server 2
289 gdns3 -- global DNS server 3297 gdns3 -- global DNS server 3
@@ -297,7 +305,8 @@
297 self.connect_result = None305 self.connect_result = None
298 self.before_script = before_script306 self.before_script = before_script
299 self.after_script = after_script307 self.after_script = after_script
300 self.disconnect_script = disconnect_script308 self.pre_disconnect_script = pre_disconnect_script
309 self.post_disconnect_script = post_disconnect_script
301 self._should_die = False310 self._should_die = False
302 self.abort_reason = ""311 self.abort_reason = ""
303 self.connect_result = ""312 self.connect_result = ""
@@ -607,7 +616,8 @@
607 616
608 self.connecting_thread = WirelessConnectThread(network,617 self.connecting_thread = WirelessConnectThread(network,
609 self.wireless_interface, self.wpa_driver, self.before_script,618 self.wireless_interface, self.wpa_driver, self.before_script,
610 self.after_script, self.disconnect_script, self.global_dns_1,619 self.after_script, self.pre_disconnect_script,
620 self.post_disconnect_script, self.global_dns_1,
611 self.global_dns_2, self.global_dns_3, self.global_dns_dom,621 self.global_dns_2, self.global_dns_3, self.global_dns_dom,
612 self.global_search_dom, self.wiface, debug)622 self.global_search_dom, self.wiface, debug)
613 self.connecting_thread.setDaemon(True)623 self.connecting_thread.setDaemon(True)
@@ -779,8 +789,9 @@
779 """789 """
780790
781 def __init__(self, network, wireless, wpa_driver, before_script,791 def __init__(self, network, wireless, wpa_driver, before_script,
782 after_script, disconnect_script, gdns1, gdns2, gdns3, 792 after_script, pre_disconnect_script, post_disconnect_script,
783 gdns_dom, gsearch_dom, wiface, debug=False):793 gdns1, gdns2, gdns3, gdns_dom, gsearch_dom, wiface,
794 debug=False):
784 """ Initialise the thread with network information.795 """ Initialise the thread with network information.
785796
786 Keyword arguments:797 Keyword arguments:
@@ -789,14 +800,16 @@
789 wpa_driver -- type of wireless interface800 wpa_driver -- type of wireless interface
790 before_script -- script to run before bringing up the interface801 before_script -- script to run before bringing up the interface
791 after_script -- script to run after bringing up the interface802 after_script -- script to run after bringing up the interface
792 disconnect_script -- script to run after disconnection803 pre_disconnect_script -- script to run before disconnection
804 post_disconnect_script -- script to run after disconnection
793 gdns1 -- global DNS server 1805 gdns1 -- global DNS server 1
794 gdns2 -- global DNS server 2806 gdns2 -- global DNS server 2
795 gdns3 -- global DNS server 3807 gdns3 -- global DNS server 3
796808
797 """809 """
798 ConnectThread.__init__(self, network, wireless, before_script, 810 ConnectThread.__init__(self, network, wireless, before_script,
799 after_script, disconnect_script, gdns1, gdns2, 811 after_script, pre_disconnect_script,
812 post_disconnect_script, gdns1, gdns2,
800 gdns3, gdns_dom, gsearch_dom, wiface, debug)813 gdns3, gdns_dom, gsearch_dom, wiface, debug)
801 self.wpa_driver = wpa_driver814 self.wpa_driver = wpa_driver
802815
@@ -967,9 +980,10 @@
967 if not self.liface: return False980 if not self.liface: return False
968 self.connecting_thread = WiredConnectThread(network,981 self.connecting_thread = WiredConnectThread(network,
969 self.wired_interface, self.before_script, self.after_script,982 self.wired_interface, self.before_script, self.after_script,
970 self.disconnect_script, self.global_dns_1, self.global_dns_2, 983 self.pre_disconnect_script, self.post_disconnect_script,
971 self.global_dns_3, self.global_dns_dom, self.global_search_dom, 984 self.global_dns_1, self.global_dns_2, self.global_dns_3,
972 self.liface, debug)985 self.global_dns_dom, self.global_search_dom, self.liface,
986 debug)
973 self.connecting_thread.setDaemon(True)987 self.connecting_thread.setDaemon(True)
974 self.connecting_thread.start()988 self.connecting_thread.start()
975 return self.connecting_thread989 return self.connecting_thread
@@ -993,8 +1007,8 @@
9931007
994 """1008 """
995 def __init__(self, network, wired, before_script, after_script, 1009 def __init__(self, network, wired, before_script, after_script,
996 disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom, 1010 pre_disconnect_script, post_disconnect_script, gdns1,
997 liface, debug=False):1011 gdns2, gdns3, gdns_dom, gsearch_dom, liface, debug=False):
998 """ Initialise the thread with network information.1012 """ Initialise the thread with network information.
9991013
1000 Keyword arguments:1014 Keyword arguments:
@@ -1003,14 +1017,16 @@
1003 wired -- name of the wired interface1017 wired -- name of the wired interface
1004 before_script -- script to run before bringing up the interface1018 before_script -- script to run before bringing up the interface
1005 after_script -- script to run after bringing up the interface1019 after_script -- script to run after bringing up the interface
1006 disconnect_script -- script to run after disconnection1020 pre_disconnect_script -- script to run before disconnection
1021 post_disconnect_script -- script to run after disconnection
1007 gdns1 -- global DNS server 11022 gdns1 -- global DNS server 1
1008 gdns2 -- global DNS server 21023 gdns2 -- global DNS server 2
1009 gdns3 -- global DNS server 31024 gdns3 -- global DNS server 3
10101025
1011 """1026 """
1012 ConnectThread.__init__(self, network, wired, before_script, 1027 ConnectThread.__init__(self, network, wired, before_script,
1013 after_script, disconnect_script, gdns1, gdns2, 1028 after_script, pre_disconnect_script,
1029 post_disconnect_script, gdns1, gdns2,
1014 gdns3, gdns_dom, gsearch_dom, liface, debug)1030 gdns3, gdns_dom, gsearch_dom, liface, debug)
10151031
1016 def _connect(self):1032 def _connect(self):
10171033
=== modified file 'wicd/translations.py'
--- wicd/translations.py 2009-06-05 08:13:38 +0000
+++ wicd/translations.py 2009-06-16 15:13:41 +0000
@@ -74,7 +74,8 @@
74language['backend_alert'] = _('''Changes to your backend won't occur until the daemon is restarted.''')74language['backend_alert'] = _('''Changes to your backend won't occur until the daemon is restarted.''')
75language['about_help'] = _('''Stop a network connection in progress''')75language['about_help'] = _('''Stop a network connection in progress''')
76language['connecting'] = _('''Connecting''')76language['connecting'] = _('''Connecting''')
77language['disconnect_script'] = _('''Run disconnect script''')77language['pre_disconnect_script'] = _('''Run pre-disconnect script''')
78language['post_disconnect_script'] = _('''Run post-disconnect script''')
78language['cannot_edit_scripts_1'] = _('''To avoid various complications, wicd-curses does not support directly editing the scripts directly. However, you can edit them manually. First, (as root)", open the "$A" config file, and look for the section labeled by the $B in question. In this case, this is:''')79language['cannot_edit_scripts_1'] = _('''To avoid various complications, wicd-curses does not support directly editing the scripts directly. However, you can edit them manually. First, (as root)", open the "$A" config file, and look for the section labeled by the $B in question. In this case, this is:''')
79language['cannot_edit_scripts_3'] = _('''You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.''')80language['cannot_edit_scripts_3'] = _('''You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.''')
80language['cannot_edit_scripts_2'] = _('''Once there, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information.''')81language['cannot_edit_scripts_2'] = _('''Once there, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information.''')
8182
=== modified file 'wicd/wicd-daemon.py'
--- wicd/wicd-daemon.py 2009-05-24 21:11:14 +0000
+++ wicd/wicd-daemon.py 2009-06-16 15:13:41 +0000
@@ -1134,8 +1134,10 @@
1134 # is done.1134 # is done.
1135 self.wifi.before_script = self.GetWirelessProperty(id, 'beforescript')1135 self.wifi.before_script = self.GetWirelessProperty(id, 'beforescript')
1136 self.wifi.after_script = self.GetWirelessProperty(id, 'afterscript')1136 self.wifi.after_script = self.GetWirelessProperty(id, 'afterscript')
1137 self.wifi.disconnect_script = self.GetWirelessProperty(id,1137 self.wifi.pre_disconnect_script = self.GetWirelessProperty(id,
1138 'disconnectscript')1138 'predisconnectscript')
1139 self.wifi.post_disconnect_script = self.GetWirelessProperty(id,
1140 'postdisconnectscript')
1139 print 'Connecting to wireless network ' + self.LastScan[id]['essid']1141 print 'Connecting to wireless network ' + self.LastScan[id]['essid']
1140 self.daemon.wired_bus.wired.Disconnect()1142 self.daemon.wired_bus.wired.Disconnect()
1141 self.daemon.SetForcedDisconnect(False)1143 self.daemon.SetForcedDisconnect(False)
@@ -1222,12 +1224,14 @@
12221224
1223 write_script_ent(bssid_key, "beforescript")1225 write_script_ent(bssid_key, "beforescript")
1224 write_script_ent(bssid_key, "afterscript")1226 write_script_ent(bssid_key, "afterscript")
1225 write_script_ent(bssid_key, "disconnectscript")1227 write_script_ent(bssid_key, "predisconnectscript")
1228 write_script_ent(bssid_key, "postdisconnectscript")
12261229
1227 if cur_network["use_settings_globally"]:1230 if cur_network["use_settings_globally"]:
1228 write_script_ent(essid_key, "beforescript")1231 write_script_ent(essid_key, "beforescript")
1229 write_script_ent(essid_key, "afterscript")1232 write_script_ent(essid_key, "afterscript")
1230 write_script_ent(essid_key, "disconnectscript")1233 write_script_ent(essid_key, "predisconnectscript")
1234 write_script_ent(essid_key, "postdisconnectscript")
12311235
1232 self.config.write()1236 self.config.write()
12331237
@@ -1421,7 +1425,8 @@
1421 """ Connects to a wired network. """1425 """ Connects to a wired network. """
1422 self.wired.before_script = self.GetWiredProperty("beforescript")1426 self.wired.before_script = self.GetWiredProperty("beforescript")
1423 self.wired.after_script = self.GetWiredProperty("afterscript")1427 self.wired.after_script = self.GetWiredProperty("afterscript")
1424 self.wired.disconnect_script = self.GetWiredProperty("disconnectscript")1428 self.wired.pre_disconnect_script = self.GetWiredProperty("predisconnectscript")
1429 self.wired.post_disconnect_script = self.GetWiredProperty("postdisconnectscript")
1425 self.daemon.wireless_bus.wifi.Disconnect()1430 self.daemon.wireless_bus.wifi.Disconnect()
1426 self.daemon.SetForcedDisconnect(False)1431 self.daemon.SetForcedDisconnect(False)
1427 self.UnsetWiredLastUsed()1432 self.UnsetWiredLastUsed()
@@ -1439,7 +1444,8 @@
14391444
1440 for option in ["ip", "broadcast", "netmask","gateway", "search_domain", 1445 for option in ["ip", "broadcast", "netmask","gateway", "search_domain",
1441 "dns_domain", "dns1", "dns2", "dns3", "beforescript", 1446 "dns_domain", "dns1", "dns2", "dns3", "beforescript",
1442 "afterscript", "disconnectscript"]:1447 "afterscript", "predisconnectscript",
1448 "postdisconnectscript"]:
1443 self.config.set(profilename, option, None)1449 self.config.set(profilename, option, None)
1444 self.config.set(profilename, "default", default)1450 self.config.set(profilename, "default", default)
1445 self.config.write()1451 self.config.write()
@@ -1507,7 +1513,8 @@
15071513
1508 write_script_ent(profilename, "beforescript")1514 write_script_ent(profilename, "beforescript")
1509 write_script_ent(profilename, "afterscript")1515 write_script_ent(profilename, "afterscript")
1510 write_script_ent(profilename, "disconnectscript")1516 write_script_ent(profilename, "predisconnectscript")
1517 write_script_ent(profilename, "postdisconnectscript")
1511 self.config.write()1518 self.config.write()
1512 return "100: Profile Written"1519 return "100: Profile Written"
15131520

Subscribers

People subscribed via source and target branches

to status/vote changes: