@ -25,17 +25,19 @@ import pty
from signal import SIGTERM
import termios
import tty
import gettext
import laditools
gettext.install(laditools.__name__)
try:
from gobject import timeout_add
import pygtk
pygtk.require ('2.0')
import gtk
import gtk.glade
import vte
import laditools
except Exception, e:
error = gtk.MessageDialog (None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "You need to get you dependencies right before you run this program. Ask your package maintainer why this is happening to you\n%s" % repr(e))
error = gtk.MessageDialog (None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _( "You need to get you dependencies right before you run this program. Ask your package maintainer why this is happening to you\n%s") % repr(e))
error.run ()
exit (1)
@ -65,7 +67,7 @@ def read_last(lfile, lines):
lfile.seek(endpos, 0)
return backlog
class ladilog (gtk.glade.XML ):
class ladilog(object ):
def __init__ (self):
self.log_files = [
{
@ -88,13 +90,13 @@ class ladilog (gtk.glade.XML):
self.global_config = laditools.config ()
self.param_dict = self.global_config.get_config_section ('ladilog')
for log in self.log_files:
for log in self.log_files:
if self.param_dict != None:
if log['config_name'] not in self.param_dict:
if log['config_name'] not in self.param_dict:
self.param_dict[log['config_name']] = log['config_default']
else:
self.param_dict = {}
self.param_dict[log['config_name']] = log['config_default']
self.param_dict = {}
self.param_dict[log['config_name']] = log['config_default']
if 'max_lines' not in self.param_dict:
self.param_dict['max_lines'] = max_lines_default
@ -104,27 +106,28 @@ class ladilog (gtk.glade.XML):
# skip logfiles that dont exist
if not os.access(log['logfile_path'], os.R_OK):
self.log_files.remove(log)
print "Skipping '%s' because it does not exist" % log['logfile_path']
print _( "Skipping '%s' because it does not exist") % log['logfile_path']
else:
print "Watching '%s'" % log['logfile_path']
print _( "Watching '%s'") % log['logfile_path']
max_lines_text = self.param_dict['max_lines']
self.max_lines = int (max_lines_text)
# Load the glade file
gtk.glade.XML.__init__(self, laditools.find_data_file("ladilog_ui.glade"))
builder = gtk.Builder()
builder.add_from_file(laditools.find_data_file("ladilog_ui.ui"))
# Get the ui ready for action
self.event_dict = {"on_ladilog_ui_destroy" : self.on_quit,
"on_close_button_clicked" : self.on_quit,
"on_clear_button_clicked" : self.on_clear_text,
"on_purge_button_clicked" : self.on_purge}
self.signal_autoconnect (self.event_dict)
builder.connect_signals (self.event_dict)
# Create our terminal and display it
for log in self.log_files:
log['term'] = vte.Terminal ()
log["tab_label"] = gtk.Label (log["name"])
self.logview_notebook = self.get_widge t ("ladilog_notebook")
self.logview_notebook = builder.get_objec t ("ladilog_notebook")
for log in self.log_files:
log['term'].show ()
@ -139,9 +142,9 @@ class ladilog (gtk.glade.XML):
log["term"].feed(line)
except ValueError:
print "You called Popen with invalid arguments... dumbass"
print _( "You called Popen with invalid arguments... dumbass")
except:
print "Unexpected error:", sys.exc_info ()[0]
print _( "Unexpected error:") , sys.exc_info ()[0]
for log in self.log_files:
self.logview_notebook.append_page (log["term"])
@ -176,12 +179,12 @@ class ladilog (gtk.glade.XML):
def run (self):
gtk.main ()
self.global_config.set_config_section ("ladilog", self.param_dict)
self.global_config.save ()
self.global_config.save ()
return 0
try:
ladilog().run()
except Exception, e:
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Unexpected error\n\n" + repr(e))
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _( "Unexpected error\n\n") + repr(e))
error.run()
exit(1)