def on_forward_button_clicked(self, widget): dport = self._get_selected_opt_from_combobox('data') cport = self._get_selected_opt_from_combobox('control') speed = int(self._get_selected_opt_from_combobox('speed')) if cport == _("No control port"): cport = None software = self.view['software_checkbutton'].get_active() hardware = self.view['hardware_checkbutton'].get_active() title = _('Connecting to device...') apb = dialogs.ActivityProgressBar(title, self, True) def get_remote_plugin_eb(failure): failure.trap(SerialException) apb.close() port = cport and cport or dport message = _('Exception received connecting to %s') % port details = _(""" The following error was received while trying to establish a connection: %s""") % failure.getErrorMessage() dialogs.open_warning_dialog(message, details) from vmc.common.hardware import HardwareRegistry hw = HardwareRegistry() d = hw.get_plugin_for_remote_dev(speed, dport, cport) d.addCallback(self._im_done, apb) d.addErrback(get_remote_plugin_eb)
def open_import_csv_dialog(path=None): """Opens a filechooser dialog to import a csv file""" title = _("Import contacts from...") chooser_dialog = gtk.FileChooserDialog( title, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser_dialog.set_default_response(gtk.RESPONSE_OK) filter_ = gtk.FileFilter() filter_.set_name(_("Csv files")) filter_.add_mime_type("text/xml") filter_.add_pattern("*csv") chooser_dialog.add_filter(filter_) filter_ = gtk.FileFilter() filter_.set_name(_("All files")) filter_.add_pattern("*") chooser_dialog.add_filter(filter_) if path: chooser_dialog.set_filename(os.path.abspath(path)) if chooser_dialog.run() == gtk.RESPONSE_OK: resp = chooser_dialog.get_filename() else: resp = None chooser_dialog.destroy() return resp
def get_selected_device_eb(failure): failure.trap(SerialException) message = _('Device setup not completed') details = _(""" An unknown error occur when setting up the device: %s""") % failure.getErrorMessage() dialogs.open_warning_dialog(message, details)
def get_about_dialog(): """Returns an AboutDialog with all the necessary info""" _MAX_WIDTH = 20 wrapped_name = fill(consts.APP_LONG_NAME, _MAX_WIDTH) abt = gtk.AboutDialog() # attach an icon icon = abt.render_icon(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU) abt.set_icon(icon) filepath = os.path.join(consts.IMAGES_DIR, 'VF_logo.png') logo = gtk.gdk.pixbuf_new_from_file(filepath) abt.set_logo(logo) gtk.about_dialog_set_url_hook(lambda abt, url: url_show(url)) gtk.about_dialog_set_email_hook(lambda d, e: url_show("mailto:%s" % e)) if gtk.pygtk_version >= (2, 11, 0): abt.set_program_name(wrapped_name) else: abt.set_name(wrapped_name) abt.set_version(consts.APP_VERSION) abt.set_copyright(_('Vodafone Spain S.A.')) abt.set_authors(consts.APP_AUTHORS) abt.set_documenters(consts.APP_DOCUMENTERS) abt.set_artists(consts.APP_ARTISTS) abt.set_website(consts.APP_URL) # XXX: pango here? I tried w/o success abt.set_website_label('http://forge.vodafonebetavine.net/..') trans_credits = _('translated to $LANG by $translater') # only enable them when necessary if trans_credits != 'translated to $LANG by $translater': abt.set_translator_credits(trans_credits) _license = """ Vodafone Mobile Connect Card driver for Linux Copyright (C) 2006-2007 Vodafone España S.A. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA""" abt.set_license(_license) return abt
def get_imsi_cb(imsi): # we will setup the combobox options here items = [] network = net_manager.get_network_by_id(imsi[:5]) if not network: # we dont know anything about this network operator, we will # just show 'Unknown' in the combobox, giving no options to # the user items.append(SMSCItem(_("Unknown"))) else: if network.smsc: # we know the network and we have its SMSC if smsc != network.smsc: # as the SMSC is different that the stored one, # we are gonna append "Custom" too items.append(SMSCItem(_("Custom"))) items.append(SMSCItem(network.get_full_name(), network.smsc, active=False)) else: items.append(SMSCItem(network.get_full_name(), network.smsc)) else: # we dont know the SMSC of this network items.append(SMSCItem(_("Unknown"))) self.view.populate_smsc_combobox(items)
def get_uptime_string(uptime): """Returns a uptime(1)'s like output from a uptime expressed in seconds""" time_dict = get_time_dict(uptime) try: hour = "%d" % time_dict['hour'] except KeyError: hour = "0" try: minute = "%d" % time_dict['minute'] if time_dict['minute'] < 10: minute = '0' + minute except KeyError: minute = '00' msg = "%s:%s" % (hour, minute) try: day = time_dict['day'] if day > 1: resp = _("%(day)d days, %(msg)s") % {'day': day, 'msg': msg} else: resp = _("%(day)d day, %(msg)s") % {'day': day, 'msg': msg} except KeyError: resp = msg return resp
def get_uptime_string(uptime): """Returns a uptime(1)'s like output from a uptime expressed in seconds""" time_dict = get_time_dict(uptime) try: hour = "%d" % time_dict['hour'] except KeyError: hour = "0" try: minute = "%d" % time_dict['minute'] if time_dict['minute'] < 10: minute = '0' + minute except KeyError: minute = '00' msg = "%s:%s" % (hour, minute) try: day = time_dict['day'] if day > 1: resp = _("%(day)d days, %(msg)s") % {'day': day, 'msg' : msg} else: resp = _("%(day)d day, %(msg)s") % {'day': day, 'msg' : msg} except KeyError: resp = msg return resp
def get_imsi_cb(imsi): # we will setup the combobox options here items = [] network = net_manager.get_network_by_id(imsi) if not network: # we dont know anything about this network operator, we will # just show 'Unknown' in the combobox, giving no options to # the user items.append(SMSCItem(_("Unknown"))) else: if network.smsc: # we know the network and we have its SMSC if smsc != network.smsc: # as the SMSC is different that the stored one, # we are gonna append "Custom" too items.append(SMSCItem(_("Custom"))) items.append( SMSCItem(network.get_full_name(), network.smsc, active=False)) else: items.append( SMSCItem(network.get_full_name(), network.smsc)) else: # we dont know the SMSC of this network items.append(SMSCItem(_("Unknown"))) self.view.populate_smsc_combobox(items)
def show_icon_cb(self, checkbutton): if checkbutton.get_active(): if not tray_available(): # block the handler so the set_active method doesnt # executes this callback again checkbutton.handler_block(self._hid2) checkbutton.set_active(False) # restore handler checkbutton.handler_unblock(self._hid2) message = _("Missing dependency") details = _(""" To use this feature you need either pygtk >= 2.10 or the egg.trayicon module """) dialogs.open_warning_dialog(message, details) return True else: # attach and show systray icon self.parent_ctrl._setup_trayicon(ignoreconf=True) # if there's an available tray, enable this chkbtn close_win_chkbtn = self.view['close_window_checkbutton'] close_win_chkbtn.set_sensitive(True) else: # detach icon from systray self.parent_ctrl._detach_trayicon() # close_window_checkbutton depends on this checkbutton # being active, thats why we set insensitive the chkbtn self.view['close_window_checkbutton'].set_sensitive(False) self.view['close_window_checkbutton'].set_active(False)
def show_icon_cb(checkbutton): if checkbutton.get_active(): if not tray_available(): # block the handler so the set_active method doesnt # executes this callback again checkbutton.handler_block(self._hid2) checkbutton.set_active(False) # restore handler checkbutton.handler_unblock(self._hid2) message = _("Missing dependency") details = _(""" To use this feature you need either pygtk >= 2.10 or the egg.trayicon module """) dialogs.open_warning_dialog(message, details) return True else: # attach and show systray icon self.parent_ctrl._setup_trayicon(ignoreconf=True) # if there's an available tray, enable this chkbtn close_win_chkbtn = self.view['close_window_checkbutton'] close_win_chkbtn.set_sensitive(True) else: # detach icon from systray self.parent_ctrl._detach_trayicon() # close_window_checkbutton depends on this checkbutton # being active, thats why we set insensitive the chkbtn self.view['close_window_checkbutton'].set_sensitive(False) self.view['close_window_checkbutton'].set_active(False)
def on_ok_button_clicked(self, widget): settings = self.get_profile_settings() if not settings: # preferred connection or auth not specified return if settings['staticdns']: if not self.dns1_entry.isvalid() or not self.dns2_entry.isvalid(): # DNS must be valid return if not settings['profile_name'] or settings['profile_name'] == '': self.view['profile_name_entry'].grab_focus() return if self.is_profile_name_insane(): message = _('Invalid characters in profile name') details = _(""" The following characters are not allowed in a profile name: %s""") % ' '.join(INVALID_CHARS) dialogs.open_warning_dialog(message, details) return prof_manager = get_profile_manager(self.model.get_device()) prof_manager.edit_profile(self.profile, settings) # now hide self.hide_ourselves()
def open_import_csv_dialog(path=None): """Opens a filechooser dialog to import a csv file""" title = _("Import contacts from...") chooser_dialog = gtk.FileChooserDialog(title, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser_dialog.set_default_response(gtk.RESPONSE_OK) filter_ = gtk.FileFilter() filter_.set_name(_("Csv files")) filter_.add_mime_type("text/xml") filter_.add_pattern("*csv") chooser_dialog.add_filter(filter_) filter_ = gtk.FileFilter() filter_.set_name(_("All files")) filter_.add_pattern("*") chooser_dialog.add_filter(filter_) if path: chooser_dialog.set_filename(os.path.abspath(path)) if chooser_dialog.run() == gtk.RESPONSE_OK: resp = chooser_dialog.get_filename() else: resp = None chooser_dialog.destroy() return resp
def settings_valid(self,settings): class Problem(Exception): def __init__(self,detail): self.detail = detail def __str__(self): return repr(self.detail) try: if not settings: raise Problem("Profile settings are Null") if settings['staticdns']: if self.dns1_entry.get_text() == '' and self.dns2_entry.get_text() == '': raise Problem("If static DNS is enabled, you must define at least one address") if not self.dns1_entry.isvalid() and not self.dns1_entry.get_text() == '': raise Problem("Primary DNS address is invalid") if not self.dns2_entry.isvalid() and not self.dns2_entry.get_text() == '': raise Problem("Secondary DNS address is invalid") if settings['apn'] == '': raise Problem("You must specify an APN") if not settings['profile_name'] or settings['profile_name'] == '': self.view['profile_name_entry'].grab_focus() raise Problem("profile name is invalid") if self.is_profile_name_insane(): raise Problem(_("""The following characters are not allowed in a profile name: %s""") % ' '.join(INVALID_CHARS)) except Problem, (instance): message = _('Invalid value in profile') dialogs.open_warning_dialog(message, instance.detail) return False
def save_standard_file(path=None): """Opens a filechooser dialog to choose where to save a file""" title = _("Save as ...") chooser_dialog = gtk.FileChooserDialog( title, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) chooser_dialog.set_default_response(gtk.RESPONSE_OK) filter_ = gtk.FileFilter() filter_.set_name(_("All files")) filter_.add_pattern("*") chooser_dialog.add_filter(filter_) if path: chooser_dialog.set_filename(path) if chooser_dialog.run() == gtk.RESPONSE_OK: resp = chooser_dialog.get_filename() if os.path.isfile(resp): # requests to confirm overwrite: overwrite = open_confirm_action_dialog( _("Overwrite"), _('Overwrite "%s"?') % os.path.basename(resp), _("""A file with this name already exists. If you choose to overwrite this file, the contents will be lost.""")) if not overwrite: resp = None else: resp = None chooser_dialog.destroy() return resp
def save_standard_file(path=None): """Opens a filechooser dialog to choose where to save a file""" title = _("Save as ...") chooser_dialog = gtk.FileChooserDialog(title, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) chooser_dialog.set_default_response(gtk.RESPONSE_OK) filter_ = gtk.FileFilter() filter_.set_name(_("All files")) filter_.add_pattern("*") chooser_dialog.add_filter(filter_) if path: chooser_dialog.set_filename(path) if chooser_dialog.run() == gtk.RESPONSE_OK: resp = chooser_dialog.get_filename() if os.path.isfile(resp): # requests to confirm overwrite: overwrite = open_confirm_action_dialog(_("Overwrite"), _('Overwrite "%s"?') % os.path.basename(resp), _("""A file with this name already exists. If you choose to overwrite this file, the contents will be lost.""")) if not overwrite: resp = None else: resp = None chooser_dialog.destroy() return resp
def set_no_device_present(self): for widget in WIDGETS_TO_HIDE: self[widget].set_sensitive(False) self.set_name(consts.APP_LONG_NAME + ' / ' + _('No device present')) self['cell_type_label'].set_text(_('N/A')) self['network_name_label'].set_text(_('N/A'))
def get_remote_plugin_eb(failure): failure.trap(SerialException) apb.close() port = cport and cport or dport message = _('Exception received connecting to %s') % port details = _(""" The following error was received while trying to establish a connection: %s""") % failure.getErrorMessage() dialogs.open_warning_dialog(message, details)
def device_serial_eb(failure): from PyQt4.QtGui import QMessageBox failure.trap(SerialException) message = _('Device setup not completed') details = _(""" Your device has been detected but it has been impossible to connect to it. %s""") % failure.getErrorMessage() QMessageBox.warning(None, message, details) _device_select([], self.configure_hardware, self.splash)
def device_serial_eb(failure): from vmc.gtk import dialogs failure.trap(SerialException) message = _('Device setup not completed') details = _(""" Your device has been detected but it has been impossible to connect to it. %s""") % failure.getErrorMessage() dialogs.open_warning_dialog(message, details) _device_select([], self.configure_hardware, self.splash)
def get_profile_cb(profile): if profile: message = _('Configuration details found for Operator!') details = _( """Do you want to load stored settings for %s?""") % profile.get_full_name() resp = dialogs.open_confirm_action_dialog(_('Load'), message, details) if resp: self.load_network_profile(profile) self.propose_profile_name()
def get_profile_cb(profile): if profile: message = _('Configuration details found for Operator!') details = _("""Do you want to load stored settings for %s?""" ) % profile.get_full_name() resp = dialogs.open_confirm_action_dialog( _('Load'), message, details) if resp: self.load_network_profile(profile) self.propose_profile_name()
def device_timeout_eb(failure): failure.trap(ex.ATTimeout) from vmc.gtk import dialogs from vmc.common.shutdown import shutdown_core message = _('Device not responding') details = _(""" Your device took more than 15 seconds to reply to my last command. Unplug it, plug it again, and try in a moment.""") dialogs.open_warning_dialog(message, details) shutdown_core(delay=.2)
def get_sms_list_cb(messages): if not messages: return message_text = self.get_message_text() if not message_text: resp = dialogs.open_warning_request_cancel_ok( _("Send empty message"), _("Are you sure you want to send an empty message?")) if not resp: # user said no self.view.set_idle_view() return # send the sms sms_cb_list = [] sent_list = [] err_list = [] def list_cb(resp): if self.sms: self.delete_messages_from_db_and_tv([self.sms]) if sent_list: self.save_messages_to_db(sent_list, TV_DICT_REV['sent_treeview']) if err_list: dialogs.open_warning_dialog( _("Unknown Error"), _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly." )) self.save_messages_to_db(err_list, TV_DICT_REV['drafts_treeview']) self.model.unregister_observer(self) self.view.hide() def try_to_send(sms): def ok(ign): sent_list.append(sms) def error(failure): failure.trap(ex.CMSError500, ex.CMSError304) err_list.append(sms) d = self.parent_ctrl.model.send_sms(sms) d.addCallback(ok) d.addErrback(error) return d for sms in messages: d = try_to_send(sms) sms_cb_list.append(d) dlist = DeferredList(sms_cb_list) dlist.addCallback(list_cb)
def device_timeout_eb(failure): failure.trap(ex.ATTimeout) from PyQt4.QtGui import QMessageBox from vmc.common.shutdown import shutdown_core message = _('Device not responding') details = _(""" Your device took more than 15 seconds to reply to my last command. Unplug it, plug it again, and try in a moment.""") QMessageBox.warning(None, message, details) shutdown_core(delay=.2)
def identify_dev_eb(failure): failure.trap(SerialException) from PyQt4.QtGui import QMessageBox info = dict(name=device.name, vmc=APP_LONG_NAME) message = _('Device setup not completed') details = _(""" %(vmc)s cannot connect with the selected device (%(name)s). """) % info QMessageBox.warning(None, message, details) config.set_last_device('') self.detect_hardware()
def identify_dev_eb(failure): failure.trap(SerialException) from vmc.gtk import dialogs info = dict(name=device.name, vmc=APP_LONG_NAME) message = _('Device setup not completed') details = _(""" %(vmc)s cannot connect with the selected device (%(name)s). """) % info dialogs.open_warning_dialog(message, details) config.set_last_device('') self.detect_hardware()
def set_disconnected(self): image = gtk.Image() image.set_from_file(os.path.join(consts.IMAGES_DIR, 'connect.png')) image.show() self['connect_button'].set_icon_widget(image) self['connect_button'].set_label(_("Connect")) self['connect_button'].set_active(False) self['upload_alignment'].hide() self['download_alignment'].hide() self['net_statusbar'].push(1, _('Not connected'))
def on_pin_modify_ok_button_clicked(self, widget): oldpin = self.view['pin_modify_current_pin_entry'].get_text() newpin = self.view['pin_modify_new_pin_entry'].get_text() newpin2 = self.view['pin_modify_confirm_pin_entry'].get_text() if newpin == newpin2: def callback(resp): self.hide_widgets() self.model.unregister_observer(self) self.view.hide() def bad_passwd_eb(failure): failure.trap(ex.CMEErrorIncorrectPassword, ex.ATError) title = _("Incorrect PIN") details = _(""" <small>The PIN you've just entered is incorrect. Bear in mind that after three failed PINs you'll be asked for the PUK code</small> """) notification = show_error_notification( self.view['pin_modify_current_pin_entry'], title, details) self.append_widget(notification) self.view['pin_modify_current_pin_entry'].grab_focus() self.view['pin_modify_current_pin_entry'].select_region(0, -1) def garbage_passwd_eb(failure): failure.trap(ex.InputValueError) title = _("Invalid PIN") details = _(""" <small>The PIN you've just entered is invalid. The PIN must be a 4 digit code</small> """) notification = show_error_notification( self.view['pin_modify_new_pin_entry'], title, details) self.append_widget(notification) self.view['pin_modify_new_pin_entry'].select_region(0, -1) self.view['pin_modify_confirm_pin_entry'].select_region(0, -1) self.view['pin_modify_new_pin_entry'].grab_focus() d = self.model.change_pin(oldpin, newpin) d.addCallback(callback) d.addErrback(bad_passwd_eb) d.addErrback(garbage_passwd_eb) else: dialogs.open_warning_dialog(_("Error"), _("Passwords don't match")) self.view['pin_modify_new_pin_entry'].select_region(0, -1) self.view['pin_modify_confirm_pin_entry'].select_region(0, -1) self.view['pin_modify_new_pin_entry'].grab_focus()
def pin_req_eb(failure): failure.trap(ex.CMEErrorIncorrectPassword, ex.ATError) title = _("Incorrect PIN") details = _(""" <small>The PIN you've just entered is incorrect. Bear in mind that after three failed PINs you'll be asked for the PUK code</small> """) dialogs.open_warning_dialog(title, details) self.view['pin_modify_current_pin_entry'].grab_focus() self.view['pin_modify_current_pin_entry'].select_region(0, -1)
def init_view_columns(self): render_text = gtk.CellRendererText() col0=gtk.TreeViewColumn(_('Name')) col0.pack_start(render_text, expand=True) col0.add_attribute(render_text, 'text', 0) col1=gtk.TreeViewColumn(_('Country')) col1.pack_start(render_text, expand=True) col1.add_attribute(render_text, 'text', 1) col2=gtk.TreeViewColumn(_('Type')) col2.pack_start(render_text, expand=True) col2.add_attribute(render_text, 'text', 2) self._view.append_column(col0) self._view.append_column(col1) self._view.append_column(col2)
def send_pin_incorrect_passwd_eb(failure): failure.trap(ex.CMEErrorIncorrectPassword, ex.ATError) title = _("Incorrect PIN") details = _(""" The PIN you've just entered is incorrect. Bear in mind that after three failed PINs you'll be asked for the PUK code """) notification = \ show_error_notification(self.view['pin_entry'], title, details) self.append_widget(notification) self.view['pin_entry'].grab_focus() self.view['pin_entry'].select_region(0, -1)
def get_sms_list_cb(messages): if not messages: return message_text = self.get_message_text() if not message_text: resp = dialogs.open_warning_request_cancel_ok( _("Send empty message"), _("Are you sure you want to send an empty message?")) if not resp: # user said no self.view.set_idle_view() return # send the sms sms_cb_list = [] sent_list = [] err_list = [] def list_cb(resp): if self.sms: self.delete_messages_from_db_and_tv([self.sms]) if sent_list: self.save_messages_to_db(sent_list, TV_DICT_REV['sent_treeview']) if err_list: dialogs.open_warning_dialog( _("Unknown Error"), _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly.")) self.save_messages_to_db(err_list, TV_DICT_REV['drafts_treeview']) self.model.unregister_observer(self) self.view.hide() def try_to_send(sms): def ok(ign): sent_list.append(sms) def error(failure): failure.trap(ex.CMSError500, ex.CMSError304) err_list.append(sms) d = self.parent_ctrl.model.send_sms(sms) d.addCallback(ok) d.addErrback(error) return d for sms in messages: d = try_to_send(sms) sms_cb_list.append(d) dlist = DeferredList(sms_cb_list) dlist.addCallback(list_cb)
def list_cb(resp): if self.sms: self.delete_messages_from_db_and_tv([self.sms]) if sent_list: self.save_messages_to_db(sent_list, TV_DICT_REV['sent_treeview']) if err_list: dialogs.open_warning_dialog( _("Unknown Error"), _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly.")) self.save_messages_to_db(err_list, TV_DICT_REV['drafts_treeview']) self.model.unregister_observer(self) self.view.hide()
def garbage_passwd_eb(failure): failure.trap(ex.InputValueError) title = _("Invalid PIN") details = _(""" <small>The PIN you've just entered is invalid. The PIN must be a 4 digit code</small> """) notification = show_error_notification( self.view['pin_modify_new_pin_entry'], title, details) self.append_widget(notification) self.view['pin_modify_new_pin_entry'].select_region(0, -1) self.view['pin_modify_confirm_pin_entry'].select_region(0, -1) self.view['pin_modify_new_pin_entry'].grab_focus()
def list_cb(resp): if self.sms: self.delete_messages_from_db_and_tv([self.sms]) if sent_list: self.save_messages_to_db(sent_list, TV_DICT_REV['sent_treeview']) if err_list: dialogs.open_warning_dialog( _("Unknown Error"), _("Your message cannot be sent to some of its recipients. Unsent messages have been saved in drafts. Please, check that you have typed the number correctly." )) self.save_messages_to_db(err_list, TV_DICT_REV['drafts_treeview']) self.model.unregister_observer(self) self.view.hide()
def shutdown_core(signal=None, frame=None, delay=2): from vmc.common.config import config config.close() # free VMCConfig singleton from vmc.common.phonebook import get_phonebook phonebook = get_phonebook(None) try: phonebook.close() # free Phonebook singleton except AttributeError: pass from vmc.common.messages import get_messages_obj messages = get_messages_obj(None) try: messages.close() # free Messages singleton except AttributeError: pass from vmc.common.persistent import net_manager try: net_manager.close() except AttributeError: pass log.msg(_('Shutting down...')) reactor.callLater(delay, reactor.stop)
def _get_usage_for_month(self, dateobj): key = (dateobj.year, dateobj.month) if not self.month_cache.has_key(key): # Current session information if self.is_connected() and self.origin_date.month == dateobj.month: tracker = self.connsm.tracker tracker.get_current_usage().addCallback( self._update_session_stats) stats = self.session_stats umts = tracker.conn_mode in THREEG_SIGNALS transferred = stats[0] + stats[1] transferred_3g = umts and transferred or 0 transferred_gprs = not umts and transferred or 0 else: transferred_3g = 0 transferred_gprs = 0 # Historical usage data usage = usage_manager.get_usage_for_month(dateobj) for item in usage: if item.umts: transferred_3g += item.bits_recv + item.bits_sent else: transferred_gprs += item.bits_recv + item.bits_sent self.month_cache[key] = { 'month': dateobj.strftime(_("%B, %Y")), 'transferred_gprs': transferred_gprs, 'transferred_3g': transferred_3g, 'transferred_total': transferred_gprs + transferred_3g } return self.month_cache[key]
def send_puk_eb(failure): failure.trap(ex.CMEErrorIncorrectPassword) title = _("Incorrect PUK") details = _(""" <small>The PUK you've just entered is incorrect. Bear in mind that after three failed PUKs you'll be asked for the PUK2 code. Your PIN code should be your last PIN.</small> """) n = show_error_notification(self.view['pin_entry'], title, details) self.append_widget(n) self.view['pin_entry'].grab_focus() self.view['pin_entry'].select_region(0, -1) self.view['puk_entry'].grab_focus() self.view['puk_entry'].select_region(0, -1)
def _fill_treeview_with_device(self, device): if not device: self.view['statusbar1'].push(1, _('Discovery finished!')) return model = self.view['device_treeview'].get_model() model.add_device(device) self.disc_queue.get().addCallback(self._fill_treeview_with_device)
def device_lacks_extractinfo_eb(failure): failure.trap(ex.DeviceLacksExtractInfo) from vmc.gtk import dialogs from vmc.common.shutdown import shutdown_core device = failure.value.args[0] info = dict(name=device.name, vmc=APP_LONG_NAME) message = _('Device setup not completed') details = _(""" Your device "%(name)s" is not properly registered with the kernel. %(vmc)s needs at least two serial ports to communicate with your %(name)s. The program includes a set of udev rules plus some binaries that make sure that your device is always recognised properly. If you've installed from source, then make sure to copy the relevant files in the contrib dir """) % info dialogs.open_warning_dialog(message, details) shutdown_core(delay=.2)
def get_device_treeview(device_list, callback, parent_view): window = gtk.Window() window.set_transient_for(parent_view.get_top_widget()) window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) window.set_title(_('Device List')) window.set_size_request(width=400, height=300) sw = gtk.ScrolledWindow() sw.add(DeviceList(device_list, callback, window)) window.add(sw) window.show_all()