コード例 #1
0
 def __init__(self, fileiso):
     self.fileiso = fileiso
     self.list_f = self.fileiso.split('/')
     self.file_cut = self.fileiso.split('/')[len(self.list_f)-1]
     self.glade = gtk.glade.XML(PATH+"md5.glade")
     self.glade.signal_autoconnect(self)
     self.window = self.glade.get_widget("window1")
     self.button = self.glade.get_widget("buttonOk")
     self.lbDef = self.glade.get_widget("lbDef")
     self.lbMd5 = self.glade.get_widget("lbMd5")
     self.pgbar = self.glade.get_widget("pgbar")
     self.copy = self.glade.get_widget("copy")
     self.copy.set_label(gettext.dgettext("nautilus-md5sum","Copy"))
     self.lbDef.set_text(gettext.dgettext("nautilus-md5sum","MD5Sum can take a long time"))
     self.lbMd5.set_text(gettext.dgettext("nautilus-md5sum","File: ")+self.file_cut)
     self.lbMd5.set_selectable(True)
     self.button.set_label(gettext.dgettext("nautilus-md5sum","Cancel"))
     self.button.grab_default()
     self.button.grab_focus()
     self.window.set_title(NAME_APP)
     self.window.set_focus_child(self.glade.get_widget("buttonOk"))
     self.window.set_icon_from_file(PATH_ICON+"md5sum-ico.png")
     self.window.show_all()
     self.copy.hide()
     self.Res = subprocess.Popen(["md5sum", fileiso], stdout=subprocess.PIPE)
コード例 #2
0
def ldnp(td, ctxt, id, idp, n, *args):
    if not dir or nolocales: _die("please set a locale directory with l_dir() before using other translate functions")

    if idp: args = (n,) + args
    out = None
    if dry:
        if not nowrite:
            save = []
            if td: save.push(' # domain: '+td)
            if ctxt: save.push('msgctxt: "'+gettext_escape(ctxt)+'"')
            save.push('msgid "'+gettext_escape(id)+'"')
            if idp: save.push('msgid_plural "'+gettext_escape(idp)+'"')
            wd(save)
        out = (idp if idp and n != 1 else id) % args
    else:
        if       td and not ctxt and id and     idp and     n: out = sprintf(dngettext(td, id, idp, n), *args)
        elif not td and not ctxt and id and     idp and     n: out = sprintf(ngettext(id, idp, n), *args)
        elif not td and not ctxt and id and not idp and not n: out = sprintf(gettext(id), *args)
        elif     td and not ctxt and id and not idp and not n: out = sprintf(dgettext(td, id), *args)

        # with context magic
        if       td and     ctxt and id and     idp and     n: out = sprintf(dngettext(td, ctxt+'\x04'+id, ctxt+'\x04'+idp, n), *args)
        elif not td and     ctxt and id and     idp and     n: out = sprintf(ngettext(ctxt+'\x04'+id, ctxt+'\x04'+idp, n), *args)
        elif not td and     ctxt and id and not idp and not n: out = sprintf(gettext(ctxt+'\x04'+id), *args)
        elif     td and     ctxt and id and not idp and not n: out = sprintf(dgettext(td, ctxt+'\x04'+id), *args)
    return out
コード例 #3
0
    def showJobView(self, job):
        if job.name == dgettext("vix", "Image Manager"):
            self.ImageBackupDone = True
        elif job.name == dgettext("vix", "Backup Manager"):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView

        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(
                self.startActualUpgrade(("menu", "menu")),
                JobView,
                job,
                cancelable=False,
                backgroundable=False,
                afterEventChangeable=False,
                afterEvent="close",
            )
        else:
            self.session.openWithCallback(
                self.doAutoBackup,
                JobView,
                job,
                cancelable=False,
                backgroundable=False,
                afterEventChangeable=False,
                afterEvent="close",
            )
コード例 #4
0
    def menu_activate_cb(self, menu, files):
        # Called when the user selects the menu.
        if len(files) != 1:
            return
        filename = files[0]
        if filename.get_uri_scheme() != "file":
            return

        if filename.is_directory():
            return

        filefont = urllib.unquote(filename.get_uri()[7:])
        os.system(
            "gksudo -u root -k -m "
            + '"'
            + gettext.dgettext("nautilus-fontinstall", "Enter your user password")
            + '"'
            + " /bin/echo "
            + '"'
            + gettext.dgettext("nautilus-fontinstall", "Do you have root access?")
            + '"'
        )
        os.system("sudo cp -r '" + filefont + "' '" + FONT_PATH + "'")
        fontinst = FONTDialog(filefont)
        fontinst.main()
コード例 #5
0
ファイル: i18n.py プロジェクト: Acidburn0zzz/ibus
def gettext_engine_description(engine):
    name = engine.get_name()
    if (name.startswith('xkb:')):
        return gettext.dgettext('xkeyboard-config', engine.get_description())
    textdomain = engine.get_textdomain()
    if textdomain == '':
        return engine.get_description()
    return gettext.dgettext(textdomain, engine.get_description())
コード例 #6
0
ファイル: ssh.py プロジェクト: chetan/ansible
    def _communicate(self, p, stdin, indata, su=False, sudoable=False, prompt=None):
        fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) & ~os.O_NONBLOCK)
        fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) & ~os.O_NONBLOCK)
        # We can't use p.communicate here because the ControlMaster may have stdout open as well
        stdout = ''
        stderr = ''
        rpipes = [p.stdout, p.stderr]
        if indata:
            try:
                stdin.write(indata)
                stdin.close()
            except:
                raise errors.AnsibleError('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
        # Read stdout/stderr from process
        while True:
            rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)

            # fail early if the sudo/su password is wrong
            if self.runner.sudo and sudoable and self.runner.sudo_pass:
                incorrect_password = gettext.dgettext(
                    "sudo", "Sorry, try again.")
                if stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)):
                    raise errors.AnsibleError('Incorrect sudo password')

            if self.runner.su and su and self.runner.su_pass:
                incorrect_password = gettext.dgettext(
                    "su", "Sorry")
                if stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)):
                    raise errors.AnsibleError('Incorrect su password')

            if p.stdout in rfd:
                dat = os.read(p.stdout.fileno(), 9000)
                stdout += dat
                if dat == '':
                    rpipes.remove(p.stdout)
            if p.stderr in rfd:
                dat = os.read(p.stderr.fileno(), 9000)
                stderr += dat
                if dat == '':
                    rpipes.remove(p.stderr)
            # only break out if no pipes are left to read or
            # the pipes are completely read and
            # the process is terminated
            if (not rpipes or not rfd) and p.poll() is not None:
                break
            # No pipes are left to read but process is not yet terminated
            # Only then it is safe to wait for the process to be finished
            # NOTE: Actually p.poll() is always None here if rpipes is empty
            elif not rpipes and p.poll() == None:
                p.wait()
                # The process is terminated. Since no pipes to read from are
                # left, there is no need to call select() again.
                break
        # close stdin after process is terminated and stdout/stderr are read
        # completely (see also issue #848)
        stdin.close()
        return (p.returncode, stdout, stderr)
コード例 #7
0
ファイル: LocaleInfo.py プロジェクト: Alberto-Beralix/Beralix
 def translate_language(self, lang):
     "return translated language"
     if lang in self._lang:
         lang_name = gettext.dgettext("iso_639", self._lang[lang])
         if lang_name == self._lang[lang]:
             lang_name = gettext.dgettext("iso_639_3", self._lang[lang])
         return lang_name
     else:
         return lang
コード例 #8
0
ファイル: Setup.py プロジェクト: Open-Plus/opgui
	def addItems(self, list, parentNode):
		for x in parentNode:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))
				item_tunerlevel = int(x.get("tunerlevel", 0))
				item_rectunerlevel = int(x.get("rectunerlevel", 0))
				item_tuxtxtlevel = int(x.get("tt_level", 0))

				if not self.onNotifiers:
					self.onNotifiers.append(self.levelChanged)
					self.onClose.append(self.removeNotifier)

				if item_level > config.usage.setup_level.index:
					continue
				if (item_tuxtxtlevel == 1) and (config.usage.tuxtxt_font_and_res.value != "expert_mode"):
					continue
				if item_tunerlevel == 1 and not config.usage.frontend_priority.value in ("expert_mode", "experimental_mode"):
					continue
				if item_tunerlevel == 2 and not config.usage.frontend_priority.value == "experimental_mode":
					continue
				if item_rectunerlevel == 1 and not config.usage.recording_frontend_priority.value in ("expert_mode", "experimental_mode"):
					continue
				if item_rectunerlevel == 2 and not config.usage.recording_frontend_priority.value == "experimental_mode":
					continue

				requires = x.get("requires")
				if requires and requires.startswith('config.'):
					item = eval(requires or "")
					if item.value and not item.value == "0":
						SystemInfo[requires] = True
					else:
						SystemInfo[requires] = False

				if requires and not SystemInfo.get(requires, False):
					continue

				if self.PluginLanguageDomain:
					item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
					item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
				else:
					item_text = _(x.get("text", "??").encode("UTF-8"))
					item_description = _(x.get("description", " ").encode("UTF-8"))

				item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				b = eval(x.text or "")
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					list.append((item_text, item, item_description))
コード例 #9
0
ファイル: lang.py プロジェクト: Acidburn0zzz/ibus
def get_language_name(_locale):
    lang = _locale.split("_")[0]
    lang = lang.lower()
    if lang in __languages_dict:
        lang = __languages_dict[lang]
        lang = gettext.dgettext("iso_639", lang)
    else:
        lang = _(u"Other")
        lang = gettext.dgettext("ibus", lang)
    return lang
コード例 #10
0
 def main(self):
     thread = FontCacheThread()
     thread.start()
     while thread.isAlive():
         time.sleep(0.09)
         self.pgbar.pulse()          
         while gtk.events_pending():
             gtk.main_iteration()
     self.pgbar.set_fraction(1.0)
     self.button.show()
     self.pgbar.set_text(gettext.dgettext("nautilus-fontinstall","Update completed"))
     self.lbFinish.set_text(gettext.dgettext("nautilus-fontinstall","The font '")+
     self.file_cut+gettext.dgettext("nautilus-fontinstall","' has been installed"))
コード例 #11
0
 def main(self):
     thread = MiThread(self.lbMd5, self)
     thread.start()
     while thread.isAlive():
         time.sleep(0.09)
         self.pgbar.pulse()          
         while gtk.events_pending():
             gtk.main_iteration()
     self.pgbar.set_fraction(1.0)
     self.button.set_label(_("Ok"))
     self.pgbar.set_text(gettext.dgettext("nautilus-md5sum","Checking completed"))
     self.lbDef.set_text(gettext.dgettext("nautilus-md5sum","MD5Sum of '")+self.file_cut+gettext.dgettext("nautilus-md5sum","' is:"))
     self.copy.show()
コード例 #12
0
ファイル: Setup.py プロジェクト: OpenViX/enigma2
	def createSetupList(self):
		currentItem = self["config"].getCurrent()
		self.list = []
		for x in self.setup:
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))

				if item_level > config.usage.setup_level.index:
					continue

				requires = x.get("requires")
				if requires and not requires.startswith('config.'):
					if requires.startswith('!'):
						if SystemInfo.get(requires[1:], False):
							continue
					elif not SystemInfo.get(requires, False):
						continue
				conditional = x.get("conditional")
				if conditional and not eval(conditional):
					continue

				# this block is just for backwards compatibility
				if requires and requires.startswith('config.'):
					item = eval(requires)
					if not (item.value and not item.value == "0"):
						continue

				if self.PluginLanguageDomain:
					item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
					item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
				else:
					item_text = _(x.get("text", "??").encode("UTF-8"))
					item_description = _(x.get("description", " ").encode("UTF-8"))

				item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
				b = eval(x.text or "")
				if b == "":
					continue
				#add to configlist
				item = b
				# the first b is the item itself, ignored by the configList.
				# the second one is converted to string.
				if not isinstance(item, ConfigNothing):
					self.list.append((item_text, item, item_description))
		self["config"].setList(self.list)
		if config.usage.sort_settings.value:
			self["config"].list.sort()
		self.moveToItem(currentItem)
コード例 #13
0
ファイル: localize.py プロジェクト: muflone/cpucompare
def text(message, gtk30=False, context=None):
    """Return a translated message and cache it for reuse"""
    if message not in localized_messages:
        if gtk30:
            # Get a message translated from GTK+ 3 domain
            full_message = message if not context else '%s\04%s' % (
                context, message)
            localized_messages[message] = dgettext('gtk30', full_message)
            # Fix for untranslated messages with context
            if context and localized_messages[message] == full_message:
                localized_messages[message] = dgettext('gtk30', message)
        else:
            localized_messages[message] = gettext(message)
    return localized_messages[message]
コード例 #14
0
def sanitizeString(s, translate = True):
    if len(s) == 0:
        return s

    if not translate:
        i18ndomains = []
    elif hasattr(rpm, "expandMacro"):
        i18ndomains = rpm.expandMacro("%_i18ndomains").split(":")
    else:
        i18ndomains = ["redhat-dist"]
        
    # iterate over i18ndomains to find the translation
    for d in i18ndomains:
        r = gettext.dgettext(d, s)
        if r != s:
            s = r
            break
        
    s = s.replace("\n\n", "\x00")
    s = s.replace("\n", " ")
    s = s.replace("\x00", "\n\n")
    s = s.replace("&", "&")
    s = s.replace("<", "&lt;")
    s = s.replace(">", "&gt;")
    if type(s) != unicode:
        try:
            s = unicode(s, "utf-8")
        except UnicodeDecodeError, e:
            sys.stderr.write("Unable to convert %s to a unicode object: %s\n" % (s, e))
            return ""
コード例 #15
0
def _(txt):
    """ Custom gettext translation function that uses the CurlyTx domain """
    t = gettext.dgettext("CurlyTx", txt)
    if t == txt:
        #print "[CurlyTx] fallback to default translation for", txt
        t = gettext.gettext(txt)
    return t
コード例 #16
0
    def get_file_items(self, window, files):
        if len(files)!=1:
            return
        filename = files[0]

        if filename.get_mime_type() not in FORMAT:
            return
        items = []
        #Called when the user selects a file in Nautilus.
        item = nautilus.MenuItem("NautilusPython::md5sum_item",
                                 gettext.dgettext("nautilus-md5sum","Check MD5Sum"),
                                 gettext.dgettext("nautilus-md5sum","Check MD5Sum"))
        item.set_property('icon', "md5sum-ico")
        item.connect("activate", self.menu_activate_cb, files)
        items.append(item)
        return items
コード例 #17
0
ファイル: __init__.py プロジェクト: Haehnchen/enigma2-plugins
def _(txt): # pylint: disable-msg=C0103
	td = gettext.dgettext("NcidClient", txt)
	if td == txt:
		print "[NcidClient] fallback to default translation for", txt 
		td = gettext.gettext(txt)
		
	return td
コード例 #18
0
 def status_change(self, pkg, percent, status):
     if self._prev_percent + self.MIN_REPORTING < percent:
         # FIXME: move into ubuntu-release-upgrader after trusty
         domain = "libapt-pkg4.12"
         progress_str = dgettext(domain, "Progress: [%3i%%]") % int(percent)
         sys.stdout.write("\r\n%s\r\n" % progress_str)
         self._prev_percent = percent
コード例 #19
0
ファイル: __init__.py プロジェクト: Haehnchen/enigma2-plugins
def _(txt):
	t = gettext.dgettext(PluginLanguageDomain, txt)
	if t == txt:
		t = getDefaultTxt(txt)
		if t == txt:
			t = gettext.gettext(txt)
	return t
コード例 #20
0
def _(txt):
    t = gettext.dgettext(PluginLanguageDomain, txt)
    if t == txt:
        print "[" + PluginLanguageDomain + "] \
        fallback to default translation for ", txt
        t = gettext.gettext(txt)
    return t
コード例 #21
0
ファイル: __init__.py プロジェクト: Pizzaofen/enigmalight
def _(txt):
	if len(txt) == 0:
		return ""
	text = gettext.dgettext("EnigmaLight", txt)
	if text == txt:
		text = gettext.gettext(txt)
	return text
コード例 #22
0
def _(txt):
	t = gettext.dgettext(PluginLanguageDomain, txt)
	if t == txt:
# 		print "[%s] fallback to default translation for %s" %(PluginLanguageDomain, txt)
		t = _(txt)
		#t = gettext.gettext(txt)
	return t
コード例 #23
0
 def get_desktop(self, key, translated=True):
     # strip away bogus prefixes
     if key.startswith("X-AppInstall-"):
         key = key[len("X-AppInstall-"):]
     # shortcut
     if not translated:
         return self.tag_section[key]
     # FIXME: make i18n work similar to get_desktop
     # first try dgettext
     if "Gettext-Domain" in self.tag_section:
         value = self.tag_section.get(key)
         if value:
             domain = self.tag_section["Gettext-Domain"]
             translated_value = gettext.dgettext(domain, value)
             if value != translated_value:
                 return translated_value
     # then try the i18n version of the key (in [de_DE] or
     # [de]) but ignore errors and return the untranslated one then
     try:
         locale = getdefaultlocale(('LANGUAGE', 'LANG', 'LC_CTYPE',
             'LC_ALL'))[0]
         if locale:
             if self.has_option_desktop("%s-%s" % (key, locale)):
                 return self.tag_section["%s-%s" % (key, locale)]
             if "_" in locale:
                 locale_short = locale.split("_")[0]
                 if self.has_option_desktop("%s-%s" % (key, locale_short)):
                     return self.tag_section["%s-%s" % (key, locale_short)]
     except ValueError:
         pass
     # and then the untranslated field
     return self.tag_section[key]
コード例 #24
0
ファイル: xmlhelper.py プロジェクト: jmanoel7/my_dot_files
    def do_activate(self):
        self.app.set_accels_for_action("win.end_tag", ['<Ctrl>e'])
        self.app.set_accels_for_action("win.last_tag", ['<Ctrl>r'])
        self.app.set_accels_for_action("win.indent_xml", ['<Ctrl><Shift>f'])

        # Translate actions below, hardcoding domain here to avoid
        # complications now
        lambda s: gettext.dgettext('devhelp', s)

        self.menu_ext = self.extend_menu("tools-section")
        menu_model = Gio.Menu()

        for menu_name, action in (
            ('EndTag', 'end_tag'),
            ('LastTag', 'previous_tag'),
            ('ValidateXML', 'validate_xml'),
            ('ValidateSchema', 'validate_schema'),
            ('ConvertXML', 'convert_xml'),
            ('GenerateXML', 'generate_xml'),
            ('IndentXML', 'indent_xml'),
        ):
            item = Gio.MenuItem.new(_(menu_name), "win.%s" % action)
            menu_model.append_item(item)

        submenu = Gio.MenuItem.new_submenu('_XML Helper', menu_model)
        self.menu_ext.append_menu_item(submenu)
コード例 #25
0
def _(txt):
    if config.plugins.xModem.nolocale.value:
        return txt
    t = gettext.dgettext(PluginLangDomain, txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #26
0
 def __init__(self):
   # get a list of country codes and real names
   self.countries = {}
   fname = "/usr/share/xml/iso-codes/iso_3166.xml"
   if os.path.exists(fname):
     et = ElementTree(file=fname)
     it = et.getiterator('iso_3166_entry')
     for elm in it:
       if elm.attrib.has_key("common_name"):
         descr = elm.attrib["common_name"]
       else:
         descr = elm.attrib["name"]
       if elm.attrib.has_key("alpha_2_code"):
         code = elm.attrib["alpha_2_code"]
       else:
         code = elm.attrib["alpha_3_code"]
       self.countries[code] = gettext.dgettext('iso_3166',descr)
   self.country = None
   self.code = None
   locale = os.getenv("LANG", default="en.UK")
   a = locale.find("_")
   z = locale.find(".")
   if z == -1:
       z = len(locale)
   self.code = locale[a+1:z]
   self.country = self.get_country_name(self.code)
コード例 #27
0
ファイル: translation.py プロジェクト: hackedbellini/stoq
def dgettext(domain, message):
    # Empty strings doesn't need to be translated, and might cause
    # gettext() to replace with something which is not an empty string
    if message == "":
        return message

    return gettext_.dgettext(domain, message)
コード例 #28
0
ファイル: setup.py プロジェクト: Nomad280279/ibus-cangjie
    def __init__ (self, engine, datadir, gettext_package):
        self.settings = Gio.Settings("org.cangjians.ibus.%s" % engine)
        self.settings.connect("changed", self.on_value_changed)

        ui_file = GLib.build_filenamev([datadir, "setup.ui"])
        self.__builder = Gtk.Builder()
        self.__builder.set_translation_domain(gettext_package)
        self.__builder.add_from_file(ui_file)

        for key in ("version", ):
            combo = self.__builder.get_object(key)
            active = self.__get_active_combo_index(combo.get_model(),
                                                   self.settings.get_int(key))
            combo.set_active(active)
            combo.connect("changed", self.on_combo_changed, key)
            setattr(self, "widget_%s" % key, combo)

        for key in ("include-allzh", "include-jp",
                    "include-zhuyin", "include-symbols"):
            switch = self.__builder.get_object(key)
            switch.set_active(self.settings.get_boolean(key))
            switch.connect("notify::active", self.on_switch_toggled, key)
            setattr(self, "widget_%s" % key, switch)

        self.__window = self.__builder.get_object("setup_dialog")

        if engine == "cangjie":
            title = dgettext(gettext_package, "Cangjie Preferences")
        elif engine == "quick":
            title = dgettext(gettext_package, "Quick Preferences")

        self.__window.set_title(title)

        try:
            # Pretend to be a GNOME Control Center dialog if appropriate
            self.gnome_cc_xid = int(GLib.getenv('GNOME_CONTROL_CENTER_XID'))
            self.__window.set_wmclass('gnome-control-center',
                                      'Gnome-control-center')
            self.__window.set_modal(True)
            self.__window.connect('notify::window', self.set_transient)
            self.__window.set_type_hint(Gdk.WindowTypeHint.DIALOG)

        except:
            # No problem here, we're just a normal dialog
            pass

        self.__window.show()
コード例 #29
0
ファイル: _ssh.py プロジェクト: jpablo128/ansible-lxc-remote
        def _check_for_su_sudo_fail(self, data):
            if self.runner.sudo and self.sudoable:
                if self.runner.sudo_pass:
                    incorrect_password = gettext.dgettext(
                        "sudo", "Sorry, try again.")
                    if data.endswith("%s\r\n%s" % (incorrect_password,
                                                   self.prompt)):
                        raise errors.AnsibleError('Incorrect sudo password')

                if data.endswith(self.prompt):
                    raise errors.AnsibleError('Missing sudo password')

            if self.runner.su and su and self.runner.su_pass:
                incorrect_password = gettext.dgettext(
                    "su", "Sorry")
                if data.endswith("%s\r\n%s" % (incorrect_password, self.prompt)):
                    raise errors.AnsibleError('Incorrect su password')
コード例 #30
0
def _(txt):
	if txt:
		t = gettext.dgettext("InfoBarTunerState", txt)
		if t == txt:
			t = gettext.gettext(txt)
		return t 
	else:
		return ""
コード例 #31
0
def _(txt):
    t = gettext.dgettext('PPFlashBackup', txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #32
0
def _(txt):
    t = gettext.dgettext("SHOUTcast", txt)
    if t == txt:
        print "[SHOUTcast] fallback to default translation for", txt
        t = gettext.gettext(txt)
    return t
コード例 #33
0
#
# 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 St, Fifth Floor, Boston, MA  02110-1301 USA

from gi.repository import Gtk
from gi.repository import GObject
import gettext

from sugar3.graphics import style
from sugar3.graphics.icon import Icon

from jarabe.controlpanel.sectionview import SectionView
from jarabe.controlpanel.inlinealert import InlineAlert

_translate_language = lambda msg: gettext.dgettext('iso_639', msg)
_translate_country = lambda msg: gettext.dgettext('iso_3166', msg)

CLASS = 'Language'
ICON = 'module-language'
TITLE = gettext.gettext('Language')


class Language(SectionView):
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model
        self.restart_alerts = alerts
        self._lang_sid = 0
        self._selected_lang_count = 0
コード例 #34
0
ファイル: persist.py プロジェクト: xutian/ovirt-host-deploy
def _(m):
    return gettext.dgettext(message=m, domain='ovirt-host-deploy')
コード例 #35
0
def _(txt):
    t = gettext.dgettext("AdvancedMovieSelection", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #36
0
ファイル: __init__.py プロジェクト: NFR-Blasser/openNFR-gui2
def _(txt):
	t = gettext.dgettext(PluginLanguageDomain, txt)
	if t == txt:
		t = gettext.gettext(txt)
	return t
コード例 #37
0
    def _communicate(self, p, stdin, indata, sudoable=False, prompt=None):
        fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) & ~os.O_NONBLOCK)
        fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) & ~os.O_NONBLOCK)
        # We can't use p.communicate here because the ControlMaster may have stdout open as well
        stdout = ''
        stderr = ''
        rpipes = [p.stdout, p.stderr]
        timeout = 1
        if indata:
            try:
                stdin.write(indata)
                stdin.close()
            except:
                raise errors.AnsibleError('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
        # Read stdout/stderr from process
        while True:
            rfd, wfd, efd = select.select(rpipes, [], rpipes, timeout)

            # fail early if the become password is wrong
            if self.runner.become and sudoable:
                incorrect_password = gettext.dgettext(self.runner.become_method, C.BECOME_ERROR_STRINGS[self.runner.become_method])

                if prompt:
                    if self.runner.become_pass:
                        if stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)):
                            raise errors.AnsibleError('Incorrect become password')

                    if stdout.endswith(prompt):
                        raise errors.AnsibleError('Missing become password')
                    elif stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)):
                        raise errors.AnsibleError('Incorrect become password')

            if p.stdout in rfd:
                dat = os.read(p.stdout.fileno(), 9000)
                stdout += dat
                if dat == '':
                    rpipes.remove(p.stdout)
            if p.stderr in rfd:
                dat = os.read(p.stderr.fileno(), 9000)
                stderr += dat
                if dat == '':
                    rpipes.remove(p.stderr)

            # Has the child process exited? If it has,
            # and we've read all available output from it, we're done.

            if p.poll() is not None:
                if not rpipes or timeout == 0:
                    break

                # When ssh has ControlMaster (+ControlPath/Persist) enabled, the
                # first connection goes into the background and we never see EOF
                # on stderr. If we see EOF on stdout and the process has exited,
                # we're probably done. We call select again with a zero timeout,
                # just to make certain we don't miss anything that may have been
                # written to stderr between the time we called select() and when
                # we learned that the process had finished.

                if p.stdout not in rpipes:
                    timeout = 0
                    continue

            # If the process has not yet exited, but we've already read EOF from
            # its stdout and stderr (and thus removed both from rpipes), we can
            # just wait for it to exit.

            elif not rpipes:
                p.wait()
                break

            # Otherwise there may still be outstanding data to read.

        # close stdin after process is terminated and stdout/stderr are read
        # completely (see also issue #848)
        stdin.close()
        return (p.returncode, stdout, stderr)
コード例 #38
0
 def check_missing_password(self, b_output):
     b_missing_password = to_bytes(
         gettext.dgettext(
             self._play_context.become_method,
             C.BECOME_MISSING_STRINGS[self._play_context.become_method]))
     return b_missing_password and b_missing_password in b_output
コード例 #39
0
ファイル: ColorSelection.py プロジェクト: openatv/KravenFHD
def _(txt):
	t = gettext.dgettext("KravenFHD", txt)
	if t == txt:
		t = gettext.gettext(txt)
	return t
コード例 #40
0
ファイル: __init__.py プロジェクト: budinev/satlodge-plugin
def _(txt):
    t = gettext.dgettext('HistoryZapSelector', txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #41
0
ファイル: plugin.py プロジェクト: wolfje55/enigma2-plugins
def _(txt):
    t = gettext.dgettext("Mosaic", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #42
0
ファイル: __init__.py プロジェクト: betacentauri/Enigma2
def _(txt):
    t = gettext.dgettext("Extraspanel", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #43
0
def _(txt):
    if gettext.dgettext(PluginLanguageDomain, txt):
        return gettext.dgettext(PluginLanguageDomain, txt)
    else:
        print "[" + PluginLanguageDomain + "] fallback to default translation for " + txt
        return gettext.gettext(txt)
コード例 #44
0
def _(m):
    return gettext.dgettext(message=m, domain='ovirt-engine-setup')
コード例 #45
0
ファイル: __init__.py プロジェクト: satis4action/OpenPLi-PC
    isDreamOS = True
except:
    isDreamOS = False


def localeInit():
    if isDreamOS:  # check if opendreambox image
        lang = language.getLanguage(
        )[:2]  # getLanguage returns e.g. "fi_FI" for "language_country"
        os_environ[
            "LANGUAGE"] = lang  # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
    gettext.bindtextdomain(PluginLanguageDomain,
                           resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))


if isDreamOS:  # check if DreamOS image
    _ = lambda txt: gettext.dgettext(PluginLanguageDomain, txt) if txt else ""
    localeInit()
    language.addCallback(localeInit)
else:

    def _(txt):
        if gettext.dgettext(PluginLanguageDomain, txt):
            return gettext.dgettext(PluginLanguageDomain, txt)
        else:
            print(("[%s] fallback to default translation for %s" %
                   (PluginLanguageDomain, txt)))
            return gettext.gettext(txt)

    language.addCallback(localeInit())
コード例 #46
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""dwh plugin."""

import time
import gettext
_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup')

from otopi import util
from otopi import plugin

from ovirt_engine_setup import constants as osetupcons
from ovirt_engine_setup.engine import constants as oenginecons
from ovirt_engine_setup.engine_common import constants as oengcommcons
from ovirt_engine_setup.engine_common import dwh_history_timekeeping
from ovirt_engine_setup.engine_common import database
from ovirt_engine_setup.engine import vdcoption


@util.export
class Plugin(plugin.PluginBase):
    """dwh plugin."""
コード例 #47
0
ファイル: filetransaction.py プロジェクト: kshithijiyer/otopi
def _(m):
    return gettext.dgettext(message=m, domain='otopi')
コード例 #48
0
ファイル: __init__.py プロジェクト: norhap/enigma2-plugins-1
def _(txt):
	t = gettext.dgettext(PluginLanguageDomain, txt)
	if t == txt:
		print("[NetworkBrowser] fallback to default translation for", txt)
		t = gettext.gettext(txt)
	return t
コード例 #49
0
def _(txt):
	t = gettext.dgettext("xbmcaddons", txt)
	if t == txt:
		print "[XBMCAddonsA] fallback to default translation for", txt
		t = gettext.gettext(txt)
	return t
コード例 #50
0
settings_list, inputs_list, states_list = load_brush_definitions_from_json(
    open(definition_path, "r").read())


class BrushInput:
    pass


inputs = []
inputs_dict = {}
for i_list in inputs_list:
    i = BrushInput()

    i.name, i.hard_min, i.soft_min, i.normal, i.soft_max, i.hard_max, i.dname, i.tooltip = i_list

    i.dname = gettext.dgettext("libmypaint", i.dname)
    i.tooltip = gettext.dgettext("libmypaint", i.tooltip)

    i.index = len(inputs)
    inputs.append(i)
    inputs_dict[i.name] = i


class BrushSetting:
    pass


settings = []
settings_dict = {}
for s_list in settings_list:
    s = BrushSetting()
コード例 #51
0
 def check_missing_password(self, output):
     missing_password = gettext.dgettext(
         self._play_context.become_method,
         C.BECOME_MISSING_STRINGS[self._play_context.become_method])
     return missing_password and missing_password in output
コード例 #52
0
def _(txt):
    t = gettext.dgettext("PrimeTimeManager", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #53
0
ファイル: dialogs.py プロジェクト: nondasjr/kiwi
#
# Author(s): Johan Dahlin <*****@*****.**>
#

import contextlib
import os
import gettext

from gi.repository import Atk, Gtk, GLib

__all__ = [
    'error', 'info', 'messagedialog', 'warning', 'yesno', 'save', 'selectfile',
    'selectfolder', 'HIGAlertDialog', 'BaseDialog', 'ask_overwrite'
]

_ = lambda m: gettext.dgettext('kiwi', m)

_IMAGE_TYPES = {
    Gtk.MessageType.INFO: Gtk.STOCK_DIALOG_INFO,
    Gtk.MessageType.WARNING: Gtk.STOCK_DIALOG_WARNING,
    Gtk.MessageType.QUESTION: Gtk.STOCK_DIALOG_QUESTION,
    Gtk.MessageType.ERROR: Gtk.STOCK_DIALOG_ERROR,
}

_BUTTON_TYPES = {
    Gtk.ButtonsType.NONE: (),
    Gtk.ButtonsType.OK: (
        Gtk.STOCK_OK,
        Gtk.ResponseType.OK,
    ),
    Gtk.ButtonsType.CLOSE: (
コード例 #54
0
def _(txt):
    t = gettext.dgettext("reloadsl", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #55
0
ファイル: panel.py プロジェクト: nopain2110/kimtoy
#IBUS_SERVICE_KIMPANEL = "org.freedesktop.IBus.Panel.KIM"
#IBUS_PATH_KIMPANEL = "/org/freedesktop/IBus/Panel/KIM"

from ibus import *
from ibus.panel import *
from ibus.bus import Bus
from ibus.inputcontext import InputContext
from ibus import keysyms
#import ibus.interface
import gtk
import dbus

IBUS_ICON_DIR = '/usr/share/ibus/icons/'

from gettext import dgettext
_ = lambda a: dgettext("ibus", a)
N_ = lambda a: a


def prop2string(prop):
    __prop_key = '/IBus/' + prop.get_key()
    __prop_label = prop.get_label().get_text()
    __prop_icon = prop.get_icon()
    __prop_tip = prop.get_tooltip().get_text()

    # workaround
    if len(__prop_icon) == 0:
        # the setup icon
        if (prop.get_key() == 'setup'):
            __prop_icon = 'configure'
コード例 #56
0
def _(txt):
    t = gettext.dgettext(PluginLanguageDomain, txt)
    if t == txt:
        #print "[%s] fallback to default translation for %s" %(PluginLanguageDomain, txt)
        t = gettext.gettext(txt)
    return t
コード例 #57
0
 def check_incorrect_password(self, output):
     incorrect_password = gettext.dgettext(
         self._play_context.become_method,
         C.BECOME_ERROR_STRINGS[self._play_context.become_method])
     return incorrect_password and incorrect_password in output
コード例 #58
0
def _(txt):
    t = gettext.dgettext("ProjectValerie", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
コード例 #59
0
    def exec_command(self, cmd, tmp_path, become_user=None, sudoable=False, executable='/bin/sh', in_data=None):
        ''' run a command on the remote host '''

        if sudoable and self.runner.become and self.runner.become_method not in self.become_methods_supported:
            raise errors.AnsibleError("Internal Error: this module does not support running commands via %s" % self.runner.become_method)

        ssh_cmd = self._password_cmd()
        ssh_cmd += ["ssh", "-C"]
        if not in_data:
            # we can only use tty when we are not pipelining the modules. piping data into /usr/bin/python
            # inside a tty automatically invokes the python interactive-mode but the modules are not
            # compatible with the interactive-mode ("unexpected indent" mainly because of empty lines)
            ssh_cmd += ["-tt"]
        if utils.VERBOSITY > 3:
            ssh_cmd += ["-vvv"]
        else:
            if self.runner.module_name == 'raw':
                ssh_cmd += ["-q"]
            else:
                ssh_cmd += ["-v"]
        ssh_cmd += self.common_args

        if self.ipv6:
            ssh_cmd += ['-6']
        ssh_cmd += [self.host]

        if self.runner.become and sudoable:
            becomecmd, prompt, success_key = utils.make_become_cmd(cmd, become_user, executable, self.runner.become_method, '', self.runner.become_exe)
            ssh_cmd.append(becomecmd)
        else:
            prompt = None
            if executable:
                ssh_cmd.append(executable + ' -c ' + pipes.quote(cmd))
            else:
                ssh_cmd.append(cmd)

        vvv("EXEC %s" % ' '.join(ssh_cmd), host=self.host)

        not_in_host_file = self.not_in_host_file(self.host)

        if C.HOST_KEY_CHECKING and not_in_host_file:
            # lock around the initial SSH connectivity so the user prompt about whether to add
            # the host to known hosts is not intermingled with multiprocess output.
            fcntl.lockf(self.runner.process_lockfile, fcntl.LOCK_EX)
            fcntl.lockf(self.runner.output_lockfile, fcntl.LOCK_EX)

        # create process
        (p, stdin) = self._run(ssh_cmd, in_data)

        self._send_password()

        no_prompt_out = ''
        no_prompt_err = ''
        if sudoable and self.runner.become and self.runner.become_pass:
            # several cases are handled for escalated privileges with password
            # * NOPASSWD (tty & no-tty): detect success_key on stdout
            # * without NOPASSWD:
            #   * detect prompt on stdout (tty)
            #   * detect prompt on stderr (no-tty)
            fcntl.fcntl(p.stdout, fcntl.F_SETFL,
                        fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
            fcntl.fcntl(p.stderr, fcntl.F_SETFL,
                        fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
            become_output = ''
            become_errput = ''

            while True:
                if success_key in become_output or \
                    (prompt and become_output.endswith(prompt)) or \
                    utils.su_prompts.check_su_prompt(become_output):
                    break

                rfd, wfd, efd = select.select([p.stdout, p.stderr], [],
                                              [p.stdout], self.runner.timeout)
                if p.stderr in rfd:
                    chunk = p.stderr.read()
                    if not chunk:
                        raise errors.AnsibleError('ssh connection closed waiting for a privilege escalation password prompt')
                    become_errput += chunk
                    incorrect_password = gettext.dgettext(
                        "become", "Sorry, try again.")
                    if become_errput.strip().endswith("%s%s" % (prompt, incorrect_password)):
                        raise errors.AnsibleError('Incorrect become password')
                    elif prompt and become_errput.endswith(prompt):
                        stdin.write(self.runner.become_pass + '\n')

                if p.stdout in rfd:
                    chunk = p.stdout.read()
                    if not chunk:
                        raise errors.AnsibleError('ssh connection closed waiting for %s password prompt' % self.runner.become_method)
                    become_output += chunk

                if not rfd:
                    # timeout. wrap up process communication
                    stdout = p.communicate()
                    raise errors.AnsibleError('ssh connection error while waiting for %s password prompt' % self.runner.become_method)

            if success_key in become_output:
                no_prompt_out += become_output
                no_prompt_err += become_errput
            elif sudoable:
                stdin.write(self.runner.become_pass + '\n')

        (returncode, stdout, stderr) = self._communicate(p, stdin, in_data, sudoable=sudoable, prompt=prompt)

        if C.HOST_KEY_CHECKING and not_in_host_file:
            # lock around the initial SSH connectivity so the user prompt about whether to add 
            # the host to known hosts is not intermingled with multiprocess output.
            fcntl.lockf(self.runner.output_lockfile, fcntl.LOCK_UN)
            fcntl.lockf(self.runner.process_lockfile, fcntl.LOCK_UN)
        controlpersisterror = 'Bad configuration option: ControlPersist' in stderr or \
                              'unknown configuration option: ControlPersist' in stderr

        if C.HOST_KEY_CHECKING:
            if ssh_cmd[0] == "sshpass" and p.returncode == 6:
                raise errors.AnsibleError('Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host\'s fingerprint to your known_hosts file to manage this host.')

        if p.returncode != 0 and controlpersisterror:
            raise errors.AnsibleError('using -c ssh on certain older ssh versions may not support ControlPersist, set ANSIBLE_SSH_ARGS="" (or ssh_args in [ssh_connection] section of the config file) before running again')
        if p.returncode == 255 and (in_data or self.runner.module_name == 'raw'):
            raise errors.AnsibleError('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
        if p.returncode == 255:
            ip = None
            port = None
            for line in stderr.splitlines():
                match = re.search(
                    'Connecting to .*\[(\d+\.\d+\.\d+\.\d+)\] port (\d+)',
                    line)
                if match:
                    ip = match.group(1)
                    port = match.group(2)
            if 'UNPROTECTED PRIVATE KEY FILE' in stderr:
                lines = [line for line in stderr.splitlines()
                         if 'ignore key:' in line]
            else:
                lines = stderr.splitlines()[-1:]
            if ip and port:
                lines.append('    while connecting to %s:%s' % (ip, port))
            lines.append(
                'It is sometimes useful to re-run the command using -vvvv, '
                'which prints SSH debug output to help diagnose the issue.')
            raise errors.AnsibleError('SSH Error: %s' % '\n'.join(lines))

        return (p.returncode, '', no_prompt_out + stdout, no_prompt_err + stderr)
コード例 #60
0
 def check_incorrect_password(self, b_output):
     b_incorrect_password = to_bytes(
         gettext.dgettext(
             self._play_context.become_method,
             C.BECOME_ERROR_STRINGS[self._play_context.become_method]))
     return b_incorrect_password and b_incorrect_password in b_output