Ejemplo n.º 1
0
def make_meta_file(path, url, piece_len_exp, flag=Event(), progress=dummy,
                   title=None, comment=None, safe=None, content_type=None,
                   target=None, url_list=None, name=None):
    data = {'announce': url.strip(), 'creation date': int(gmtime())}
    piece_length = 2 ** piece_len_exp
    a, b = os.path.split(path)
    if not target:
        if b == '':
            f = a + '.torrent'
        else:
            f = os.path.join(a, b + '.torrent')
    else:
        f = target
    info = makeinfo(path, piece_length, flag, progress, name, content_type)
    if flag.isSet():
        return
    check_info(info)
    h = file(f, 'wb')

    data['info'] = info
    lang = read_language_file() or 'en'
    if lang:
        data['locale'] = lang
    if title:
        data['title'] = title
    if comment:
        data['comment'] = comment
    if safe:
        data['safe'] = safe
    if url_list:
        data['url-list'] = url_list
    h.write(bencode(data))
    h.close()
Ejemplo n.º 2
0
    def __init__(self):
        gtk.Frame.__init__(self, "Translate %s into:" % app_name)
        self.set_border_width(SPACING)
        
        model = gtk.ListStore(*[gobject.TYPE_STRING] * 2)
        default = model.append(("System default", ''))

        lang = read_language_file()
        for l in languages:
            it = model.append((language_names[l].encode('utf8'), l))
            if l == lang:
                default = it

        self.combo = gtk.ComboBox(model)
        cell = gtk.CellRendererText()
        self.combo.pack_start(cell, True)
        self.combo.add_attribute(cell, 'text', 0)

        if default is not None:
            self.combo.set_active_iter(default)

        self.combo.connect('changed', self.changed)
        box = gtk.VBox(spacing=SPACING)
        box.set_border_width(SPACING)
        box.pack_start(self.combo, expand=False, fill=False)
        l = gtk.Label("You must restart %s for the\nlanguage "
                      "setting to take effect." % app_name)
        l.set_alignment(0,1)
        l.set_line_wrap(True)
        box.pack_start(l, expand=False, fill=False)
        self.add(box)
Ejemplo n.º 3
0
    def __init__(self):
        gtk.Frame.__init__(self, "Translate %s into:" % app_name)
        self.set_border_width(SPACING)

        model = gtk.ListStore(*[gobject.TYPE_STRING] * 2)
        default = model.append(("System default", ''))

        lang = read_language_file()
        for l in languages:
            it = model.append((language_names[l].encode('utf8'), l))
            if l == lang:
                default = it

        self.combo = gtk.ComboBox(model)
        cell = gtk.CellRendererText()
        self.combo.pack_start(cell, True)
        self.combo.add_attribute(cell, 'text', 0)

        if default is not None:
            self.combo.set_active_iter(default)

        self.combo.connect('changed', self.changed)
        box = gtk.VBox(spacing=SPACING)
        box.set_border_width(SPACING)
        box.pack_start(self.combo, expand=False, fill=False)
        l = gtk.Label("You must restart %s for the\nlanguage "
                      "setting to take effect." % app_name)
        l.set_alignment(0, 1)
        l.set_line_wrap(True)
        box.pack_start(l, expand=False, fill=False)
        self.add(box)
    def __init__(self, parent, *a, **k):
        wx.Panel.__init__(self, parent, *a, **k)
        self.sizer = VSizer()
        self.SetSizer(self.sizer)
        if 'errback' in k:
            self.errback = k.pop('errback')
        else:
            self.errback = self.set_language_failed

        # widgets
        self.box = wx.StaticBox(self, label="Translate %s into:" % app_name)

        self.language_names = [
            "System default",
        ] + [language_names[l] for l in languages]
        languages.insert(0, '')
        self.languages = languages
        self.choice = wx.Choice(self, choices=self.language_names)
        self.Bind(wx.EVT_CHOICE, self.set_language, self.choice)

        restart = wx.StaticText(
            self, -1, "You must restart %s for the\nlanguage "
            "setting to take effect." % app_name)

        self.bottom_error = wx.StaticText(self, -1, '')
        self.bottom_error.SetForegroundColour(error_color)

        # sizers
        self.box_sizer = wx.StaticBoxSizer(self.box, wx.VERTICAL)

        # set menu selection and warning item if necessary
        self.valid = True
        lang = read_language_file()
        if lang is not None:
            try:
                i = self.languages.index(lang)
                self.choice.SetSelection(i)
            except ValueError, e:
                self.top_error = wx.StaticText(
                    self,
                    -1,
                    "This version of %s does not \nsupport the language '%s'."
                    % (app_name, lang),
                )
                self.top_error.SetForegroundColour(error_color)

                self.box_sizer.Add(self.top_error,
                                   flag=wx.TOP | wx.LEFT | wx.RIGHT,
                                   border=SPACING)
                # BUG add menu separator
                # BUG change color of extra menu item
                self.choice.Append(lang)
                self.choice.SetSelection(len(self.languages))
                self.valid = False
Ejemplo n.º 5
0
    def __init__(self, parent, *a, **k):
        wx.Panel.__init__(self, parent, *a, **k)
        self.sizer = VSizer()
        self.SetSizer(self.sizer)
        if 'errback' in k:
            self.errback = k.pop('errback')
        else:
            self.errback = self.set_language_failed

        # widgets
        self.box = wx.StaticBox(self, label="Translate %s into:" % app_name)

        self.language_names = ["System default",] + [language_names[l] for l in languages]
        languages.insert(0, '')
        self.languages = languages
        self.choice = wx.Choice(self, choices=self.language_names)
        self.Bind(wx.EVT_CHOICE, self.set_language, self.choice)

        restart = wx.StaticText(self, -1,
                                "You must restart %s for the\nlanguage "
                                "setting to take effect." % app_name)

        self.bottom_error = wx.StaticText(self, -1, '')
        self.bottom_error.SetForegroundColour(error_color)

        # sizers
        self.box_sizer = wx.StaticBoxSizer(self.box, wx.VERTICAL)

        # set menu selection and warning item if necessary
        self.valid = True
        lang = read_language_file()
        if lang is not None:
            try:
                i = self.languages.index(lang)
                self.choice.SetSelection(i)
            except ValueError, e:
                self.top_error = wx.StaticText(self, -1,
                                     "This version of %s does not \nsupport the language '%s'."%(app_name,lang),)
                self.top_error.SetForegroundColour(error_color)

                self.box_sizer.Add(self.top_error, flag=wx.TOP|wx.LEFT|wx.RIGHT, border=SPACING)
                # BUG add menu separator
                # BUG change color of extra menu item
                self.choice.Append(lang)
                self.choice.SetSelection(len(self.languages))
                self.valid = False
Ejemplo n.º 6
0
def make_meta_file(path,
                   url,
                   piece_len_exp,
                   flag=Event(),
                   progress=dummy,
                   title=None,
                   comment=None,
                   safe=None,
                   content_type=None,
                   target=None,
                   url_list=None,
                   name=None,
                   micropayments=False):
    data = {'announce': url.strip(), 'creation date': int(gmtime())}
    piece_length = 2**piece_len_exp
    a, b = os.path.split(path)
    if not target:
        if b == '':
            f = a + '.torrent'
        else:
            f = os.path.join(a, b + '.torrent')
    else:
        f = target
    info = makeinfo(path, piece_length, flag, progress, name, content_type)
    if flag.isSet():
        return
    check_info(info)
    h = file(f, 'wb')

    data['info'] = info
    lang = read_language_file() or 'en'
    if lang:
        data['locale'] = lang
    if title:
        data['title'] = title
    if comment:
        data['comment'] = comment
    if safe:
        data['safe'] = safe
    if url_list:
        data['url-list'] = url_list
    if micropayments:
        data['micropayments'] = micropayments
    h.write(bencode(data))
    h.close()
Ejemplo n.º 7
0
def make_meta_file(
    path,
    url,
    piece_len_exp,
    flag=Event(),
    progress=dummy,
    title=None,
    comment=None,
    safe=None,
    content_type=None,
    target=None,
    url_list=None,
    name=None,
):
    data = {"announce": url.strip(), "creation date": int(time())}
    piece_length = 2 ** piece_len_exp
    a, b = os.path.split(path)
    if not target:
        if b == "":
            f = a + ".torrent"
        else:
            f = os.path.join(a, b + ".torrent")
    else:
        f = target
    info = makeinfo(path, piece_length, flag, progress, name, content_type)
    if flag.isSet():
        return
    check_info(info)
    h = file(f, "wb")

    data["info"] = info
    lang = read_language_file() or "en"
    if lang:
        data["locale"] = lang
    if title:
        data["title"] = title
    if comment:
        data["comment"] = comment
    if safe:
        data["safe"] = safe
    if url_list:
        data["url-list"] = url_list
    h.write(bencode(data))
    h.close()