本文整理汇总了Python中vmc.common.encoding._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_about_dialog
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
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:60,代码来源:dialogs.py
示例2: save_standard_file
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
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:32,代码来源:dialogs.py
示例3: get_selected_device_eb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:7,代码来源:initialconf.py
示例4: on_forward_button_clicked
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:31,代码来源:initialconf.py
示例5: settings_valid
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
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:35,代码来源:initialconf.py
示例6: on_ok_button_clicked
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()
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:29,代码来源:initialconf.py
示例7: get_imsi_cb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:27,代码来源:preferences.py
示例8: show_icon_cb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:29,代码来源:preferences.py
示例9: open_import_csv_dialog
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
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:28,代码来源:dialogs.py
示例10: get_uptime_string
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
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:27,代码来源:uptime.py
示例11: set_no_device_present
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'))
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:8,代码来源:application.py
示例12: get_profile_cb
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()
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:10,代码来源:initialconf.py
示例13: get_remote_plugin_eb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:10,代码来源:initialconf.py
示例14: device_serial_eb
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)
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:10,代码来源:startup.py
示例15: device_serial_eb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:10,代码来源:startup.py
示例16: device_timeout_eb
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)
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:11,代码来源:startup.py
示例17: device_timeout_eb
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)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:11,代码来源:startup.py
示例18: identify_dev_eb
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()
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:12,代码来源:startup.py
示例19: set_disconnected
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'))
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:12,代码来源:application.py
示例20: on_pin_modify_ok_button_clicked
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()
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:53,代码来源:pin.py
注:本文中的vmc.common.encoding._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论