diff --git a/DrPrintBackend.py b/DrPrintBackend.py
index 66a213f..4884615 100644
--- a/DrPrintBackend.py
+++ b/DrPrintBackend.py
@@ -16,8 +16,6 @@ class Backend(gobject.GObject):
def __init__(self):
super(Backend, self).__init__()
- gobject.signal_new("auth_failed", Backend, gobject.SIGNAL_RUN_FIRST, None, ())
- gobject.signal_new('io_error', Backend, gobject.SIGNAL_RUN_FIRST, None, ())
def send_print(self, printer, username, password, page_per_page, filename, page_range, copies, orientation, sides):
# Get printer name
@@ -36,8 +34,7 @@ class Backend(gobject.GObject):
username=username,
password=password)
except paramiko.AuthenticationException, e:
- self.emit('auth_failed')
- return
+ raise PrintingError('Autenticazione fallita')
t = client.get_transport()
sftp = paramiko.SFTPClient.from_transport(t)
@@ -76,9 +73,13 @@ class Backend(gobject.GObject):
## Se ci sono opzioni dai il -o e specificale
if not cmd_opts == "":
cmd = cmd + "%s" % cmd_opts + " /tmp/drprint_tmp_%s" % username
-
- attr = sftp.put(filename, "/tmp/drprint_tmp_%s" % username)
- print "File trasferito, dimensione: %d bytes" % attr.st_size
+
+ try:
+ attr = sftp.put(filename, "/tmp/drprint_tmp_%s" % username)
+ except OSError:
+ raise PrintingError('Errore nel trasferimento del file')
+ else:
+ print "File trasferito, dimensione: %d bytes" % attr.st_size
# Apriamo la sessione.
chan = t.open_session()
diff --git a/DrPrintGui/MainWin.py b/DrPrintGui/MainWin.py
index 6b342e2..9182372 100644
--- a/DrPrintGui/MainWin.py
+++ b/DrPrintGui/MainWin.py
@@ -121,8 +121,6 @@ class MainWin(gtk.Window):
def connect_all(self):
self.print_button.connect('clicked', self.print_button_clicked_callback)
- self.backend.connect('auth_failed', self.auth_failed_callback)
- self.backend.connect('io_error', self.io_error_callback)
def print_button_clicked_callback(self, widget):
if not self.backend == None:
@@ -139,7 +137,8 @@ class MainWin(gtk.Window):
resp = gtk.RESPONSE_OK
if not (filename.lower().endswith("pdf") |
- filename.lower().endswith("ps")):
+ filename.lower().endswith("ps") |
+ filename.lower().endswith("txt")):
dialog = MessageDialog("Attenzione!",
"Il file che hai scelto di stampare\n\
non sembra essere un file <b>PS</b>,\n\
@@ -164,7 +163,7 @@ Se vuoi continuare premi OK")
sides = sides)
except PrintingError, e:
# Comunichiamo il fallimento
- dialog = ErrorDialog("Errore di stampa",
+ dialog = ErrorDialog("<b>Errore di stampa</b>",
"Il seguente errore si è verificato durante la stampa: %s." % e)
dialog.run()
dialog.destroy()
@@ -178,25 +177,6 @@ Se vuoi continuare premi OK")
self.debug( "Sembra che non ci sia un backend attaccato\
a questa interfaccia, quindi non faccio nulla")
- def auth_failed_callback(self, obj):
- """Questa funzione gestisce l'eventualità che utente
- e password siano errati"""
- self.debug("Autenticazione fallita")
- dialog = ErrorDialog("Autenticazione Fallita",
- "Lo username e la password forniti non sono\n\
-corretti. L'autenticazione su ssh.dm.unipi.it\nnon è andata a buon fine.")
- dialog.run()
- dialog.destroy()
-
- def io_error_callback(self, obj):
-
- self.debug("Errore di I/O")
- dialog = ErrorDialog("Errore di I/O",
- "C'è stato un errore nella lettura o nella\n \
-trasmissione del file.")
-
- dialog.run()
- dialog.destroy()