specify types in all str.format() calls (fixes #169)

This commit is contained in:
Micah Lee 2015-05-15 12:26:58 -07:00
parent 8086ed8c64
commit 669750be37
18 changed files with 65 additions and 66 deletions

View File

@ -1,7 +1,7 @@
{ {
"connecting_ctrlport": "Verbinde zum Tor-Kontrollport um den versteckten Dienst auf Port {0} laufen zu lassen.", "connecting_ctrlport": "Verbinde zum Tor-Kontrollport um den versteckten Dienst auf Port {0:d} laufen zu lassen.",
"cant_connect_ctrlport": "Konnte keine Verbindung zum Tor-Kontrollport auf Port {0} aufbauen. Läuft Tor?", "cant_connect_ctrlport": "Konnte keine Verbindung zum Tor-Kontrollport auf Port {0:d} aufbauen. Läuft Tor?",
"cant_connect_socksport": "Konnte keine Verbindung zum Tor SOCKS5 Server auf Port {0} herstellen. OnionShare setzt voraus dass Tor Browser im Hintergrund läuft. Wenn du noch ihn noch noch nicht hast kannst du ihn unter https://www.torproject.org/ herunterladen.", "cant_connect_socksport": "Konnte keine Verbindung zum Tor SOCKS5 Server auf Port {0:d} herstellen. OnionShare setzt voraus dass Tor Browser im Hintergrund läuft. Wenn du noch ihn noch noch nicht hast kannst du ihn unter https://www.torproject.org/ herunterladen.",
"preparing_files": "Dateien werden vorbereitet.", "preparing_files": "Dateien werden vorbereitet.",
"wait_for_hs": "Warte auf HS:", "wait_for_hs": "Warte auf HS:",
"wait_for_hs_trying": "Verbindungsversuch...", "wait_for_hs_trying": "Verbindungsversuch...",
@ -9,7 +9,7 @@
"wait_for_hs_yup": "Bereit!", "wait_for_hs_yup": "Bereit!",
"give_this_url": "Geben Sie diese URL der Person, der Sie die Datei zusenden möchten:", "give_this_url": "Geben Sie diese URL der Person, der Sie die Datei zusenden möchten:",
"ctrlc_to_stop": "Drücken Sie Strg+C um den Server anzuhalten", "ctrlc_to_stop": "Drücken Sie Strg+C um den Server anzuhalten",
"not_a_file": "{0} ist keine Datei.", "not_a_file": "{0:s} ist keine Datei.",
"download_size": "Dateigrösse", "download_size": "Dateigrösse",
"filename": "Dateiname", "filename": "Dateiname",
"size": "Dateigröße", "size": "Dateigröße",

View File

@ -1,7 +1,7 @@
{ {
"connecting_ctrlport": "Connecting to Tor control port to set up hidden service on port {0}.", "connecting_ctrlport": "Connecting to Tor control port to set up hidden service on port {0:d}.",
"cant_connect_ctrlport": "Can't connect to Tor control port on port {0}. OnionShare requires Tor Browser to be running in the background to work. If you don't have it you can get it from https://www.torproject.org/.", "cant_connect_ctrlport": "Can't connect to Tor control port on port {0:d}. OnionShare requires Tor Browser to be running in the background to work. If you don't have it you can get it from https://www.torproject.org/.",
"cant_connect_socksport": "Can't connect to Tor SOCKS5 server on port {0}. OnionShare requires Tor Browser to be running in the background to work. If you don't have it you can get it from https://www.torproject.org/.", "cant_connect_socksport": "Can't connect to Tor SOCKS5 server on port {0:d}. OnionShare requires Tor Browser to be running in the background to work. If you don't have it you can get it from https://www.torproject.org/.",
"preparing_files": "Preparing files to share.", "preparing_files": "Preparing files to share.",
"wait_for_hs": "Waiting for HS to be ready:", "wait_for_hs": "Waiting for HS to be ready:",
"wait_for_hs_trying": "Trying...", "wait_for_hs_trying": "Trying...",
@ -9,7 +9,7 @@
"wait_for_hs_yup": "Ready!", "wait_for_hs_yup": "Ready!",
"give_this_url": "Give this URL to the person you're sending the file to:", "give_this_url": "Give this URL to the person you're sending the file to:",
"ctrlc_to_stop": "Press Ctrl-C to stop server", "ctrlc_to_stop": "Press Ctrl-C to stop server",
"not_a_file": "{0} is not a file.", "not_a_file": "{0:s} is not a file.",
"download_size": "Download size", "download_size": "Download size",
"filename": "Filename", "filename": "Filename",
"size": "Size", "size": "Size",

View File

@ -1,7 +1,7 @@
{ {
"connecting_ctrlport": "Conectando a puerto control de Tor para configurar servicio oculto en puerto {0}.", "connecting_ctrlport": "Conectando a puerto control de Tor para configurar servicio oculto en puerto {0:d}.",
"cant_connect_ctrlport": "No se pudo conectar a puerto control de Tor en puertos {0}. ¿Está funcionando Tor?", "cant_connect_ctrlport": "No se pudo conectar a puerto control de Tor en puertos {0:d}. ¿Está funcionando Tor?",
"cant_connect_socksport": "No se pudo conectar al servidor SOCKS5 de Tor en el puerto {0}. ¿Está funcionando Tor?", "cant_connect_socksport": "No se pudo conectar al servidor SOCKS5 de Tor en el puerto {0:d}. ¿Está funcionando Tor?",
"preparing_files": "Preparando los archivos para compartir.", "preparing_files": "Preparando los archivos para compartir.",
"wait_for_hs": "Esperando a que HS esté listo:", "wait_for_hs": "Esperando a que HS esté listo:",
"wait_for_hs_trying": "Probando...", "wait_for_hs_trying": "Probando...",
@ -9,7 +9,7 @@
"wait_for_hs_yup": "Listo!", "wait_for_hs_yup": "Listo!",
"give_this_url": "Entregue esta URL a la persona a la que está enviando el archivo:", "give_this_url": "Entregue esta URL a la persona a la que está enviando el archivo:",
"ctrlc_to_stop": "Pulse Ctrl-C para detener el servidor", "ctrlc_to_stop": "Pulse Ctrl-C para detener el servidor",
"not_a_file": "{0} no es un archivo.", "not_a_file": "{0:s} no es un archivo.",
"download_size": "Tamaño de la descarga", "download_size": "Tamaño de la descarga",
"filename": "Archivo", "filename": "Archivo",
"size": "Tamaño", "size": "Tamaño",

View File

@ -1,7 +1,7 @@
{ {
"connecting_ctrlport": "Yhdistetään Torin ohjausporttiin että saadaan salattu palvelin porttiin {0}.", "connecting_ctrlport": "Yhdistetään Torin ohjausporttiin että saadaan salattu palvelin porttiin {0:d}.",
"cant_connect_ctrlport": "Ei voi yhdistää Torin ohjausporttiin portissa {0}. OnionShare tarvitsee Tor Browserin toimimaan taustalla. Jos sinulla ei ole sitä niin voit hakea sen osoitteesta https://www.torproject.org/.", "cant_connect_ctrlport": "Ei voi yhdistää Torin ohjausporttiin portissa {0:d}. OnionShare tarvitsee Tor Browserin toimimaan taustalla. Jos sinulla ei ole sitä niin voit hakea sen osoitteesta https://www.torproject.org/.",
"cant_connect_socksport": "Ei voi yhdistää Tor SOCKS5 palveluun portissa {0}. OnionShare tarvitsee Tor Browserin toimimaan taustalla. Jos sinulla ei ole sitä niin voit hakea sen osoitteesta https://www.torproject.org/.", "cant_connect_socksport": "Ei voi yhdistää Tor SOCKS5 palveluun portissa {0:d}. OnionShare tarvitsee Tor Browserin toimimaan taustalla. Jos sinulla ei ole sitä niin voit hakea sen osoitteesta https://www.torproject.org/.",
"preparing_files": "Valmistellaan tiedostoja jaettavaksi.", "preparing_files": "Valmistellaan tiedostoja jaettavaksi.",
"wait_for_hs": "Odotetaan piilopalvelun valmistumista:", "wait_for_hs": "Odotetaan piilopalvelun valmistumista:",
"wait_for_hs_trying": "Yritetään...", "wait_for_hs_trying": "Yritetään...",
@ -9,7 +9,7 @@
"wait_for_hs_yup": "Valmis!", "wait_for_hs_yup": "Valmis!",
"give_this_url": "Anna tämä URL-osoite henkilölle, jolle lähetät tiedostot:", "give_this_url": "Anna tämä URL-osoite henkilölle, jolle lähetät tiedostot:",
"ctrlc_to_stop": "Näppäin Ctrl-C pysäyttää palvelimen", "ctrlc_to_stop": "Näppäin Ctrl-C pysäyttää palvelimen",
"not_a_file": "{0} Ei ole tiedosto.", "not_a_file": "{0:s} Ei ole tiedosto.",
"download_size": "Download size", "download_size": "Download size",
"filename": "Filename", "filename": "Filename",
"size": "Size", "size": "Size",

View File

@ -1,6 +1,6 @@
{ {
"connecting_ctrlport": "Connexion au réseau Tor pour mettre en place un Hidden Service sur le port {0}.", "connecting_ctrlport": "Connexion au réseau Tor pour mettre en place un Hidden Service sur le port {0:d}.",
"cant_connect_ctrlport": "Impossible de se connecter au port de contrôle Tor sur le port {0}. Est-ce que Tor tourne ?", "cant_connect_ctrlport": "Impossible de se connecter au port de contrôle Tor sur le port {0:d}. Est-ce que Tor tourne ?",
"preparing_files": "Préparation des fichiers à partager.", "preparing_files": "Préparation des fichiers à partager.",
"wait_for_hs": "En attente du HS:", "wait_for_hs": "En attente du HS:",
"wait_for_hs_trying": "Tentative...", "wait_for_hs_trying": "Tentative...",
@ -8,7 +8,7 @@
"wait_for_hs_yup": "Prêt !", "wait_for_hs_yup": "Prêt !",
"give_this_url": "Donnez cette URL à la personne qui doit recevoir le fichier :", "give_this_url": "Donnez cette URL à la personne qui doit recevoir le fichier :",
"ctrlc_to_stop": "Ctrl-C arrête le serveur", "ctrlc_to_stop": "Ctrl-C arrête le serveur",
"not_a_file": "{0} n'est pas un fichier.", "not_a_file": "{0:s} n'est pas un fichier.",
"download_size": "Taille de téléchargement", "download_size": "Taille de téléchargement",
"filename": "Nom du fichier", "filename": "Nom du fichier",
"size": "Taille", "size": "Taille",

View File

@ -1,9 +1,9 @@
{ {
"connecting_ctrlport": "Connessione alla porta di controllo di Tor per inizializzare il servizio nascosto sulla porta {0}.", "connecting_ctrlport": "Connessione alla porta di controllo di Tor per inizializzare il servizio nascosto sulla porta {0:d}.",
"cant_connect_ctrlport": "Impossibile connettere alla porta di controllo di Tor tramite le porte {0}. Tor è stato avviato?", "cant_connect_ctrlport": "Impossibile connettere alla porta di controllo di Tor tramite le porte {0:d}. Tor è stato avviato?",
"give_this_url": "Comunica questo URL alla persona a cui vuoi inviare il file:", "give_this_url": "Comunica questo URL alla persona a cui vuoi inviare il file:",
"ctrlc_to_stop": "Premi Ctrl-C per fermare il server", "ctrlc_to_stop": "Premi Ctrl-C per fermare il server",
"not_a_file": "{0} non è un file.", "not_a_file": "{0:s} non è un file.",
"gui_copied_url": "URL copiato negli appunti", "gui_copied_url": "URL copiato negli appunti",
"download_page_loaded": "Pagina di download caricata", "download_page_loaded": "Pagina di download caricata",
"other_page_loaded": "Un altra pagina é stata caricata", "other_page_loaded": "Un altra pagina é stata caricata",

View File

@ -1,7 +1,7 @@
{ {
"connecting_ctrlport": "Verbinden met de Tor controle port om een verborgen service op te zetten op poort {0}.", "connecting_ctrlport": "Verbinden met de Tor controle port om een verborgen service op te zetten op poort {0:d}.",
"cant_connect_ctrlport": "Kan geen verbinding maken met Tor controle poort op poort {0}. OnionShare heeft de Tor Browser op de achtergrond nodig om te kunnen werken. Deze kan je verkrijgen via https://www.torproject.org/.", "cant_connect_ctrlport": "Kan geen verbinding maken met Tor controle poort op poort {0:d}. OnionShare heeft de Tor Browser op de achtergrond nodig om te kunnen werken. Deze kan je verkrijgen via https://www.torproject.org/.",
"cant_connect_socksport": "Kan geen verbinding maken met de Tor SOCKS5 server op poort {0}. OnionShare heeft de Tor Browser op de achtergrond nodig om te werken. Deze kan je verkrijgen via from https://www.torproject.org/.", "cant_connect_socksport": "Kan geen verbinding maken met de Tor SOCKS5 server op poort {0:d}. OnionShare heeft de Tor Browser op de achtergrond nodig om te werken. Deze kan je verkrijgen via from https://www.torproject.org/.",
"preparing_files": "Bestanden om te delen aan het voorbereiden.", "preparing_files": "Bestanden om te delen aan het voorbereiden.",
"wait_for_hs": "Wachten op gereed zijn van HS:", "wait_for_hs": "Wachten op gereed zijn van HS:",
"wait_for_hs_trying": "Proberen...", "wait_for_hs_trying": "Proberen...",
@ -9,7 +9,7 @@
"wait_for_hs_yup": "Gereed!", "wait_for_hs_yup": "Gereed!",
"give_this_url": "Geef deze URL aan de persoon aan wie je dit bestand verzend:", "give_this_url": "Geef deze URL aan de persoon aan wie je dit bestand verzend:",
"ctrlc_to_stop": "Druk Ctrl-C om de server te stoppen", "ctrlc_to_stop": "Druk Ctrl-C om de server te stoppen",
"not_a_file": "{0} is geen bestand.", "not_a_file": "{0:s} is geen bestand.",
"download_size": "Downloadgrootte", "download_size": "Downloadgrootte",
"filename": "Bestandsnaam", "filename": "Bestandsnaam",
"size": "Grootte", "size": "Grootte",

View File

@ -1,9 +1,9 @@
{ {
"connecting_ctrlport": "Kobler til Tors kontroll-port for å sette opp en gjemt tjeneste på port {0}.", "connecting_ctrlport": "Kobler til Tors kontroll-port for å sette opp en gjemt tjeneste på port {0:d}.",
"cant_connect_ctrlport": "Klarte ikke å koble til Tors kontroll-porter {0}. Sjekk at Tor kjører.", "cant_connect_ctrlport": "Klarte ikke å koble til Tors kontroll-porter {0:d}. Sjekk at Tor kjører.",
"give_this_url": "Gi personen du vil sende filen til denne URL-en:", "give_this_url": "Gi personen du vil sende filen til denne URL-en:",
"ctrlc_to_stop": "Trykk Ctrl+C for å stoppe serveren.", "ctrlc_to_stop": "Trykk Ctrl+C for å stoppe serveren.",
"not_a_file": "{0} er ikke en fil.", "not_a_file": "{0:s} er ikke en fil.",
"gui_copied_url": "Kopierte URL-en til utklippstavlen", "gui_copied_url": "Kopierte URL-en til utklippstavlen",
"download_page_loaded": "Nedlastingsside lastet", "download_page_loaded": "Nedlastingsside lastet",
"other_page_loaded": "En annen side har blitt lastet", "other_page_loaded": "En annen side har blitt lastet",

View File

@ -1,9 +1,9 @@
{ {
"connecting_ctrlport": "Conectando-se à porta de controle Tor para configurar serviço escondido na porta {0}.", "connecting_ctrlport": "Conectando-se à porta de controle Tor para configurar serviço escondido na porta {0:d}.",
"cant_connect_ctrlport": "Não pode conectar à porta de controle Tor na porta {0}. O Tor está rodando?", "cant_connect_ctrlport": "Não pode conectar à porta de controle Tor na porta {0:d}. O Tor está rodando?",
"give_this_url": "Passe este URL para a pessoa que deve receber o arquivo:", "give_this_url": "Passe este URL para a pessoa que deve receber o arquivo:",
"ctrlc_to_stop": "Pressione Ctrl-C para parar o servidor", "ctrlc_to_stop": "Pressione Ctrl-C para parar o servidor",
"not_a_file": "{0} não é um arquivo.", "not_a_file": "{0:s} não é um arquivo.",
"gui_copied_url": "URL foi copiado para área de transferência", "gui_copied_url": "URL foi copiado para área de transferência",
"download_page_loaded": "Página de download carregada", "download_page_loaded": "Página de download carregada",
"other_page_loaded": "Outra página tem sido carregada", "other_page_loaded": "Outra página tem sido carregada",

View File

@ -1,9 +1,9 @@
{ {
"connecting_ctrlport": "Соединяемся с контрольным портом Tor для создания скрытого сервиса на порту {0}.", "connecting_ctrlport": "Соединяемся с контрольным портом Tor для создания скрытого сервиса на порту {0:d}.",
"cant_connect_ctrlport": "Невозможно соединиться с контрольным портом Tor на порту {0}. Tor запущен?", "cant_connect_ctrlport": "Невозможно соединиться с контрольным портом Tor на порту {0:d}. Tor запущен?",
"give_this_url": "Отправьте эту ссылку тому человеку, которому вы хотите передать файл:", "give_this_url": "Отправьте эту ссылку тому человеку, которому вы хотите передать файл:",
"ctrlc_to_stop": "Нажмите Ctrl-C чтобы остановить сервер", "ctrlc_to_stop": "Нажмите Ctrl-C чтобы остановить сервер",
"not_a_file": "{0} не является файлом.", "not_a_file": "{0:s} не является файлом.",
"gui_copied_url": "Ссылка скопирована в буфер обмена", "gui_copied_url": "Ссылка скопирована в буфер обмена",
"download_page_loaded": "Страница закачки загружена", "download_page_loaded": "Страница закачки загружена",
"other_page_loaded": "Другая страница была загружена", "other_page_loaded": "Другая страница была загружена",

View File

@ -1,9 +1,9 @@
{ {
"connecting_ctrlport": "{0} portundaki gizli servis kurulumu için Tor kontrol portuna bağlanıyor.", "connecting_ctrlport": "{0:d} portundaki gizli servis kurulumu için Tor kontrol portuna bağlanıyor.",
"cant_connect_ctrlport": "Tor kontrol {0} portuna bağlanamıyor. Tor çalışıyor mu?", "cant_connect_ctrlport": "Tor kontrol {0:d} portuna bağlanamıyor. Tor çalışıyor mu?",
"give_this_url": "Dosyayı gönderdiğin kişiye bu URL'i verin:", "give_this_url": "Dosyayı gönderdiğin kişiye bu URL'i verin:",
"ctrlc_to_stop": "Sunucuyu durdurmak için, Ctrl-C basın", "ctrlc_to_stop": "Sunucuyu durdurmak için, Ctrl-C basın",
"not_a_file": "{0} dosya değil.", "not_a_file": "{0:s} dosya değil.",
"gui_copied_url": "Panoya kopyalanan URL", "gui_copied_url": "Panoya kopyalanan URL",
"download_page_loaded": "İndirme sayfası yüklendi", "download_page_loaded": "İndirme sayfası yüklendi",
"other_page_loaded": "Diğer sayfa yüklendi", "other_page_loaded": "Diğer sayfa yüklendi",

View File

@ -70,14 +70,14 @@ def random_string(num_bytes, output_len=None):
def human_readable_filesize(b): def human_readable_filesize(b):
thresh = 1024.0 thresh = 1024.0
if b < thresh: if b < thresh:
return '{0} B'.format(b) return '{0:.1f} B'.format(b)
units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
u = 0 u = 0
b /= thresh b /= thresh
while b >= thresh: while b >= thresh:
b /= thresh b /= thresh
u += 1 u += 1
return '{0} {1}'.format(round(b, 1), units[u]) return '{0:.1f} {1:s}'.format(round(b, 1), units[u])
def is_root(): def is_root():
@ -99,7 +99,7 @@ class ZipWriter(object):
if zip_filename: if zip_filename:
self.zip_filename = zip_filename self.zip_filename = zip_filename
else: else:
self.zip_filename = '{0}/onionshare_{1}.zip'.format(tempfile.mkdtemp(), random_string(4, 6)) self.zip_filename = '{0:s}/onionshare_{1:s}.zip'.format(tempfile.mkdtemp(), random_string(4, 6))
self.z = zipfile.ZipFile(self.zip_filename, 'w', allowZip64=True) self.z = zipfile.ZipFile(self.zip_filename, 'w', allowZip64=True)

View File

@ -101,13 +101,13 @@ class OnionShare(object):
args = ['/usr/bin/gksudo', '-D', 'OnionShare', '--', '/usr/bin/onionshare'] args = ['/usr/bin/gksudo', '-D', 'OnionShare', '--', '/usr/bin/onionshare']
else: else:
args = ['/usr/bin/sudo', '--', '/usr/bin/onionshare'] args = ['/usr/bin/sudo', '--', '/usr/bin/onionshare']
print "Executing: {0}".format(args+[str(self.port)]) print "Executing: {0:s}".format(args+[str(self.port)])
p = subprocess.Popen(args+[str(self.port)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) p = subprocess.Popen(args+[str(self.port)], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout = p.stdout.read(22) # .onion URLs are 22 chars long stdout = p.stdout.read(22) # .onion URLs are 22 chars long
if stdout: if stdout:
self.onion_host = stdout self.onion_host = stdout
print 'Got onion_host: {0}'.format(self.onion_host) print 'Got onion_host: {0:s}'.format(self.onion_host)
else: else:
if p.poll() == -1: if p.poll() == -1:
raise TailsError(o.stderr.read()) raise TailsError(o.stderr.read())
@ -116,7 +116,7 @@ class OnionShare(object):
else: else:
if self.local_only: if self.local_only:
self.onion_host = '127.0.0.1:{0}'.format(self.port) self.onion_host = '127.0.0.1:{0:d}'.format(self.port)
else: else:
# come up with a hidden service directory name # come up with a hidden service directory name
@ -160,12 +160,12 @@ class OnionShare(object):
del hsdic['HiddenServicePort'][dropme] del hsdic['HiddenServicePort'][dropme]
hsdic['HiddenServiceDir'] = hsdic.get('HiddenServiceDir', [])+[self.hidserv_dir] hsdic['HiddenServiceDir'] = hsdic.get('HiddenServiceDir', [])+[self.hidserv_dir]
hsdic['HiddenServicePort'] = hsdic.get('HiddenServicePort', [])+[ hsdic['HiddenServicePort'] = hsdic.get('HiddenServicePort', [])+[
'80 127.0.0.1:{0}'.format(self.port)] '80 127.0.0.1:{0:d}'.format(self.port)]
self.controller.set_options(hsdic2list(hsdic)) self.controller.set_options(hsdic2list(hsdic))
# figure out the .onion hostname # figure out the .onion hostname
hostname_file = '{0}/hostname'.format(self.hidserv_dir) hostname_file = '{0:s}/hostname'.format(self.hidserv_dir)
self.onion_host = open(hostname_file, 'r').read().strip() self.onion_host = open(hostname_file, 'r').read().strip()
def wait_for_hs(self): def wait_for_hs(self):
@ -177,13 +177,13 @@ class OnionShare(object):
ready = False ready = False
while not ready: while not ready:
try: try:
sys.stdout.write('{0} '.format(strings._('wait_for_hs_trying'))) sys.stdout.write('{0:s} '.format(strings._('wait_for_hs_trying')))
sys.stdout.flush() sys.stdout.flush()
if helpers.get_platform() == 'Tails': if helpers.get_platform() == 'Tails':
# in Tails everything is proxies over Tor already # in Tails everything is proxies over Tor already
# so no need to set the socks5 proxy # so no need to set the socks5 proxy
urllib2.urlopen('http://{0}'.format(self.onion_host)) urllib2.urlopen('http://{0:s}'.format(self.onion_host))
else: else:
tor_exists = False tor_exists = False
tor_socks_ports = [9050, 9150] tor_socks_ports = [9050, 9150]
@ -201,12 +201,12 @@ class OnionShare(object):
raise NoTor(strings._("cant_connect_socksport").format(tor_socks_ports)) raise NoTor(strings._("cant_connect_socksport").format(tor_socks_ports))
ready = True ready = True
sys.stdout.write('{0}\n'.format(strings._('wait_for_hs_yup'))) sys.stdout.write('{0:s}\n'.format(strings._('wait_for_hs_yup')))
except socks.SOCKS5Error: # non-Tails error except socks.SOCKS5Error: # non-Tails error
sys.stdout.write('{0}\n'.format(strings._('wait_for_hs_nope'))) sys.stdout.write('{0:s}\n'.format(strings._('wait_for_hs_nope')))
sys.stdout.flush() sys.stdout.flush()
except urllib2.HTTPError: # Tails error except urllib2.HTTPError: # Tails error
sys.stdout.write('{0}\n'.format(strings._('wait_for_hs_nope'))) sys.stdout.write('{0:s}\n'.format(strings._('wait_for_hs_nope')))
sys.stdout.flush() sys.stdout.flush()
except KeyboardInterrupt: except KeyboardInterrupt:
return False return False
@ -223,7 +223,7 @@ def tails_root():
try: try:
port = int(args.port[0]) port = int(args.port[0])
except ValueError: except ValueError:
sys.stderr.write('{0}\n'.format(strings._("error_tails_invalid_port"))) sys.stderr.write('{0:s}\n'.format(strings._("error_tails_invalid_port")))
sys.exit(-1) sys.exit(-1)
# open hole in firewall # open hole in firewall
@ -316,7 +316,7 @@ def main():
sys.exit() sys.exit()
print strings._("give_this_url") print strings._("give_this_url")
print 'http://{0}/{1}'.format(app.onion_host, web.slug) print 'http://{0:s}/{1:s}'.format(app.onion_host, web.slug)
print '' print ''
print strings._("ctrlc_to_stop") print strings._("ctrlc_to_stop")

View File

@ -102,7 +102,7 @@ def debug_mode():
else: else:
temp_dir = '/tmp/' temp_dir = '/tmp/'
log_handler = logging.FileHandler('{0}/onionshare_server.log'.format(temp_dir)) log_handler = logging.FileHandler('{0:s}/onionshare_server.log'.format(temp_dir))
log_handler.setLevel(logging.WARNING) log_handler.setLevel(logging.WARNING)
app.logger.addHandler(log_handler) app.logger.addHandler(log_handler)
@ -114,7 +114,7 @@ def index(slug_candidate):
add_request(REQUEST_LOAD, request.path) add_request(REQUEST_LOAD, request.path)
return render_template_string( return render_template_string(
open('{0}/index.html'.format(helpers.get_onionshare_dir())).read(), open('{0:s}/index.html'.format(helpers.get_onionshare_dir())).read(),
slug=slug, slug=slug,
file_info=file_info, file_info=file_info,
filename=os.path.basename(zip_filename).decode("utf-8"), filename=os.path.basename(zip_filename).decode("utf-8"),
@ -161,9 +161,9 @@ def download(slug_candidate):
# tell GUI the progress # tell GUI the progress
downloaded_bytes = fp.tell() downloaded_bytes = fp.tell()
percent = round((1.0 * downloaded_bytes / zip_filesize) * 100, 2) percent = (1.0 * downloaded_bytes / zip_filesize) * 100
sys.stdout.write( sys.stdout.write(
"\r{0}, {1}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent)) "\r{0:s}, {1:.2f}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
sys.stdout.flush() sys.stdout.flush()
add_request(REQUEST_PROGRESS, path, {'id': download_id, 'bytes': downloaded_bytes}) add_request(REQUEST_PROGRESS, path, {'id': download_id, 'bytes': downloaded_bytes})
except: except:
@ -198,7 +198,7 @@ def download(slug_candidate):
@app.errorhandler(404) @app.errorhandler(404)
def page_not_found(e): def page_not_found(e):
add_request(REQUEST_OTHER, request.path) add_request(REQUEST_OTHER, request.path)
return render_template_string(open('{0}/404.html'.format(helpers.get_onionshare_dir())).read()) return render_template_string(open('{0:s}/404.html'.format(helpers.get_onionshare_dir())).read())
# shutting down the server only works within the context of flask, so the easiest way to do it is over http # shutting down the server only works within the context of flask, so the easiest way to do it is over http
shutdown_slug = helpers.random_string(16) shutdown_slug = helpers.random_string(16)
@ -232,6 +232,6 @@ def stop(port):
s = socket.socket() s = socket.socket()
s.connect(('127.0.0.1', port)) s.connect(('127.0.0.1', port))
s.sendall('GET /{0}/shutdown HTTP/1.1\r\n\r\n'.format(shutdown_slug)) s.sendall('GET /{0:s}/shutdown HTTP/1.1\r\n\r\n'.format(shutdown_slug))
else: else:
urllib2.urlopen('http://127.0.0.1:{0}/{1}/shutdown'.format(port, shutdown_slug)).read() urllib2.urlopen('http://127.0.0.1:{0:d}/{1:s}/shutdown'.format(port, shutdown_slug)).read()

View File

@ -65,7 +65,7 @@ class Downloads(QtGui.QVBoxLayout):
if downloaded_bytes == pb.total_bytes: if downloaded_bytes == pb.total_bytes:
pb.setFormat("%p%") pb.setFormat("%p%")
else: else:
pb.setFormat("{0}, %p%".format(helpers.human_readable_filesize(downloaded_bytes))) pb.setFormat("{0:s}, %p%".format(helpers.human_readable_filesize(downloaded_bytes)))
def cancel_download(self, download_id): def cancel_download(self, download_id):
pb = self.progress_bars[download_id] pb = self.progress_bars[download_id]

View File

@ -117,7 +117,7 @@ class FileList(QtGui.QListWidget):
size = helpers.human_readable_filesize(fileinfo.size()) size = helpers.human_readable_filesize(fileinfo.size())
else: else:
size = helpers.human_readable_filesize(helpers.dir_size(filename)) size = helpers.human_readable_filesize(helpers.dir_size(filename))
item_name = unicode('{0} ({1})'.format(basename, size)) item_name = unicode('{0:s} ({1:s})'.format(basename, size))
item = QtGui.QListWidgetItem(item_name) item = QtGui.QListWidgetItem(item_name)
item.setToolTip(QtCore.QString(size)) item.setToolTip(QtCore.QString(size))

View File

@ -200,7 +200,7 @@ class OnionShareGui(QtGui.QWidget):
self.downloads.cancel_download(event["data"]["id"]) self.downloads.cancel_download(event["data"]["id"])
elif event["path"] != '/favicon.ico': elif event["path"] != '/favicon.ico':
self.status_bar.showMessage('{0}: {1}'.format(strings._('other_page_loaded', True), event["path"])) self.status_bar.showMessage('{0:s}: {1:s}'.format(strings._('other_page_loaded', True), event["path"]))
def copy_url(self): def copy_url(self):
self.status_bar.showMessage(strings._('gui_copied_url', True), 2000) self.status_bar.showMessage(strings._('gui_copied_url', True), 2000)

View File

@ -84,7 +84,7 @@ class ServerStatus(QtGui.QVBoxLayout):
# set the URL fields # set the URL fields
if self.status == self.STATUS_STARTED: if self.status == self.STATUS_STARTED:
self.url_label.setText('http://{0}/ {1}'.format(self.app.onion_host, self.web.slug)) self.url_label.setText('http://{0:s}/ {1:s}'.format(self.app.onion_host, self.web.slug))
self.url_label.show() self.url_label.show()
self.copy_url_button.show() self.copy_url_button.show()
else: else:
@ -132,7 +132,7 @@ class ServerStatus(QtGui.QVBoxLayout):
self.update() self.update()
def copy_url(self): def copy_url(self):
url = 'http://{0}/{1}'.format(self.app.onion_host, self.web.slug) url = 'http://{0:s}/{1:s}'.format(self.app.onion_host, self.web.slug)
if platform.system() == 'Windows': if platform.system() == 'Windows':
# Qt's QClipboard isn't working in Windows # Qt's QClipboard isn't working in Windows
@ -152,4 +152,3 @@ class ServerStatus(QtGui.QVBoxLayout):
clipboard.setText(url) clipboard.setText(url)
self.url_copied.emit() self.url_copied.emit()