[gnome-schedule] remove trailing whitespaces
- From: Gaute Hope <gauteh src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-schedule] remove trailing whitespaces
- Date: Thu, 9 Jul 2009 11:54:49 +0000 (UTC)
commit 14abdcee7f5bf71229391bc0a70b88f8799dc4f6
Author: Gaute Hope <eg gaute vetsj com>
Date: Thu Jul 9 13:54:44 2009 +0200
remove trailing whitespaces
ChangeLog | 6 +
src/at.py | 142 ++++++++++++------------
src/atEditor.py | 162 ++++++++++++++--------------
src/crontabEditor.py | 156 ++++++++++++++--------------
src/crontabEditorHelper.py | 28 +++---
src/data.py | 30 +++---
src/gnome-schedule.py | 4 +-
src/lang.py | 22 ++--
src/mainWindow.py | 252 ++++++++++++++++++++++----------------------
src/scheduleapplet.py | 42 ++++----
src/setuserWindow.py | 22 ++--
src/template.py | 56 +++++-----
src/template_chooser.py | 44 ++++----
src/template_manager.py | 64 ++++++------
src/xwrapper.py | 10 +-
15 files changed, 523 insertions(+), 517 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7d28dc5..79fd963 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-09 Gaute Hope <eg gaute vetsj com>
+
+ * Bug 588091: By Paul Hodges <phodeges4 gmail com>: Make sure return
+ types are correct in get_job_data of crontab.py
+ * Remove trailing whitespaces
+
2009-07-08 Gaute Hope <eg gaute vetsj com>
* Bug 588091: By Paul Hodges <phodges4 gmail com>: make sure display,
diff --git a/src/at.py b/src/at.py
index 7eebea9..87ee49b 100644
--- a/src/at.py
+++ b/src/at.py
@@ -33,7 +33,7 @@ import config
class At:
def __init__(self,root,user,uid,gid,user_home_dir,manual_poscorrect):
-
+
#default preview length
self.preview_len = 50
self.root = root
@@ -49,17 +49,17 @@ class At:
# 3 Tue May 8 01:01:00 2007 a gaute
self.atRecordRegex = re.compile('^([\d]+)[\t]([\w]{3,3})[\s]([\w]{3,3})[\s]*([\d]+)[\s]([\d]{2,2}[:][\d]{2,2}[:][\d]{2,2})[\s]([\d]{4,4})[\s]([\w])[\s]([\w]+)')
-
+
# after you add a job, this line is printed to stderr
# job 10 at 2006-09-18 12:38
self.atRecordRegexAdd = re.compile('^job\s([0-9]+)\sat')
-
+
self.atRecordRegexAdded = re.compile('[^\s]+\s([0-9]+)\sat')
self.SCRIPT_DELIMITER = "###### ---- GNOME_SCHEDULE_SCRIPT_DELIMITER #####"
-
+
self.DISPLAY = "DISPLAY=%s; export DISPLAY;\n"
- self.DISPLAY = self.DISPLAY + "XAUTHORITY=" + user_home_dir + "/.Xauthority; export XAUTHORITY;\n"
+ self.DISPLAY = self.DISPLAY + "XAUTHORITY=" + user_home_dir + "/.Xauthority; export XAUTHORITY;\n"
self.DISPLAY = self.DISPLAY + config.xwrapper_exec + " a\n"
self.DISPLAY = self.DISPLAY + """
xwrapper=$?;
@@ -71,11 +71,11 @@ else
fi
"""
- # If normally this variable is unset the user would not expect it
+ # If normally this variable is unset the user would not expect it
# to be set, which it will be because Gnome Schedule needs it.
- # Therefore we unset it in the script.
+ # Therefore we unset it in the script.
self.POSIXLY_CORRECT_UNSET = "unset POSIXLY_CORRECT\n"
-
+
self.atdatafileversion = 5
self.atdata = self.user_home_dir + "/.gnome/gnome-schedule/at"
if os.path.exists (self.user_home_dir + "/.gnome") != True:
@@ -89,7 +89,7 @@ fi
os.chown (self.atdata, self.uid, self.gid)
except:
print _("Failed to create data dir! Make sure ~/.gnome and ~/.gnome/gnome-schedule are writable.")
-
+
self.months = {
'Jan' : '1',
'Feb' : '2',
@@ -104,7 +104,7 @@ fi
'Nov' : '11',
'Dec' : '12'
}
-
+
def set_rights(self,user,uid,gid, ud):
self.user = user
self.uid = uid
@@ -123,36 +123,36 @@ fi
except:
print (_("Failed to create data dir: %s. Make sure ~/.gnome and ~/.gnome/gnome-schedule are writable.") % (self.atdata))
-
+
def get_type (self):
return "at"
-
+
def parse (self, line, output = True):
if (output == True):
if len (line) > 1 and line[0] != '#':
m = self.atRecordRegex.match(line)
- if m != None:
+ if m != None:
# Time
time = m.groups ()[4][:-3]
-
+
# Date
day = m.groups ()[3]
month = m.groups ()[2]
-
+
for monthname in self.months:
month = month.replace (monthname, self.months[monthname])
-
+
if int (day) < 10:
day = "0" + day
if int (month) < 10:
month = "0" + month
-
+
date = day + "." + month + "." + m.groups ()[5]
job_id = m.groups ()[0]
class_id = m.groups ()[6]
user = m.groups ()[7]
-
+
success, title, desc, manual_poscorrect, output, display = self.get_job_data (int (job_id))
# manual_poscorrect is only used during preparation of script
@@ -160,11 +160,11 @@ fi
# read lines and detect starter
script = os.popen(execute).read()
script, dangerous = self.__prepare_script__ (script, manual_poscorrect, output, display)
-
+
#removing ending newlines, but keep one
#if a date in the past is selected the record is removed by at, this creates an error, and generally if the script is of zero length
# TODO: complain about it as well
-
+
if len(script) < 2:
done = 1
else:
@@ -177,7 +177,7 @@ fi
done = 1
return job_id, date, time, class_id, user, script, title, dangerous, output
-
+
elif (output == False):
if len (line) > 1 and line[0] != '#':
m = self.atRecordRegexAdd.search(line)
@@ -198,7 +198,7 @@ fi
if os.access (f, os.R_OK):
fh = open (f, 'r')
d = fh.read ()
-
+
ver_p = d.find ("ver=")
if ver_p == -1:
ver = 1
@@ -206,18 +206,18 @@ fi
ver_s = d[ver_p + 4:d.find ("\n")]
d = d[d.find ("\n") + 1:]
ver = int (ver_s)
-
+
title = d[6:d.find ("\n")]
d = d[d.find ("\n") + 1:]
-
+
# icons out
if ver < 2:
icon = d[5:d.find ("\n")]
d = d[d.find ("\n") + 1:]
-
+
desc = d[5:d.find ("\n")]
d = d[d.find ("\n") + 1:]
-
+
manual_poscorrect_b = False
if ver > 2:
manual_poscorrect = d[18:d.find ("\n")]
@@ -226,7 +226,7 @@ fi
manual_poscorrect_b = True
elif manual_poscorrect == "false":
manual_poscorrect_b = False
-
+
if ver >= 5:
output_str = d[7:d.find ("\n")]
output = int (output_str)
@@ -243,12 +243,12 @@ fi
display = ""
fh.close ()
-
+
return True, title, desc, manual_poscorrect_b, output, display
-
- else:
+
+ else:
return False, "", "", False, 0, ""
-
+
def write_job_data (self, job_id, title, desc, output, display):
# Create and write data file
f = os.path.join (self.atdata, str(job_id))
@@ -258,7 +258,7 @@ fi
fh.write ("ver=" + str(self.atdatafileversion) + "\n")
fh.write ("title=" + title + "\n")
fh.write ("desc=" + desc + "\n")
-
+
# This one doesn't need to be passed independently for each job since the job data is only updated together with a task being appended or updated (also new added), and the variable depends on each session. Not job.
if self.manual_poscorrect == True:
fh.write ("manual_poscorrect=true\n")
@@ -271,12 +271,12 @@ fi
fh.close ()
os.chown (f, self.uid, self.gid)
os.chmod (f, 0600)
-
+
def checkfield (self, runat):
regexp1 = re.compile ("([0-9][0-9])([0-9][0-9])\ ([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9][0-9][0-9])")
regexp2 = re.compile("([0-9][0-9])([0-9][0-9])")
regexp3 = re.compile("([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9][0-9][0-9])")
-
+
runat_g1 = regexp1.match(runat)
runat_g2 = regexp2.match(runat)
runat_g3 = regexp3.match(runat)
@@ -286,7 +286,7 @@ fi
cday = ctime[2]
chour = ctime[3]
cminute = ctime[4]
-
+
if runat_g1:
(hour, minute, day, month, year) = runat_g1.groups()
hour = int(hour)
@@ -297,20 +297,20 @@ fi
if hour > 24 or hour < 0:
return False, "hour"
-
+
if minute > 60 or minute < 0:
return False, "minute"
-
+
if month > 12 or month < 0:
return False, "month"
-
+
if day > 31 or day < 0:
return False, "day"
-
+
if year < 0:
return False, "year"
-
- if year >= cyear:
+
+ if year >= cyear:
if year == cyear:
syear = True
if (month >= cmonth):
@@ -348,7 +348,7 @@ fi
minute = int(minute)
if hour > 24 or hour < 0:
return False, "hour"
-
+
if minute > 60 or minute < 0:
return False, "minute"
@@ -369,14 +369,14 @@ fi
else:
#lowercase
runat = runat.lower()
-
+
#some timespecs:
days = ['sun','mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sunday','monday','tuesday','wednesday','thursday','friday','saturday']
relative_days = ['tomorrow','next week','today']
relative_hour = ['noon','teatime','midnight','next hour']
relative_minute = ['next minute']
relative_month = ['next month']
-
+
if runat in days:
pass
elif runat in relative_days:
@@ -392,7 +392,7 @@ fi
return True, "ok"
-
+
def append (self, runat, command, title, output):
tmpfile = tempfile.mkstemp ()
fd, path = tmpfile
@@ -405,10 +405,10 @@ fi
if output > 0:
display = os.getenv ('DISPLAY')
tmp.write (self.DISPLAY % display )
-
+
tmp.write (command + "\n")
tmp.close ()
-
+
temp = None
if self.root == 1:
@@ -431,12 +431,12 @@ fi
t = self.parse (line, False)
if t != False:
job_id = t
-
+
#print job_id
-
+
desc = ""
self.write_job_data (job_id, title, desc, output, display)
-
+
os.unlink (path)
@@ -448,7 +448,7 @@ fi
os.unlink (f)
execute = config.getAtrmbin()+ " " + str(job_id)
commands.getoutput(execute)
-
+
#add new
tmpfile = tempfile.mkstemp ()
fd, path = tmpfile
@@ -485,14 +485,14 @@ fi
t = self.parse (line, False)
if t != False:
job_id = t
-
+
#print job_id
-
+
desc = ""
self.write_job_data (job_id, title, desc, output, display)
-
+
os.unlink (path)
-
+
def delete (self, job_id, iter):
if job_id:
@@ -502,38 +502,38 @@ fi
os.unlink (f)
execute = config.getAtrmbin()+ " " + str(job_id)
commands.getoutput(execute)
-
-
+
+
def read (self):
data = []
#do 'atq'
execute = config.getAtqbin ()
self.lines = os.popen(execute).readlines()
for line in self.lines:
-
+
array_or_false = self.parse (line)
#print array_or_false
if array_or_false != False:
(job_id, date, time, class_id, user, lines, title, dangerous, output) = array_or_false
-
+
preview = self.__make_preview__ (lines)
if dangerous == 1:
preview = _("Warning! Unknown task: %(preview)s") % {'preview': preview}
#chopping of script delimiter
lines.strip ()
-
+
timestring = "%s %s" % (date, time)
date_o = datetime.datetime.strptime (date + " " + time, "%d.%m.%Y %H:%M")
timestring_show = _("On %(timestring)s") % { 'timestring' : date_o.strftime ("%c") }
-
+
# TODO: looks like it could be one append
if self.root == 1:
if self.user == user:
data.append([title, timestring_show, preview, lines, int(job_id), timestring, self, None, date, class_id, user, time, _("Once"), "at", output, timestring])
- else:
+ else:
#print "Record omitted, not current user"
pass
else:
@@ -541,12 +541,12 @@ fi
#print _("added %(id)s") % { "id": job_id }
else:
- print _("Warning: a line in atq's output didn't parse")
+ print _("Warning: a line in atq's output didn't parse")
return data
-
+
def __prepare_script__ (self, script, manual_poscorrect, output, display):
-
+
# It looks like at prepends a bunch of stuff to each script
# Luckily it delimits that using two newlines
# So assuming that at never prepends two newlines unless
@@ -554,7 +554,7 @@ fi
# once the first two lines have been found
# Later: It now seems like this is incorrect, and may vary upon distribution. I therefore determine the prepended stuff by making a test job and then removing the length of it. in gentoo it adds to newlines at the end of the script
-
+
# If the script is created by Gnome Schedule the script is seperated by a delimiter.
dangerous = 0
@@ -593,15 +593,15 @@ fi
else:
title = "Untitled"
# If the string contains ICON=
- iconstart = script.find ("ICON=")
+ iconstart = script.find ("ICON=")
if iconstart != -1:
iconend = script.find ("\n", iconstart)
icon = script[(iconstart + 5):iconend]
-
+
prelen = prelen + len(icon) + 6
-
+
else:
- icon = None
+ icon = None
script = script[prelen:]
@@ -644,4 +644,4 @@ fi
result = result + "..."
return result
-
+
diff --git a/src/atEditor.py b/src/atEditor.py
index aeec061..725923a 100644
--- a/src/atEditor.py
+++ b/src/atEditor.py
@@ -39,11 +39,11 @@ class AtEditor:
self.backend = backend
self.scheduler = scheduler
self.template = template
-
+
self.widget = self.xml.get_widget("at_editor")
self.xml.signal_connect("on_at_editor_delete", self.on_button_cancel_clicked)
-
+
self.mode = 0 # 0 = add, 1 = edit, 2 = template
self.button_save = self.xml.get_widget ("at_button_save")
@@ -61,15 +61,15 @@ class AtEditor:
self.spin_year = self.xml.get_widget ("at_spin_year")
self.spin_month = self.xml.get_widget ("at_spin_month")
self.spin_day = self.xml.get_widget ("at_spin_day")
-
+
self.title_box = self.xml.get_widget ("title_box")
-
+
self.image_icon = gtk.Image ()
self.image_icon.set_from_pixbuf (self.ParentClass.bigiconat)
self.title_box.pack_start (self.image_icon, False, False, 0)
self.title_box.reorder_child (self.image_icon, 0)
self.image_icon.show ()
-
+
self.cal_button = self.xml.get_widget ("cal_button")
self.cal_hbox = gtk.HBox ()
self.calicon = gtk.Image ()
@@ -81,17 +81,17 @@ class AtEditor:
self.cal_hbox.add (self.arrow)
self.cal_button.add (self.cal_hbox)
self.cal_button.show_all ()
-
+
self.xml.signal_connect ("on_cal_button_toggled", self.on_cal_button_toggled)
self.xml.signal_connect ("on_cb_xoutput_toggled", self.on_cb_xoutput_toggled)
-
+
self.cal_loaded = False
self.x, self.y = self.widget.get_position ()
self.height, self.width = self.widget.get_size ()
self.cal_active = True
-
+
self.xml.signal_connect ("on_at_editor_size_changed", self.on_at_editor_size_changed)
-
+
self.xml.signal_connect("on_at_button_cancel_clicked", self.on_button_cancel_clicked)
self.xml.signal_connect("on_at_button_save_clicked", self.on_button_save_clicked)
@@ -102,21 +102,21 @@ class AtEditor:
self.xml.signal_connect("on_at_button_cancel_clicked", self.on_button_cancel_clicked)
self.xml.signal_connect ("on_at_button_template_clicked", self.on_button_template_clicked)
-
+
self.check_spin_running = False
-
+
self.xml.signal_connect("on_at_spin_hour_changed", self.on_spin_hour_changed)
self.xml.signal_connect("on_at_spin_minute_changed", self.on_spin_minute_changed)
self.xml.signal_connect ("on_at_spin_year_changed", self.on_spin_year_changed)
self.xml.signal_connect ("on_at_spin_month_changed", self.on_spin_month_changed)
self.xml.signal_connect ("on_at_spin_day_changed", self.on_spin_day_changed)
-
+
ctime = time.localtime()
year = ctime[0]
self.spin_year.set_range (year, year + 5847) # TODO: Year +5847 compatability
self.timeout_handler_id = gobject.timeout_add(60 * 1000, self.__check_spins__)
-
-
+
+
def showadd (self, transient):
self.button_save.set_label (gtk.STOCK_ADD)
self.__reset__ ()
@@ -130,16 +130,16 @@ class AtEditor:
self.widget.show_all ()
self.output = 0
self.cb_xoutput.set_active (0)
-
+
self.__update_textboxes__()
-
+
def showadd_template (self, transient, title, command, output):
self.button_save.set_label (gtk.STOCK_ADD)
self.__reset__ ()
self.title = title
self.command = command
self.mode = 0 # add new task
- self.output = output
+ self.output = output
self.cb_xoutput.set_active (output)
self.widget.set_title(_("Create a New Scheduled Task"))
self.widget.set_transient_for(transient)
@@ -147,9 +147,9 @@ class AtEditor:
self.__setup_calendar__ ()
self.button_add_template.show ()
self.widget.show_all ()
-
+
self.__update_textboxes__()
-
+
def showedit_template (self, transient, id, title, command, output):
self.button_save.set_label (gtk.STOCK_ADD)
self.__reset__ ()
@@ -157,45 +157,45 @@ class AtEditor:
self.title = title
self.command = command
self.mode = 2 # edit template
- self.output = output
+ self.output = output
self.cb_xoutput.set_active (output)
self.widget.set_title(_("Edit template"))
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.__setup_calendar__ ()
self.widget.show_all ()
-
+
# hide time settings
self.at_vbox_time.hide ()
-
+
# save and cancel buttons
self.button_save.set_label (gtk.STOCK_SAVE)
self.button_add_template.hide ()
-
+
self.__update_textboxes__()
-
+
def shownew_template (self, transient):
self.button_save.set_label (gtk.STOCK_ADD)
self.__reset__ ()
self.tid = 0
self.mode = 2 # edit template
- self.output = 0
+ self.output = 0
self.cb_xoutput.set_active (0)
self.widget.set_title(_("New template"))
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.__setup_calendar__ ()
self.widget.show_all ()
-
+
# hide time settings
self.at_vbox_time.hide ()
-
+
# save and cancel buttons
self.button_save.set_label (gtk.STOCK_ADD)
self.button_add_template.hide ()
-
+
self.__update_textboxes__()
-
+
def showedit (self, transient, record, job_id, iter):
self.button_save.set_label (gtk.STOCK_APPLY)
self.mode = 1 # edit task
@@ -213,8 +213,8 @@ class AtEditor:
while i == 0:
self.command = self.command[1:]
i = self.command.find ('\n', 0)
-
- #parse
+
+ #parse
(hour, minute, day, month, year) = self.__parse_time__(self.time, self.date)
self.runat = hour + minute + " " + day + "." + month + "." + year
self.spin_year.set_value (int (year))
@@ -224,7 +224,7 @@ class AtEditor:
self.spin_hour.set_value(int(hour))
self.spin_minute.set_value(int(minute))
self.widget.set_title(_("Edit a Scheduled Task"))
-
+
self.__update_textboxes__ ()
self.parentiter = iter
self.widget.set_transient_for(transient)
@@ -233,18 +233,18 @@ class AtEditor:
self.button_add_template.show ()
self.widget.show_all ()
-
+
def on_cal_lost_focus (self, *args):
self.__hide_calendar__ ()
-
+
def on_at_editor_size_changed (self, *args):
if self.cal_button.get_active ():
x, y = self.widget.get_position ()
height, width = self.widget.get_size ()
if ((x != self.x) or (y != self.y) or (height != self.height) or (width != self.width)):
self.__hide_calendar__ ()
-
+
def on_cb_xoutput_toggled (self, *args):
if self.cb_xoutput.get_active ():
self.output = 1
@@ -256,21 +256,21 @@ class AtEditor:
self.__show_calendar__ ()
else:
self.__hide_calendar__ ()
-
-
+
+
def __setup_calendar__ (self):
if self.cal_loaded == False:
self.xml.signal_connect ("on_cal_lost_focus", self.on_cal_lost_focus)
self.xml.signal_connect ("on_cal_window_destroy", self.__destroy_calendar__) # its actually not destroyed, but deleted
-
+
self.xml.signal_connect ("on_cal_day_selected_dc", self.on_cal_day_selected_dc)
self.xml.signal_connect ("on_cal_day_selected", self.on_cal_day_selected)
-
+
self.cal_window = self.xml.get_widget ("cal_window")
self.calendar = self.xml.get_widget ("calendar")
self.cal_window.hide_all ()
self.cal_loaded = True
-
+
def __destroy_calendar__ (self):
self.cal_window.hide_all ()
return True
@@ -281,10 +281,10 @@ class AtEditor:
self.spin_year.set_value (int (year))
self.spin_month.set_value (int (month) + 1)
self.spin_day.set_value (int (day))
-
+
def on_cal_day_selected_dc (self, *args):
self.__hide_calendar__ ()
-
+
def __show_calendar__ (self):
x, y = self.widget.window.get_origin ()
button_rect = self.cal_button.get_allocation ()
@@ -299,13 +299,13 @@ class AtEditor:
self.calendar.select_day (self.spin_day.get_value_as_int ())
self.cal_active = True
self.cal_window.show_all ()
-
+
def __hide_calendar__ (self):
self.cal_window.hide_all ()
self.cal_button.set_active (False)
self.widget.set_modal (True)
-
-
+
+
def on_worded_label_event (self, *args):
#TODO highlight on mouseover
pass
@@ -319,9 +319,9 @@ class AtEditor:
#TODO show at_script_menuons: install t
# don't forget to attach eventhandling to this popup
pass
-
-
+
+
def on_text_task_change (self, *args):
start = self.text_task_buffer.get_start_iter()
end = self.text_task_buffer.get_end_iter()
@@ -331,14 +331,14 @@ class AtEditor:
def on_entry_title_changed (self, *args):
self.title = self.entry_title.get_text()
- def on_spin_day_changed (self, *args):
- self.__check_spins__ ()
+ def on_spin_day_changed (self, *args):
+ self.__check_spins__ ()
self.__update_time_cal__()
def on_spin_month_changed (self, *args):
self.__check_spins__ ()
self.__update_time_cal__()
-
+
def on_spin_year_changed (self, *args):
self.__check_spins__ ()
self.__update_time_cal__()
@@ -355,30 +355,30 @@ class AtEditor:
# Is additionally run every minute
if self.check_spin_running != True:
self.check_spin_running = True
-
+
ctime = time.localtime()
year = ctime[0]
month = ctime[1]
day = ctime[2]
hour = ctime[3]
minute = ctime[4]
-
+
cyear = False
cmonth = False
cday = False
chour = False
-
+
syear = self.spin_year.get_value_as_int ()
if (syear == year):
cyear = True
-
+
smonth = self.spin_month.get_value_as_int ()
mi, ma = self.spin_month.get_range ()
if cyear:
if (mi != month):
self.spin_month.set_range (month, 12)
mi = month
- else:
+ else:
if ((mi != 1) or (ma != 12)):
self.spin_month.set_range (1, 12)
if (mi <= smonth <= ma):
@@ -391,8 +391,8 @@ class AtEditor:
smonth = self.spin_month.get_value_as_int ()
if (smonth == month):
cmonth = True
-
- sday = self.spin_day.get_value_as_int ()
+
+ sday = self.spin_day.get_value_as_int ()
mi, ma = self.spin_day.get_range ()
w, days = calendar.monthrange (syear, smonth)
if (cmonth and cyear):
@@ -412,7 +412,7 @@ class AtEditor:
sday = self.spin_day.get_value_as_int ()
if (sday == day):
cday = True
-
+
shour = self.spin_hour.get_value_as_int ()
mi, ma = self.spin_hour.get_range ()
if (cyear and cmonth and cday):
@@ -432,7 +432,7 @@ class AtEditor:
shour = self.spin_hour.get_value_as_int ()
if (shour == hour):
chour = True
-
+
sminute = self.spin_minute.get_value_as_int ()
mi, ma = self.spin_minute.get_range ()
if (cyear and cmonth and cday and chour):
@@ -448,10 +448,10 @@ class AtEditor:
if (sminute > ma):
self.spin_minute.set_value (ma)
else:
- self.spin_minute.set_value (mi)
+ self.spin_minute.set_value (mi)
self.check_spin_running = False
-
-
+
+
def __update_time_cal__ (self):
year = self.spin_year.get_text ()
month = self.spin_month.get_text ()
@@ -460,40 +460,40 @@ class AtEditor:
minute = self.spin_minute.get_text()
year = str(year)
-
+
if hour.isdigit():
hour = int(hour)
else:
return False
-
+
if minute.isdigit():
minute = int(minute)
else:
return False
-
+
if day.isdigit ():
day = int (day)
else:
return False
-
+
if month.isdigit ():
month = int (month)
else:
return False
-
+
if year.isdigit () == False:
return False
-
+
if hour < 10:
hour = "0" + str(hour)
else:
hour = str(hour)
-
+
if minute < 10:
minute = "0" + str(minute)
else:
minute = str(minute)
-
+
if month < 10:
month = "0" + str(month)
else:
@@ -527,7 +527,7 @@ class AtEditor:
minute = ctime[4]
self.output = 0
-
+
self.runat = str(hour) + str(minute) + " " + str(day) + "." + str(month) + "." + str (year)
self.spin_hour.set_value(int(hour))
@@ -537,7 +537,7 @@ class AtEditor:
self.spin_day.set_value (int (day))
self.__update_textboxes__ ()
-
+
def __update_textboxes__(self, update_runat = 1):
@@ -557,8 +557,8 @@ class AtEditor:
date_g = regexp_date.match(date)
if date_g:
- (day, month, year) = date_g.groups()
-
+ (day, month, year) = date_g.groups()
+
return hour, minute, day, month, year
@@ -566,7 +566,7 @@ class AtEditor:
self.__destroy_calendar__ ()
self.widget.hide()
return True
-
+
def __WrongRecordDialog__ (self, x):
self.wrongdialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, (_("This is an invalid record! The problem could be: %s") % (x)))
@@ -582,12 +582,12 @@ class AtEditor:
self.template.savetemplate_at (self.tid, self.title, self.command, self.output)
self.widget.hide ()
return
-
+
(validate, reason) = self.scheduler.checkfield(self.runat)
if validate == False:
self.__WrongRecordDialog__ (reason)
return
-
+
if (self.backend.get_not_inform_working_dir_at() != True):
dia2 = gtk.MessageDialog (self.widget, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, _("Note about working directory of executed tasks:\n\nOne-time tasks will be run from the directory where Gnome schedule is run from (normally the home directory)."))
dia2.add_buttons (_("_Don't show again"), gtk.RESPONSE_CLOSE, gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
@@ -603,13 +603,13 @@ class AtEditor:
pass
dia2.destroy ()
del dia2
-
+
if self.mode == 1:
self.scheduler.update (self.job_id, self.runat, self.command, self.title, self.output)
else:
self.scheduler.append (self.runat, self.command, self.title, self.output)
-
+
self.ParentClass.schedule_reload ()
-
+
self.widget.hide ()
-
+
diff --git a/src/crontabEditor.py b/src/crontabEditor.py
index a0b9183..18d5504 100644
--- a/src/crontabEditor.py
+++ b/src/crontabEditor.py
@@ -38,32 +38,32 @@ class CrontabEditor:
self.backend = backend
self.scheduler = scheduler
self.template = template
-
+
self.xml = self.ParentClass.xml
self.widget = self.xml.get_widget("crontab_editor")
self.widget.connect("delete-event", self.widget.hide_on_delete)
-
-
+
+
# TODO: move to crontab?
self.fieldRegex = re.compile('^(\*)$|^([0-9]+)$|^\*\/([0-9]+)$|^([0-9]+)-([0-9]+)$|(^([0-9]+[,])+([0-9]+)$)')
self.nooutputRegex = re.compile('([^#\n$]*)>(\s|)/dev/null\s2>&1')
-
-
+
+
self.title_box = self.xml.get_widget ("crontab_title_box")
-
+
self.image_icon = gtk.Image ()
self.image_icon.set_from_pixbuf (self.ParentClass.bigiconcrontab)
self.title_box.pack_start (self.image_icon, False, False, 0)
self.title_box.reorder_child (self.image_icon, 0)
self.image_icon.show ()
-
+
self.noevents = False
-
-
- ##simple tab
+
+
+ ##simple tab
self.entry_title = self.xml.get_widget ("entry_title")
self.entry_task = self.xml.get_widget ("entry_task")
-
+
self.frequency_combobox = self.xml.get_widget ("frequency_combobox")
self.frequency_combobox_model = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
self.frequency_combobox_model.append([_("Every minute"), ["*", "*", "*", "*", "*", ""]])
@@ -73,7 +73,7 @@ class CrontabEditor:
self.frequency_combobox_model.append([_("Every week"), ["0", "0", "*", "*", "1", ""]])
self.frequency_combobox_model.append([_("At reboot"), ["", "", "", "", "", "@reboot"]])
self.frequency_combobox.set_model (self.frequency_combobox_model)
-
+
self.cb_output = self.xml.get_widget ("combo_output")
self.cb_o_model = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_INT)
self.cb_o_model.append ([self.ParentClass.output_strings[0], 0])
@@ -90,9 +90,9 @@ class CrontabEditor:
self.button_template = self.xml.get_widget ("button_template")
self.rb_advanced = self.xml.get_widget ("rb_advanced")
self.rb_basic = self.xml.get_widget ("rb_basic")
-
+
self.label_preview = self.xml.get_widget ("label_preview")
-
+
self.xml.signal_connect("on_button_cancel_clicked", self.on_button_cancel_clicked)
self.xml.signal_connect("on_button_apply_clicked", self.on_button_apply_clicked)
self.xml.signal_connect("on_anyadvanced_entry_changed", self.on_anyadvanced_entry_changed)
@@ -101,29 +101,29 @@ class CrontabEditor:
self.xml.signal_connect ("on_combo_output_changed", self.on_anybasic_entry_changed)
self.xml.signal_connect("on_help_clicked", self.on_fieldHelp_clicked)
-
+
self.xml.signal_connect("on_rb_advanced_toggled", self.on_editmode_toggled)
self.xml.signal_connect("on_rb_basic_toggled", self.on_editmode_toggled)
-
+
self.xml.signal_connect ("on_button_template_clicked", self.on_template_clicked)
-
+
##advanced
self.minute_entry = self.xml.get_widget ("minute_entry")
self.hour_entry = self.xml.get_widget ("hour_entry")
self.day_entry = self.xml.get_widget ("day_entry")
self.month_entry = self.xml.get_widget ("month_entry")
self.weekday_entry = self.xml.get_widget ("weekday_entry")
-
+
self.help_minute = self.xml.get_widget ("help_minute")
self.help_hour = self.xml.get_widget ("help_hour")
self.help_day = self.xml.get_widget ("help_day")
self.help_month = self.xml.get_widget ("help_month")
self.help_weekday = self.xml.get_widget ("help_weekday")
-
+
self.editorhelper = crontabEditorHelper.CrontabEditorHelper(self)
-
-
-
+
+
+
def showadd (self, transient):
self.button_apply.set_label (gtk.STOCK_ADD)
self.__reset__ ()
@@ -144,8 +144,8 @@ class CrontabEditor:
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.button_template.show ()
self.widget.show ()
-
- self.output = output
+
+ self.output = output
# hehe again, why make it less complicated..
timeexpression = timeexpression + " echo hehe"
self.minute, self.hour, self.day, self.month, self.weekday, hehe = self.scheduler.parse (timeexpression, True)
@@ -159,7 +159,7 @@ class CrontabEditor:
self.weekday = ""
self.command = command
self.title = title
-
+
self.__update_textboxes__ ()
i = self.__getfrequency__ (self.minute, self.hour, self.day, self.month, self.weekday, self.special)
@@ -171,19 +171,19 @@ class CrontabEditor:
self.frequency_combobox.set_active (i)
self.cb_output.set_active (self.output)
-
-
+
+
def showedit_template (self, transient, id, title, command, output, timeexpression):
self.button_apply.set_label (gtk.STOCK_SAVE)
-
+
self.mode = 2
self.tid = id
self.__reset__ ()
-
+
self.command = command
self.title = title
self.output = output
-
+
timeexpression = timeexpression + " echo hehe"
self.minute, self.hour, self.day, self.month, self.weekday, hehe = self.scheduler.parse (timeexpression, True)
self.special = ""
@@ -194,10 +194,10 @@ class CrontabEditor:
self.hour = ""
self.month = ""
self.weekday = ""
-
- self.widget.set_title(_("Edit template"))
+
+ self.widget.set_title(_("Edit template"))
self.__update_textboxes__ ()
-
+
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show ()
@@ -214,21 +214,21 @@ class CrontabEditor:
def shownew_template (self, transient):
self.button_apply.set_label (gtk.STOCK_ADD)
-
+
self.mode = 2
self.tid = 0
self.__reset__ ()
-
- self.widget.set_title(_("New template"))
+
+ self.widget.set_title(_("New template"))
self.__update_textboxes__ ()
-
+
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show ()
self.button_template.hide ()
-
+
def showedit (self, transient, record, job_id, linenumber, iter):
self.button_apply.set_label (gtk.STOCK_APPLY)
self.mode = 1
@@ -245,8 +245,8 @@ class CrontabEditor:
self.hour = ""
self.month = ""
self.weekday = ""
-
- self.widget.set_title(_("Edit a Scheduled Task"))
+
+ self.widget.set_title(_("Edit a Scheduled Task"))
self.__update_textboxes__ ()
self.parentiter = iter
self.widget.set_transient_for(transient)
@@ -261,7 +261,7 @@ class CrontabEditor:
self.rb_basic.set_active (True)
self.frequency_combobox.set_active (i)
- self.cb_output.set_active (self.output)
+ self.cb_output.set_active (self.output)
def __reset__ (self):
self.noevents = True
@@ -284,7 +284,7 @@ class CrontabEditor:
self.day_entry.set_sensitive (False)
self.month_entry.set_editable (False)
self.month_entry.set_sensitive (False)
- self.weekday_entry.set_editable (False)
+ self.weekday_entry.set_editable (False)
self.weekday_entry.set_sensitive (False)
self.help_minute.set_sensitive (False)
self.help_hour.set_sensitive (False)
@@ -297,7 +297,7 @@ class CrontabEditor:
self.noevents = False
- #error dialog box
+ #error dialog box
def __WrongRecordDialog__ (self, x, y, z):
self.wrongdialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, (_("This is an invalid record! The problem could be in the %(field)s field. Reason: %(reason)s") % (y, z)))
self.wrongdialog.run()
@@ -307,7 +307,7 @@ class CrontabEditor:
self.wrongdialog2 = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, (_("Your command contains one or more of the character %, this is special for cron and cannot be used with Gnome-schedule because of the format it uses to store extra information on the crontab line. Please use the | redirector character to achieve the same functionality. Refer to the crontab manual for more information about the % character. If you don not want to use it for redirection it must be properly escaped with the \ letter.")))
self.wrongdialog2.run()
self.wrongdialog2.destroy()
-
+
def __check_field_format__ (self, field, type):
try:
# Type should not be translatable!
@@ -334,9 +334,9 @@ class CrontabEditor:
self.day = "*"
self.month = "*"
self.weekday = "*"
-
+
self.update_preview ()
-
+
self.rb_advanced.set_active (True)
self.minute_entry.set_editable (True)
self.minute_entry.set_sensitive (True)
@@ -365,7 +365,7 @@ class CrontabEditor:
self.day_entry.set_sensitive (False)
self.month_entry.set_editable (False)
self.month_entry.set_sensitive (False)
- self.weekday_entry.set_editable (False)
+ self.weekday_entry.set_editable (False)
self.weekday_entry.set_sensitive (False)
self.help_minute.set_sensitive (False)
self.help_hour.set_sensitive (False)
@@ -375,8 +375,8 @@ class CrontabEditor:
self.frequency_combobox.set_sensitive (True)
self.on_frequency_combobox_changed (self.frequency_combobox)
self.noevents = False
-
-
+
+
def on_button_cancel_clicked (self, *args):
self.widget.hide()
@@ -411,14 +411,14 @@ class CrontabEditor:
if self.scheduler.check_command (self.command) == False:
self.__dialog_command_failed__ ()
return False
-
+
if self.special != "":
self.template.savetemplate_crontab (0, self.title, self.command, self.output, self.special)
else:
self.template.savetemplate_crontab (0, self.title, self.command, self.output, self.minute + " " + self.hour + " " + self.day + " " + self.month + " " + self.weekday)
-
+
self.widget.hide ()
-
+
def on_button_apply_clicked (self, *args):
if self.special != "":
try:
@@ -450,8 +450,8 @@ class CrontabEditor:
if self.scheduler.check_command (self.command) == False:
self.__dialog_command_failed__ ()
return False
-
-
+
+
if (self.backend.get_not_inform_working_dir_crontab() != True):
dia2 = gtk.MessageDialog (self.widget, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, _("Note about working directory of executed tasks:\n\nRecurrent tasks will be run from the home directory."))
dia2.add_buttons (_("_Don't show again"), gtk.RESPONSE_CLOSE, gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
@@ -467,18 +467,18 @@ class CrontabEditor:
pass
dia2.destroy ()
del dia2
-
+
if self.mode == 1:
self.scheduler.update (self.minute, self.hour, self.day, self.month, self.weekday, self.command, self.linenumber, self.parentiter, self.output, self.job_id, self.comment, self.title, self.desc)
-
+
elif self.mode == 0:
self.scheduler.append (self.minute, self.hour, self.day, self.month, self.weekday, self.command, self.output, self.title)
-
+
elif self.mode == 2:
if self.special != "":
try:
self.__check_field_format__ (self.special, "special")
- record = self.special + " " + self.command
+ record = self.special + " " + self.command
self.minute = "@reboot"
self.hour = "@reboot"
self.day = "@reboot"
@@ -505,15 +505,15 @@ class CrontabEditor:
if self.scheduler.check_command (self.command) == False:
self.__dialog_command_failed__ ()
return False
-
+
if self.special != "":
self.template.savetemplate_crontab (self.tid, self.title, self.command, self.output, self.special)
else:
self.template.savetemplate_crontab (self.tid, self.title, self.command, self.output, self.minute + " " + self.hour + " " + self.day + " " + self.month + " " + self.weekday)
-
+
self.widget.hide ()
return
-
+
self.ParentClass.schedule_reload ()
self.widget.hide ()
@@ -526,10 +526,10 @@ class CrontabEditor:
else:
self.rb_advanced.set_active (True)
-
+
def __getfrequency__ (self, minute, hour, day, month, weekday, special):
index = -1
-
+
if minute == "*" and hour == "*" and month == "*" and day == "*" and weekday == "*":
index = 0
if minute == "0" and hour == "*" and month == "*" and day == "*" and weekday == "*":
@@ -542,11 +542,11 @@ class CrontabEditor:
index = 4
if special != "":
index = 5
-
+
return index
-
+
def __update_textboxes__ (self):
self.noevents = True
self.cb_output.set_active (self.output)
@@ -572,12 +572,12 @@ class CrontabEditor:
month = "@reboot"
weekday = "@reboot"
self.label_preview.set_text ("<b>" + self.scheduler.__easy__ (minute, hour, day, month, weekday) + "</b>")
-
+
except ValueError, ex:
x, y, z = ex
self.label_preview.set_text (_("This is an invalid record! The problem could be in the %(field)s field. Reason: %(reason)s") % ({'field' : y, 'reason' : z}))
-
-
+
+
else:
try:
# Type should not be translatable!
@@ -586,7 +586,7 @@ class CrontabEditor:
self.__check_field_format__ (self.day, "day")
self.__check_field_format__ (self.month, "month")
self.__check_field_format__ (self.weekday, "weekday")
-
+
# Day of Month
# Crontab bug? Let's not support
# dom behaves like minute
@@ -597,15 +597,15 @@ class CrontabEditor:
for day in self.scheduler.downumbers:
dom = dom.replace (day, self.scheduler.downumbers[day])
"""
-
+
# Month of Year
moy = self.month
if moy.isdigit () == False:
moy = moy.lower ()
for m in self.scheduler.monthnumbers:
moy = moy.replace (m, self.scheduler.monthnumbers[m])
-
-
+
+
# Day of Week
dow = self.weekday
if dow.isdigit() == False:
@@ -618,8 +618,8 @@ class CrontabEditor:
self.label_preview.set_text (_("This is an invalid record! The problem could be in the %(field)s field. Reason: %(reason)s") % ({'field' : y, 'reason' : z}))
self.label_preview.set_use_markup (True)
-
-
+
+
def on_anyadvanced_entry_changed (self, *args):
if self.noevents == False:
self.minute = self.minute_entry.get_text ()
@@ -628,7 +628,7 @@ class CrontabEditor:
self.month = self.month_entry.get_text ()
self.weekday = self.weekday_entry.get_text ()
self.output = self.cb_output.get_active()
-
+
self.__update_textboxes__ ()
@@ -646,8 +646,8 @@ class CrontabEditor:
if frequency != None:
self.minute, self.hour, self.day, self.month, self.weekday, self.special = frequency
self.__update_textboxes__()
-
-
+
+
def on_fieldHelp_clicked(self, widget, *args):
name = widget.get_name()
field = "minute"
@@ -668,4 +668,4 @@ class CrontabEditor:
expression = self.weekday_entry.get_text()
self.editorhelper.show (field, expression)
-
+
diff --git a/src/crontabEditorHelper.py b/src/crontabEditorHelper.py
index 0c217e9..f617ba3 100644
--- a/src/crontabEditorHelper.py
+++ b/src/crontabEditorHelper.py
@@ -26,15 +26,15 @@ import re
class CrontabEditorHelper:
def __init__(self, parent):
self.ParentClass = parent
-
+
self.xml = self.ParentClass.xml
-
+
self.NoExpressionEvents = False
self.fieldRegex = self.ParentClass.fieldRegex
-
+
self.widget = self.xml.get_widget("crontabEditorHelper")
self.widget.connect("delete-event", self.widget.hide_on_delete)
-
+
self.radAll = self.xml.get_widget("radAll")
self.radEvery = self.xml.get_widget("radEvery")
self.radRange = self.xml.get_widget("radRange")
@@ -46,7 +46,7 @@ class CrontabEditorHelper:
self.entFix = self.xml.get_widget("entFix")
self.entRangeStart = self.xml.get_widget("entRangeStart")
self.entRangeEnd = self.xml.get_widget("entRangeEnd")
-
+
self.header = self.xml.get_widget("label_crontab_editor_title")
self.lblEveryEntity = self.xml.get_widget("lblEveryEntity")
@@ -97,7 +97,7 @@ class CrontabEditorHelper:
self.entRangeStart.set_text ("1")
self.entFix.set_text("1")
self.radAll.set_label(_("Every day"))
-
+
if field == "month":
self.entRangeEnd.set_text ("12")
self.entRangeStart.set_text ("1")
@@ -115,9 +115,9 @@ class CrontabEditorHelper:
self.entExpression.set_text ("*")
self.trans_field = self.ParentClass.scheduler.translate_frequency (field)
-
-
-
+
+
+
self.do_label_magic ()
@@ -169,7 +169,7 @@ class CrontabEditorHelper:
self.widget.set_title(_("Edit month"))
elif field == "weekday":
self.widget.set_title(_("Edit weekday"))
-
+
self.widget.set_transient_for(self.ParentClass.widget)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show_all()
@@ -192,7 +192,7 @@ class CrontabEditorHelper:
if self.field == "day": self.ParentClass.day_entry.set_text(expression)
if self.field == "month": self.ParentClass.month_entry.set_text(expression)
if self.field == "weekday": self.ParentClass.weekday_entry.set_text(expression)
-
+
self.widget.hide()
@@ -249,7 +249,7 @@ class CrontabEditorHelper:
self.radFix.set_label (translated[0])
self.lblFixEntity.set_label (translated[1])
-
+
translated[0] = _("In a step width")
if self.field == "minute":
translated[1] = _("Minutes:")
@@ -261,10 +261,10 @@ class CrontabEditorHelper:
translated[1] = _("Months:")
elif self.field == "weekday":
translated[1] = _("Weekdays:")
-
+
self.radEvery.set_label (translated[0])
self.lblEveryEntity.set_label (translated[1])
-
+
def entExpressionChanged(self, *args):
if self.NoExpressionEvents == False:
diff --git a/src/data.py b/src/data.py
index de4fe2e..6862ab1 100644
--- a/src/data.py
+++ b/src/data.py
@@ -27,14 +27,14 @@ import os
import config
class ConfigBackend:
-
+
def __init__(self, parent, type):
-
+
self.parent = parent
self.type = "gconf"
-
+
self.gconf_client = gconf.client_get_default()
- self.gconf_client.add_dir ("/apps/gnome-schedule", gconf.CLIENT_PRELOAD_NONE)
+ self.gconf_client.add_dir ("/apps/gnome-schedule", gconf.CLIENT_PRELOAD_NONE)
self.gconf_client.notify_add ("/apps/gnome-schedule/advanced", self.on_gconfkey_advanced_changed)
def get_not_inform_working_dir (self):
@@ -42,41 +42,41 @@ class ConfigBackend:
return True
else:
return False
-
-
+
+
def set_not_inform_working_dir (self, value):
self.gconf_client.set_bool ("/apps/gnome-schedule/inform_working_dir", value)
-
+
def get_not_inform_working_dir_crontab (self):
return self.gconf_client.get_bool ("/apps/gnome-schedule/inform_working_dir_crontab")
-
+
def set_not_inform_working_dir_crontab (self, value):
self.gconf_client.set_bool ("/apps/gnome-schedule/inform_working_dir_crontab", value)
-
+
def get_not_inform_working_dir_at (self):
return self.gconf_client.get_bool ("/apps/gnome-schedule/inform_working_dir_at")
-
+
def set_not_inform_working_dir_at (self, value):
self.gconf_client.set_bool ("/apps/gnome-schedule/inform_working_dir_at", value)
-
-
+
+
def set_window_state (self, x, y, height, width):
self.gconf_client.set_int ("/apps/gnome-schedule/x", x)
self.gconf_client.set_int ("/apps/gnome-schedule/y", y)
self.gconf_client.set_int ("/apps/gnome-schedule/height", height)
self.gconf_client.set_int ("/apps/gnome-schedule/width", width)
-
+
def get_window_state (self):
h = self.gconf_client.get_int ("/apps/gnome-schedule/height")
w = self.gconf_client.get_int ("/apps/gnome-schedule/width")
x = self.gconf_client.get_int ("/apps/gnome-schedule/x")
y = self.gconf_client.get_int ("/apps/gnome-schedule/y")
return x, y, h, w
-
+
def get_advanced_option(self):
return self.gconf_client.get_bool ("/apps/gnome-schedule/advanced")
-
+
def set_advanced_option(self,value):
self.gconf_client.set_bool ("/apps/gnome-schedule/advanced", value)
diff --git a/src/gnome-schedule.py b/src/gnome-schedule.py
index 00532cc..7b9f47c 100644
--- a/src/gnome-schedule.py
+++ b/src/gnome-schedule.py
@@ -50,7 +50,7 @@ try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
-
+
except:
#Some distributions come with GTK2, but not pyGTK
pass
@@ -61,7 +61,7 @@ try:
# TODO: Gnome specific
import gnome
import gnome.ui
-
+
except:
print _("You need to install pyGTK or GTKv2,\n"
"or set your PYTHONPATH correctly.\n"
diff --git a/src/lang.py b/src/lang.py
index 0854a5f..0ea2c17 100644
--- a/src/lang.py
+++ b/src/lang.py
@@ -95,14 +95,14 @@ language = locale.getlocale()[0]
if language == None:
language = "C"
-# Some locale stuff in this section to get
-# translated time expressions out of system.
-# Don't touch this. Change settings through gettext (po files)
+# Some locale stuff in this section to get
+# translated time expressions out of system.
+# Don't touch this. Change settings through gettext (po files)
def lc_weekday (weekday):
weekday = int(weekday)
if weekday >= 0 and weekday < 7:
weekday = str(weekday)
- else:
+ else:
weekday = "0"
timevalue = time.strptime(weekday, "%w")
expression = time.strftime("%A", timevalue)
@@ -119,14 +119,14 @@ def lc_date (day,month,year = None):
month = "%02d" % int(month)
if year == None:
timevalue = time.strptime(("%s.%s" % (day, month)), "%d.%m")
- # Translators: Date format for expressions like 'January 21'. %B is month, %d is day number.
+ # Translators: Date format for expressions like 'January 21'. %B is month, %d is day number.
# Run the command 'man strftime' to read more about these and other available specifiers.
expression = time.strftime(_("%B %d"), timevalue)
else:
year = str(year)[-2:]
year = "%02d" % int(year)
timevalue = time.strptime(("%s.%s.%s" % (day, month, year)), "%d.%m.%y")
- # Translators: Date format for expressions like 'January 21, 2005'. %B is month, %d is day number, %Y is year with century.
+ # Translators: Date format for expressions like 'January 21, 2005'. %B is month, %d is day number, %Y is year with century.
# Run the command 'man strftime' to read more about these and other available specifiers.
expression = time.strftime(_("%B %d, %Y"), timevalue)
return unicode(expression, encoding, 'ignore')
@@ -136,7 +136,7 @@ def lc_time (hour,minute,second = None):
minute = "%02d" % int(minute)
if second == None:
timevalue = time.strptime(("%s:%s" % (hour, minute)), "%H:%M")
- # Translators: Time without seconds. %H is hour, %M is minute.
+ # Translators: Time without seconds. %H is hour, %M is minute.
# Run the command 'man strftime' to read more about these and other available specifiers.
expression = time.strftime(_("%H:%M"), timevalue)
else:
@@ -155,18 +155,18 @@ def translate_crontab_easy (minute, hour, day, month, weekday):
# Add support for your language here
# if language.find ("whatever") != -1:
# return translate_crontab_easy_whatever (minute, hour, day, month, weekday)
-# else:
+# else:
return translate_crontab_easy_common (minute, hour, day, month, weekday)
# Translate Crontab expressions to human readable ones.
# Don't touch this function. Copy and modify it to create a special translation.
-# Changes on this function affects all translations made through po files.
+# Changes on this function affects all translations made through po files.
def translate_crontab_easy_common (minute, hour, day, month, weekday):
# reboot
if minute == "@reboot":
return _("At reboot")
-
+
# These are unsupported cases
if minute.find ("/") != -1 or hour.find ("/") != -1 or day.find ("/") != -1 or month.find ("/") != -1 or weekday.find ("/") != -1:
return translate_crontab_easy_fallback (minute, hour, day, month, weekday)
@@ -174,7 +174,7 @@ def translate_crontab_easy_common (minute, hour, day, month, weekday):
return translate_crontab_easy_fallback (minute, hour, day, month, weekday)
if minute.find (",") != -1 or hour.find (",") != -1 or day.find (",") != -1 or month.find (",") != -1 or weekday.find (",") != -1:
return translate_crontab_easy_fallback (minute, hour, day, month, weekday)
-
+
# So if our case is supported:
# Minute and hour cases
diff --git a/src/mainWindow.py b/src/mainWindow.py
index 85394ff..e545f4f 100644
--- a/src/mainWindow.py
+++ b/src/mainWindow.py
@@ -57,36 +57,36 @@ class main:
self.inapplet = inapplet
self.gprogram = gprogram
self.manual_poscorrect = manual_poscorrect
-
+
self.__loadIcon__()
self.__loadGlade__()
-
+
self.editor = None
self.schedule = None
-
+
self.noevents = False
-
+
# Common string representation for the different output modes
self.output_strings = [
_("Default behaviour"),
- _("Suppress output"),
- _("X application"),
+ _("Suppress output"),
+ _("X application"),
_("X application: suppress output"),
]
#start the backend where all the user configuration is stored
self.backend = data.ConfigBackend(self, "gconf")
self.template = template.Template (self, self.backend)
-
-
+
+
##configure the window
self.widget = self.xml.get_widget("mainWindow")
self.widget.connect("delete_event", self.__quit__)
self.widget.connect("destroy_event", self.__quit__)
-
+
self.widget.set_icon(self.iconPixbuf)
-
+
#load state
(x, y, h, w) = self.backend.get_window_state ()
if (x and y):
@@ -96,19 +96,19 @@ class main:
self.widget.set_resizable (True)
- ##
+ ##
##configure statusbar
self.statusbar = self.xml.get_widget("statusbar")
-
+
self.statusbarUser = self.statusbar.get_context_id("user")
##
-
- ##configure the toolbar
+
+ ##configure the toolbar
self.toolbar = self.xml.get_widget ("toolbar")
self.add_button = gtk.MenuToolButton (gtk.STOCK_NEW)
-
+
self.add_button_menu = gtk.Menu ()
self.add_button_menu_add_crontab = gtk.MenuItem ()
self.add_button_menu_add_at = gtk.MenuItem ()
@@ -124,7 +124,7 @@ class main:
self.recurrenthbox.pack_start (icon, False, False, 2)
self.recurrenthbox.pack_start (label, True, True, 2)
self.add_button_menu_add_crontab.add (self.recurrenthbox)
-
+
self.onetimehbox = gtk.HBox ()
icon = gtk.Image ()
icon.set_from_pixbuf (self.iconat)
@@ -135,7 +135,7 @@ class main:
self.onetimehbox.pack_start (icon, False, False, 2)
self.onetimehbox.pack_start (label, True, True, 2)
self.add_button_menu_add_at.add (self.onetimehbox)
-
+
self.templatehbox = gtk.HBox ()
icon = gtk.Image ()
icon.set_from_pixbuf (self.icontemplate)
@@ -146,18 +146,18 @@ class main:
self.templatehbox.pack_start (icon, False, False, 2)
self.templatehbox.pack_start (label, True, True, 2)
self.add_button_menu_add_template.add (self.templatehbox)
-
+
self.add_button_menu.append (self.add_button_menu_add_crontab)
self.add_button_menu.append (self.add_button_menu_add_at)
self.add_button_menu.append (self.add_button_menu_add_template)
-
+
self.add_button.set_menu (self.add_button_menu)
self.toolbar.insert (self.add_button, 0)
self.add_button.set_is_important (True)
tip = gtk.Tooltips ()
tip.enable ()
-
+
self.add_button.set_tooltip (tip, _("Add a new task"), tip_private=None)
self.add_button.show_all ()
self.add_button_menu.show_all ()
@@ -169,7 +169,7 @@ class main:
self.add_button_menu_add_at.connect ("activate", self.on_add_at_task)
self.add_button_menu_add_template.connect ("activate", self.on_add_from_template)
-
+
self.prop_button = self.xml.get_widget ("prop_button")
self.del_button = self.xml.get_widget ("del_button")
self.run_button = self.xml.get_widget ("run_button")
@@ -198,26 +198,26 @@ class main:
self.xml.signal_connect("on_btnExit_clicked", self.__quit__)
self.xml.signal_connect("on_mainWindow_delete_event", self.__quit__)
self.xml.signal_connect("on_run_button_clicked", self.on_run_button_clicked)
-
+
self.xml.signal_connect ("on_button_m_template_clicked", self.on_template_manager_button)
-
+
##inittializing the treeview and treemodel
## somethins not rite here..:
## [0 Title, 1 Frequency, 2 Command, 3 Crontab record, 4 ID, 5 Time, 6 Icon, 7 scheduled instance, 8 icon path, 9 date, 10 class_id, 11 user, 12 time, 13 type, 14 crontab/at, 15 advanced time string]
- ##for at this would be like:
-
+ ##for at this would be like:
+
# ["untitled", "12:50 2004-06-25", "preview", "script", "job_id", "12:50", icon, at instance, icon_path, "2004-06-25", "a", "drzap", "at"]
- ##for crontab it would be:
-
+ ##for crontab it would be:
+
# ["untitled", "every hour", "ls /", "0 * * * * ls / # untitled", "5", "0 * * * *", icon, crontab instance,icon_path, 1(job_id), "", "", "crontab"]
self.treemodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING , gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING)
-
+
self.treeview = self.xml.get_widget("treeview")
-
+
self.xml.signal_connect("on_treeview_button_press_event", self.on_treeview_button_press_event)
self.xml.signal_connect("on_treeview_key_press_event", self.on_treeview_key_pressed)
-
+
self.treeview.set_model (self.treemodel)
self.treeview.get_selection().connect("changed", self.on_TreeViewSelectRow)
@@ -230,26 +230,26 @@ class main:
self.switchView("simple")
self.edit_mode_button.set_active (False)
self.noevents = False
-
-
+
+
self.__initUser__()
-
+
##create crontab
self.crontab = crontab.Crontab(self.root, self.user, self.uid, self.gid, self.user_home_dir)
self.crontab_editor = crontabEditor.CrontabEditor(self, self.backend, self.crontab, self.template)
##
-
+
##create at
self.at = at.At(self.root, self.user, self.uid, self.gid, self.user_home_dir, self.manual_poscorrect)
self.at_editor = atEditor.AtEditor (self, self.backend, self.at, self.template)
##
-
+
#set user window
self.setuserWindow = setuserWindow.SetuserWindow (self)
-
+
#set add window
self.addWindow = addWindow.AddWindow (self)
-
+
# template windows
self.template_chooser = template_chooser.TemplateChooser (self, self.template)
self.template_manager = template_manager.TemplateManager (self, self.template)
@@ -260,11 +260,11 @@ class main:
# temporary files to be deleted
self.temp_files = []
-
+
if inapplet == False:
gtk.main()
-
-
+
+
def update_schedule(self):
selection = self.treeview.get_selection()
model, iter, = selection.get_selected()
@@ -272,7 +272,7 @@ class main:
path = model.get_path(iter)
self.schedule_reload ()
if iter:
- selection.select_path(path)
+ selection.select_path(path)
return True
def changeUser(self,user):
@@ -284,10 +284,10 @@ class main:
#adjust statusbar
if self.root == 1:
self.statusbar.push(self.statusbarUser, (_("Editing user: %s") % (self.user)))
-
+
self.schedule_reload ()
-
-
+
+
def __setUser__(self,user):
userdb = pwd.getpwnam(user)
self.user = user
@@ -295,8 +295,8 @@ class main:
self.gid = userdb[3]
self.user_home_dir = userdb[5]
self.user_shell = userdb[6]
-
-
+
+
## TODO: 2 times a loop looks to mutch
def schedule_reload (self):
self.treemodel.clear ()
@@ -304,24 +304,24 @@ class main:
data = self.crontab.read ()
if data != None:
self.__fill__ (data)
-
+
data = self.at.read ()
if data != None:
self.__fill__ (data)
-
+
def __fill__ (self, records):
for title, timestring_show, preview, lines, job_id, timestring, scheduler, icon, date, class_id, user, time, typetext, type, output, timestring_advanced in records:
-
+
if scheduler.get_type() == "crontab":
iter = self.treemodel.append([title, timestring_show, preview, lines, job_id, timestring, self.iconcrontab, scheduler, icon, date, class_id, user, time, typetext, type, output, timestring_advanced])
elif scheduler.get_type() == "at":
iter = self.treemodel.append([title, timestring_show, preview, lines, job_id, timestring, self.iconat, scheduler, icon, date, class_id, user, time, typetext, type, output, timestring_advanced])
-
-
+
+
def __loadIcon__(self):
if self.debug_flag:
if os.access("../icons/gnome-schedule.svg", os.F_OK):
@@ -341,9 +341,9 @@ class main:
self.iconcrontab = gtk.gdk.pixbuf_new_from_file_at_size (config.getImagedir() + "/crontab.svg", 19, 19)
self.bigiconcrontab = gtk.gdk.pixbuf_new_from_file_at_size (config.getImagedir() + "/crontab.svg", 49, 49)
except:
- print _("ERROR: Could not load icon")
-
- if self.debug_flag:
+ print _("ERROR: Could not load icon")
+
+ if self.debug_flag:
if os.access ("../icons/calendar.svg", os.F_OK):
self.iconcalendar = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/calendar.svg", 19, 19)
self.bigiconcalendar = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/calendar.svg", 49, 49)
@@ -353,8 +353,8 @@ class main:
self.bigiconcalendar = gtk.gdk.pixbuf_new_from_file_at_size (config.getImagedir() + "/calendar.svg", 49, 49)
except:
print _("ERROR: Could not load icon")
-
- if self.debug_flag:
+
+ if self.debug_flag:
if os.access ("../icons/template.svg", os.F_OK):
self.icontemplate = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/template.svg", 19, 19)
self.normalicontemplate = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/template.svg", 25, 25)
@@ -368,8 +368,8 @@ class main:
self.pathicontemplate = config.getImagedir() + "/template.svg"
except:
print _("ERROR: Could not load icon")
-
- if self.debug_flag:
+
+ if self.debug_flag:
if os.access ("../icons/at.svg", os.F_OK):
self.iconat = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/at.svg", 19, 19)
self.bigiconat = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/at.svg", 49, 49)
@@ -379,8 +379,8 @@ class main:
self.bigiconat = gtk.gdk.pixbuf_new_from_file_at_size (config.getImagedir() + "/at.svg", 49, 49)
except:
print _("ERROR: Could not load icon")
-
-
+
+
def __loadGlade__(self):
if self.debug_flag:
if os.access("gnome-schedule.glade", os.F_OK):
@@ -396,25 +396,25 @@ class main:
print _("ERROR: Could not load glade file")
quit ()
-
-
+
+
def __initUser__(self):
- self.uid = os.geteuid()
+ self.uid = os.geteuid()
self.gid = os.getegid()
self.user = pwd.getpwuid(self.uid)[0]
self.user_home_dir = pwd.getpwuid(self.uid)[5]
self.user_shell = pwd.getpwuid(self.uid)[6]
-
+
if self.uid != 0:
self.btnSetUser.hide()
- self.statusbar.hide()
+ self.statusbar.hide()
self.root = 0
else:
self.root = 1
self.btnSetUser.show()
self.statusbar.show()
self.statusbar.push(self.statusbarUser, (_("Editing user: %s") % (self.user)))
-
+
#when the user selects a task, buttons get enabled
def on_TreeViewSelectRow (self, *args):
@@ -422,13 +422,13 @@ class main:
value = True
else:
value = False
-
+
self.prop_button.set_sensitive (value)
self.del_button.set_sensitive (value)
self.run_button.set_sensitive (value)
-
-
+
+
#clean existing columns
def __cleancolumns__ (self):
columns = len(self.treeview.get_columns()) -1
@@ -436,18 +436,18 @@ class main:
temp = self.treeview.get_column(columns)
self.treeview.remove_column(temp)
columns = columns - 1
-
-
- #switch between advanced and simple mode
+
+
+ #switch between advanced and simple mode
def switchView(self, mode = "simple"):
self.__cleancolumns__ ()
-
+
self.treeview.get_selection().unselect_all()
self.edit_mode = mode
-
+
cell = gtk.CellRendererPixbuf()
cell.set_fixed_size(21,21)
- cell2 = gtk.CellRendererText ()
+ cell2 = gtk.CellRendererText ()
col = gtk.TreeViewColumn (_("Task"), None)
col.pack_start (cell, True)
col.pack_end (cell2, True)
@@ -456,11 +456,11 @@ class main:
col.add_attribute (cell2, "text", 13)
else:
col.add_attribute (cell2, "text", 14)
-
+
self.treeview.append_column(col)
-
+
if mode == "simple":
-
+
col = gtk.TreeViewColumn(_("Description"), gtk.CellRendererText(), text=0)
col.set_resizable (True)
self.treeview.append_column(col)
@@ -477,7 +477,7 @@ class main:
elif mode == "advanced":
-
+
col = gtk.TreeViewColumn(_("Date and Time"), gtk.CellRendererText(), text=16)
col.set_resizable (True)
self.treeview.append_column(col)
@@ -503,34 +503,34 @@ class main:
def on_add_at_task (self, *args):
self.addWindow.mode = 0
self.addWindow.on_button_at_clicked (*args)
-
+
def on_add_crontab_task (self, *args):
self.addWindow.mode = 0
self.addWindow.on_button_crontab_clicked (*args)
-
+
def on_add_from_template (self, *args):
self.addWindow.mode = 0
self.addWindow.on_button_template_clicked (*args)
def on_template_manager_button (self, *args):
self.template_manager.show (self.widget)
-
+
def on_add_scheduled_task_menu_activate (self, *args):
self.addWindow.ShowAddWindow (self.widget)
def on_properties_menu_activate (self, *args):
store, iter = self.treeview.get_selection().get_selected()
-
+
try:
#see what scheduler (at, crontab or ...)
self.schedule = self.treemodel.get_value(iter, 7)
-
-
-
+
+
+
record = self.treemodel.get_value(iter, 3)
linenumber = self.treemodel.get_value(iter, 4)
-
- # TODO: dirty hacky
+
+ # TODO: dirty hacky
if self.schedule.get_type() == "crontab":
self.editor = self.crontab_editor
job_id = self.treemodel.get_value (iter, 9)
@@ -543,8 +543,8 @@ class main:
print ex
self.dialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Please select a task"))
self.dialog.run ()
- self.dialog.destroy ()
-
+ self.dialog.destroy ()
+
# TODO: looks not that clean (is broken)
def on_delete_menu_activate (self, *args):
@@ -555,14 +555,14 @@ class main:
return
dialog.destroy()
del dialog
-
+
store, iter = self.treeview.get_selection().get_selected()
-
+
try:
#see what scheduler (at, crontab or ...)
self.schedule = self.treemodel.get_value(iter, 7)
-
- # TODO: dirty hacky
+
+ # TODO: dirty hacky
if self.schedule.get_type() == "crontab":
self.editor = self.crontab_editor
elif self.schedule.get_type() == "at":
@@ -574,14 +574,14 @@ class main:
path = self.treemodel.get_path(iter)
pathint = path[0]
backpath = (pathint - 1,)
-
+
if self.schedule.get_type() == "crontab":
self.schedule.delete (linenumber, iter, self.treemodel.get_value(iter, 9))
elif self.schedule.get_type() == "at":
self.schedule.delete (linenumber, iter)
-
+
self.schedule_reload()
-
+
firstiter = self.treemodel.get_iter_first()
try:
nextiter = self.treemodel.get_iter(path)
@@ -601,7 +601,7 @@ class main:
#go first
selection = self.treeview.get_selection()
selection.select_iter(firstiter)
-
+
except Exception, ex:
#print ex
self.dialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Please select a task"))
@@ -614,7 +614,7 @@ class main:
def on_btnSetUser_clicked(self, *args):
self.on_set_user_menu_activate(self, args)
-
+
def on_add_button_clicked (self, *args):
self.on_add_scheduled_task_menu_activate (self, args)
@@ -637,7 +637,7 @@ class main:
if (key == "Return" or key == "KP_Return"):
self.on_properties_menu_activate(self, widget)
-
+
#double click on task to get properties
def on_treeview_button_press_event (self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
@@ -647,9 +647,9 @@ class main:
#about box
def open_url (self, *args):
url_show("http://gnome-schedule.sourceforge.net")
-
-
+
+
def on_run_button_clicked (self, *args):
dialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, _("Are you sure you want to run this task now?\n\nThis is used to preview the task and initiates a one-time run, this does not affect the normal scheduled run times."))
dialog.add_buttons (gtk.STOCK_EXECUTE, gtk.RESPONSE_YES, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
@@ -660,7 +660,7 @@ class main:
return
dialog.destroy()
del dialog
-
+
if (self.backend.get_not_inform_working_dir() != True):
dia2 = gtk.MessageDialog (self.widget, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, _("Note about working directory of executed tasks:\n\nRecurrent tasks will be run from the home directory, one-time tasks from the directory where Gnome schedule was run from at the time of task creation (normally the home directory)."))
dia2.add_buttons (_("_Don't show again"), gtk.RESPONSE_CLOSE, gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
@@ -676,56 +676,56 @@ class main:
pass
dia2.destroy ()
del dia2
-
+
store, iter = self.treeview.get_selection().get_selected()
-
+
try:
# commands are at model[3]
-
- #see what scheduler (at, crontab or ...)
+
+ #see what scheduler (at, crontab or ...)
self.schedule = self.treemodel.get_value(iter, 7)
-
+
tmpfile = tempfile.mkstemp ()
fd, path = tmpfile
tmp = os.fdopen (fd, 'w')
-
+
commands = self.treemodel.get_value(iter, 3)
linenumber = self.treemodel.get_value(iter, 4)
-
-
+
+
if self.schedule.get_type () == "at":
script = os.popen (config.getAtbin () + " -c " + str (linenumber)).read ()
elif self.schedule.get_type () == "crontab":
script = self.schedule.parse (commands)[1][5]
-
+
# left untranslated to protect against any 'translation attacks'..
script = script + "\necho " + "Press ENTER to continue and close this window." + "\n"
script = script + "read\nexit\n"
tmp.write (script)
tmp.flush ()
self.temp_files.append ((tmp, path))
-
-
+
+
execute = self.user_shell + " " + path
-
+
if self.root == 1:
if self.user != "root":
execute = "su " + self.user + " -c \"" + self.user_shell + " " + path
os.chown (path, self.uid, self.gid)
os.chmod (path, stat.S_IEXEC | stat.S_IREAD)
-
-
+
+
gnome.execute_terminal_shell (self.user_home_dir, execute)
-
-
+
+
except Exception, ex:
print ex
self.dialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Please select a task!"))
self.dialog.run ()
self.dialog.destroy ()
-
+
def on_about_menu_activate (self, *args):
-
+
gtk.about_dialog_set_url_hook(self.open_url, "bogusbar")
dlg = gtk.AboutDialog ()
dlg.set_title (_("About Gnome Schedule"))
@@ -746,19 +746,19 @@ class main:
)
dlg.set_translator_credits (_("translator-credits"))
dlg.set_logo (self.iconPixbuf)
-
+
if (dlg.run() != gtk.RESPONSE_YES):
dlg.destroy()
del dlg
return
dlg.destroy()
del dlg
-
+
#open help
def on_manual_menu_activate (self, *args):
try:
gnome.help_display (
- 'gnome-schedule',
+ 'gnome-schedule',
None)
except gobject.GError, error:
dialog = gtk.MessageDialog (
@@ -777,7 +777,7 @@ class main:
f, p = t
f.close ()
os.remove (p)
-
+
# save state
x,y = self.widget.get_position ()
h, w = self.widget.get_size ()
@@ -787,4 +787,4 @@ class main:
else:
gtk.main_quit ()
return True
-
+
diff --git a/src/scheduleapplet.py b/src/scheduleapplet.py
index 00a0347..cc0d55f 100755
--- a/src/scheduleapplet.py
+++ b/src/scheduleapplet.py
@@ -49,7 +49,7 @@ try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
-
+
except:
#Some distributions come with GTK2, but not pyGTK
pass
@@ -62,7 +62,7 @@ try:
import gnome.ui
import gnomeapplet
import gobject
-
+
except:
print _("You need to install pyGTK or GTKv2,\n"
"or set your PYTHONPATH correctly.\n"
@@ -79,38 +79,38 @@ class ScheduleApplet(gnomeapplet.Applet):
self.__gobject_init__()
self.debug_flag = debug_flag
self.manual_poscorrect = manual_poscorrect
-
+
gettext.bindtextdomain(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR())
gettext.textdomain(config.GETTEXT_PACKAGE())
locale.bindtextdomain(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR())
locale.textdomain(config.GETTEXT_PACKAGE())
-
-
+
+
self.applet = applet
self.gprogram = gprogram
self.__loadIcon__()
-
+
self.ev_box = gtk.EventBox()
-
+
self.image = gtk.Image()
self.image.set_from_pixbuf(self.iconPixbuf)
-
+
self.main_loaded = False
-
+
self.ev_box.add(self.image)
self.ev_box.show()
self.ev_box.set_events(gtk.gdk.BUTTON_PRESS_MASK)
self.ev_box.connect("button_press_event", self.event_box_clicked)
self.applet.add(self.ev_box)
-
+
self.create_menu()
self.applet.show_all()
-
-
+
+
def __loadIcon__(self):
if self.debug_flag:
if os.access("../icons/gnome-schedule.svg", os.F_OK):
@@ -122,12 +122,12 @@ class ScheduleApplet(gnomeapplet.Applet):
print _("ERROR: Could not load icon")
def create_menu(self):
- self.verbs = [ ("show_main", self.show_main_window),
+ self.verbs = [ ("show_main", self.show_main_window),
("add", self.add_task),
("help", self.show_help),
("about", self.show_about)
]
-
+
#check for file in current dir
if self.debug_flag:
if os.access ("gnome-schedule-applet.xml", os.F_OK):
@@ -139,14 +139,14 @@ class ScheduleApplet(gnomeapplet.Applet):
print _("ERROR: Could not load menu xml file")
datadir = ''
quit ()
-
+
self.applet.setup_menu_from_file(datadir, "gnome-schedule-applet.xml", "gnome-schedule", self.verbs)
-
+
def event_box_clicked (self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.show_main_window()
-
+
def show_main_window(self, *args):
if self.main_loaded == False:
self.main_loaded = True
@@ -154,7 +154,7 @@ class ScheduleApplet(gnomeapplet.Applet):
else:
self.main_window.widget.show ()
self.main_window.schedule_reload()
-
+
def add_task(self, *args):
if self.main_loaded == False:
@@ -162,7 +162,7 @@ class ScheduleApplet(gnomeapplet.Applet):
self.main_window.widget.hide()
self.main_window.on_add_scheduled_task_menu_activate()
-
+
def show_help(self, *args):
if self.main_loaded == False:
self.show_main_window()
@@ -181,7 +181,7 @@ gobject.type_register(ScheduleApplet)
def schedule_applet_factory(applet, iid):
ScheduleApplet(applet, iid, pr, debug_flag, manual_poscorrect)
return True
-
+
gnomeapplet.bonobo_factory("OAFIID:GNOME_GnomeSchedule_Factory",
- ScheduleApplet.__gtype__,
+ ScheduleApplet.__gtype__,
"GnomeScheduleApplet", "0", schedule_applet_factory)
diff --git a/src/setuserWindow.py b/src/setuserWindow.py
index b18486e..4da8d9b 100644
--- a/src/setuserWindow.py
+++ b/src/setuserWindow.py
@@ -34,11 +34,11 @@ class SetuserWindow:
##comboxEntry
self.entUser = self.xml.get_widget("entUser")
-
+
liststore = gtk.ListStore(gobject.TYPE_STRING)
self.entUser.set_model(liststore)
self.entUser.set_text_column(0)
-
+
#entryCompletion
# TODO: make it only possible for the user to type something that is in the list
self.entry = self.entUser.child
@@ -47,20 +47,20 @@ class SetuserWindow:
self.entry.set_completion(completion)
completion.set_model(liststore)
completion.set_text_column(0)
-
+
#fill combox with all the users
pwd_info = pwd.getpwall()
-
+
for info in pwd_info:
self.entUser.append_text(info[0])
##
-
+
self.cancel_button = self.xml.get_widget ("setuser_cancel_button")
self.ok_button = self.xml.get_widget ("setuser_ok_button")
self.xml.signal_connect("on_setuser_cancel_button_clicked", self.on_cancel_button_clicked)
self.xml.signal_connect("on_setuser_ok_button_clicked", self.on_ok_button_clicked)
-
-
+
+
#public function
def ShowSetuserWindow (self):
self.widget.set_transient_for(self.ParentClass.widget)
@@ -73,15 +73,15 @@ class SetuserWindow:
def on_ok_button_clicked (self, *args):
-
+
user = self.entry.get_text()
try:
- self.ParentClass.changeUser(user)
+ self.ParentClass.changeUser(user)
self.widget.hide()
-
+
except Exception, ex:
print ex
self.dialog = gtk.MessageDialog(self.widget, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("No such user"))
self.dialog.run ()
self.dialog.destroy ()
-
+
diff --git a/src/template.py b/src/template.py
index 959ce03..1b1b83a 100644
--- a/src/template.py
+++ b/src/template.py
@@ -29,7 +29,7 @@ class Template:
self.parent = parent
self.configbackend = configbackend
self.gconf_client = self.configbackend.gconf_client
-
+
def removetemplate_at (self, template_id):
installed = self.gconf_client.get_string("/apps/gnome-schedule/templates/at/installed")
@@ -45,17 +45,17 @@ class Template:
first = False
else:
newstring = newstring + ", " + t
-
+
self.gconf_client.unset("/apps/gnome-schedule/templates/at/%s/title" % (str (template_id)))
self.gconf_client.unset("/apps/gnome-schedule/templates/at/%s/command" % (str (template_id)))
self.gconf_client.unset ("/apps/gnome-schedule/templates/at/%s/output" % (str (template_id)))
-
+
if newstring == " ":
self.gconf_client.unset ("/apps/gnome-schedule/templates/at/installed")
else:
self.gconf_client.set_string("/apps/gnome-schedule/templates/at/installed", newstring)
-
- def removetemplate_crontab (self, template_id):
+
+ def removetemplate_crontab (self, template_id):
installed = self.gconf_client.get_string("/apps/gnome-schedule/templates/crontab/installed")
newstring = installed
if installed != None:
@@ -69,18 +69,18 @@ class Template:
first = False
else:
newstring = newstring + ", " + t
-
+
self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/title" % (str (template_id)))
self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/command" % (str (template_id)))
self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/timeexpression" % (str (template_id)))
self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/output" % (str (template_id)))
-
+
if newstring == " ":
self.gconf_client.unset ("/apps/gnome-schedule/templates/crontab/installed")
else:
self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/installed", newstring)
-
-
+
+
def create_new_id_crontab (self):
i = self.gconf_client.get_int ("/apps/gnome-schedule/templates/crontab/last_id")
if i == None:
@@ -90,17 +90,17 @@ class Template:
i = i + 1
self.gconf_client.set_int ("/apps/gnome-schedule/templates/crontab/last_id", i)
return i
-
- def savetemplate_crontab (self, template_id, title, command, output, timeexpression):
+
+ def savetemplate_crontab (self, template_id, title, command, output, timeexpression):
if (template_id == 0):
template_id = self.create_new_id_crontab ()
-
+
self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/timeexpression" % (str (template_id)), timeexpression)
self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/title" % (str (template_id)), title)
self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/command" % (str (template_id)), command)
self.gconf_client.set_int("/apps/gnome-schedule/templates/crontab/%s/output" % (str (template_id)), output)
-
+
installed = self.gconf_client.get_string("/apps/gnome-schedule/templates/crontab/installed")
if installed == None:
installed = str(template_id)
@@ -110,16 +110,16 @@ class Template:
for t in installed.split (", "):
if t == str (template_id):
found = True
-
+
if found == False:
installed = installed + ", " + str (template_id)
-
+
self.gconf_client.unset ("/apps/gnome-schedule/templates/crontab/installed")
self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/installed", installed)
self.parent.template_manager.reload_tv ()
self.parent.template_chooser.reload_tv ()
-
-
+
+
def gettemplateids (self, type):
strlist = self.gconf_client.get_string("/apps/gnome-schedule/templates/" + type + "/installed")
if strlist != None:
@@ -138,17 +138,17 @@ class Template:
output = self.gconf_client.get_int("/apps/gnome-schedule/templates/" + type + "/%s/output" % (str (template_id)))
timeexpression = self.gconf_client.get_string("/apps/gnome-schedule/templates/" + type + "/%s/timeexpression" % (template_id))
return template_id, title, command, output, timeexpression
-
+
except Exception, ex:
return False
-
+
elif type == "at":
try:
command = self.gconf_client.get_string("/apps/gnome-schedule/templates/at/%s/command" % (str (template_id)))
title = self.gconf_client.get_string("/apps/gnome-schedule/templates/at/%s/title" % (str (template_id)))
output = self.gconf_client.get_int ("/apps/gnome-schedule/templates/at/%s/output" % (str (template_id)))
return template_id, title, command, output
-
+
except Exception, ex:
return False
@@ -160,7 +160,7 @@ class Template:
else:
i = i + 1
self.gconf_client.set_int ("/apps/gnome-schedule/templates/at/last_id", i)
- return i
+ return i
def savetemplate_at (self, template_id, title, command, output):
print "savetemplate"
@@ -168,12 +168,12 @@ class Template:
if (template_id == 0):
template_id = self.create_new_id_at ()
print "got new id"
-
+
self.gconf_client.set_string("/apps/gnome-schedule/templates/at/%s/title" % (str (template_id)), title)
self.gconf_client.set_string("/apps/gnome-schedule/templates/at/%s/command" % (str (template_id)), command)
self.gconf_client.set_int ("/apps/gnome-schedule/templates/at/%s/output" % ( str(template_id)), output)
-
+
installed = self.gconf_client.get_string("/apps/gnome-schedule/templates/at/installed")
if installed == None:
installed = str(template_id)
@@ -183,15 +183,15 @@ class Template:
for t in installed.split (", "):
if t == str (template_id):
found = True
-
+
if found == False:
installed = installed + ", " + str (template_id)
-
+
self.gconf_client.unset ("/apps/gnome-schedule/templates/at/installed")
self.gconf_client.set_string("/apps/gnome-schedule/templates/at/installed", installed)
self.parent.template_manager.reload_tv ()
self.parent.template_chooser.reload_tv ()
-
+
# TODO: output
def format_at (self, title, command, output):
command = self.parent.at.__make_preview__ (command, 0)
@@ -200,7 +200,7 @@ class Template:
s = (s + " <i>(%s)</i>") % (str (self.parent.output_strings [2]))
return s
-
+
def format_crontab (self, title, command, output, timeexpression):
command = self.parent.crontab.__make_preview__ (command)
if self.parent.edit_mode == "simple":
@@ -213,5 +213,5 @@ class Template:
if output > 0:
s = (s + " <i>(%s)</i>") % (str (self.parent.output_strings[output]))
-
+
return s
diff --git a/src/template_chooser.py b/src/template_chooser.py
index 535907f..4c3d5ef 100644
--- a/src/template_chooser.py
+++ b/src/template_chooser.py
@@ -30,8 +30,8 @@ class TemplateChooser:
self.xml = self.parent.xml
self.widget = self.xml.get_widget ("template_chooser")
self.widget.connect("delete-event", self.widget.hide_on_delete)
-
-
+
+
self.treeview = self.xml.get_widget ("tc_treeview")
self.button_use = self.xml.get_widget ("tc_button_use")
hbox = gtk.HBox ()
@@ -45,38 +45,38 @@ class TemplateChooser:
hbox.pack_start (label, True, True, 0)
self.button_use.add (hbox)
self.button_use.show_all ()
-
+
self.button_cancel = self.xml.get_widget ("tc_button_cancel")
-
+
self.xml.signal_connect ("on_tc_button_use_clicked", self.on_use_clicked)
self.xml.signal_connect ("on_tc_button_cancel_clicked", self.on_cancel_clicked)
self.xml.signal_connect ("on_tc_treeview_button_press_event", self.on_tv_pressed)
-
+
self.treeview.get_selection().connect("changed", self.on_tv_changed)
-
+
# setup liststore
# [template id, type, type-string, formatted text, icon/pixbuf]
self.treemodel = gtk.ListStore (gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.gdk.Pixbuf)
-
+
# setup treeview
self.treeview.set_model (self.treemodel)
self.treeview.set_headers_visible (True)
-
-
+
+
rend1 = gtk.CellRendererPixbuf ()
rend2 = gtk.CellRendererText ()
-
+
column = gtk.TreeViewColumn(_("Task"))
column.pack_start (rend1, True)
column.pack_end (rend2, True)
column.add_attribute (rend1, "pixbuf", 4)
column.add_attribute (rend2, "text", 2)
self.treeview.append_column(column)
-
-
+
+
rend = gtk.CellRendererText ()
column = gtk.TreeViewColumn(_("Description"), rend, markup=3)
- self.treeview.append_column(column)
+ self.treeview.append_column(column)
def on_tv_changed (self, *args):
if self.treeview.get_selection().count_selected_rows() > 0 :
@@ -84,7 +84,7 @@ class TemplateChooser:
else:
value = False
self.button_use.set_sensitive (value)
-
+
def reload_tv (self):
self.treemodel.clear ()
at = self.template.gettemplateids ("at")
@@ -104,8 +104,8 @@ class TemplateChooser:
id2, title, command, output, timeexpression = t
formatted = self.template.format_crontab (title, command, output, timeexpression)
iter = self.treemodel.append ([int (id), "crontab", _("Recurrent"), formatted, self.parent.bigiconcrontab])
-
-
+
+
def show (self, transient):
# populate treeview
self.reload_tv ()
@@ -113,18 +113,18 @@ class TemplateChooser:
self.widget.set_transient_for (transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show_all ()
-
+
def on_tv_pressed (self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.on_use_clicked(self, widget)
-
+
def on_use_clicked (self, *args):
store, iter = self.treeview.get_selection().get_selected()
if iter != None:
type = self.treemodel.get_value(iter, 1)
id = self.treemodel.get_value(iter, 0)
if type == "at":
- t = self.template.gettemplate ("at", int (id))
+ t = self.template.gettemplate ("at", int (id))
if t != False:
id2, title, command, output = t
self.parent.at_editor.showadd_template (self.transient, title, command, output)
@@ -133,10 +133,10 @@ class TemplateChooser:
if t != False:
id2, title, command, output, timeexpression = t
self.parent.crontab_editor.showadd_template (self.transient, title, command, output, timeexpression)
-
+
self.widget.hide ()
-
+
def on_cancel_clicked (self, *args):
self.widget.hide ()
-
+
diff --git a/src/template_manager.py b/src/template_manager.py
index 36e4d25..b360bbd 100644
--- a/src/template_manager.py
+++ b/src/template_manager.py
@@ -28,7 +28,7 @@ class TemplateManager:
self.xml = self.parent.xml
self.widget = self.xml.get_widget ("template_manager")
self.widget.connect("delete-event", self.widget.hide_on_delete)
-
+
self.treeview = self.xml.get_widget ("tm_treeview")
self.button_use = self.xml.get_widget ("tm_button_use")
hbox = gtk.HBox ()
@@ -42,44 +42,44 @@ class TemplateManager:
hbox.pack_start (label, True, True, 0)
self.button_use.add (hbox)
self.button_use.show_all ()
-
+
self.button_cancel = self.xml.get_widget ("tm_button_cancel")
-
+
self.xml.signal_connect ("on_tm_button_new_clicked", self.on_new_clicked)
self.xml.signal_connect ("on_tm_button_use_clicked", self.on_use_clicked)
self.xml.signal_connect ("on_tm_button_cancel_clicked", self.on_cancel_clicked)
self.xml.signal_connect ("on_tm_button_edit_clicked", self.on_edit_clicked)
self.xml.signal_connect ("on_tm_button_delete_clicked", self.on_delete_clicked)
self.xml.signal_connect ("on_tm_treeview_button_press_event", self.on_tv_pressed)
-
+
self.button_edit = self.xml.get_widget ("tm_button_edit")
self.button_delete = self.xml.get_widget ("tm_button_delete")
-
+
self.treeview.get_selection().connect("changed", self.on_tv_changed)
-
+
# setup liststore
# [template id, type, type-string, formatted text, icon/pixbuf]
self.treemodel = gtk.ListStore (gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.gdk.Pixbuf)
-
+
# setup treeview
self.treeview.set_model (self.treemodel)
self.treeview.set_headers_visible (True)
-
-
+
+
rend1 = gtk.CellRendererPixbuf ()
rend2 = gtk.CellRendererText ()
-
+
column = gtk.TreeViewColumn(_("Task"))
column.pack_start (rend1, True)
column.pack_end (rend2, True)
column.add_attribute (rend1, "pixbuf", 4)
column.add_attribute (rend2, "text", 2)
self.treeview.append_column(column)
-
-
+
+
rend = gtk.CellRendererText ()
column = gtk.TreeViewColumn(_("Description"), rend, markup=3)
- self.treeview.append_column(column)
+ self.treeview.append_column(column)
def on_tv_changed (self, *args):
if self.treeview.get_selection().count_selected_rows() > 0 :
@@ -89,7 +89,7 @@ class TemplateManager:
self.button_use.set_sensitive (value)
self.button_edit.set_sensitive (value)
self.button_delete.set_sensitive (value)
-
+
def reload_tv (self):
self.treemodel.clear ()
at = self.template.gettemplateids ("at")
@@ -109,28 +109,28 @@ class TemplateManager:
id2, title, command, output, timeexpression = t
formatted = self.template.format_crontab (title, command, output, timeexpression)
iter = self.treemodel.append ([int (id), "crontab", _("Recurrent"), formatted, self.parent.bigiconcrontab])
-
+
def on_edit_clicked (self, *args):
store, iter = self.treeview.get_selection().get_selected()
if iter != None:
type = self.treemodel.get_value(iter, 1)
id = self.treemodel.get_value(iter, 0)
if type == "at":
- t = self.template.gettemplate ("at", int (id))
+ t = self.template.gettemplate ("at", int (id))
if t != False:
id2, title, command = t
self.parent.at_editor.showedit_template (self.widget, id2, title, command)
-
+
elif type == "crontab":
t = self.template.gettemplate ("crontab", int (id) )
if t != False:
id2, title, command, output, timeexpression = t
self.parent.crontab_editor.showedit_template (self.widget, id2, title, command, output, timeexpression)
self.reload_tv ()
-
+
def on_new_clicked (self, *args):
self.parent.addWindow.ShowAddWindow (self.widget, 1)
-
+
def on_delete_clicked (self, *args):
store, iter = self.treeview.get_selection().get_selected()
if iter != None:
@@ -140,30 +140,30 @@ class TemplateManager:
self.template.removetemplate_at (id)
elif type == "crontab":
self.template.removetemplate_crontab (id)
-
+
self.reload_tv ()
-
-
-
+
+
+
def show (self, transient):
# populate treeview
self.reload_tv ()
-
+
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show_all ()
-
+
def on_tv_pressed (self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.on_edit_clicked(self, widget)
-
+
def on_use_clicked (self, *args):
store, iter = self.treeview.get_selection().get_selected()
if iter != None:
type = self.treemodel.get_value(iter, 1)
id = self.treemodel.get_value(iter, 0)
if type == "at":
- t = self.template.gettemplate ("at", int (id))
+ t = self.template.gettemplate ("at", int (id))
if t != False:
id2, title, command, output = t
self.parent.at_editor.showadd_template (self.widget, title, command, output)
@@ -172,12 +172,12 @@ class TemplateManager:
if t != False:
id2, title, command, output, timeexpression = t
self.parent.crontab_editor.showadd_template (self.widget, title, command, output, timeexpression)
-
+
self.widget.hide ()
-
+
def on_cancel_clicked (self, *args):
self.widget.hide ()
-
-
-
+
+
+
diff --git a/src/xwrapper.py b/src/xwrapper.py
index 4bdb1cc..ba3ee1c 100755
--- a/src/xwrapper.py
+++ b/src/xwrapper.py
@@ -33,7 +33,7 @@ import gettext
gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
def check_X (display, xauth):
- # Checking if I can use X
+ # Checking if I can use X
os.putenv ('DISPLAY', display)
os.putenv ('XAUTHORITY', xauth)
@@ -54,9 +54,9 @@ def check_X (display, xauth):
sys.exit(1)
try:
- gtk.init_check ()
+ gtk.init_check ()
- except Exception as e:
+ except Exception as e:
print _("Could not open a connection to X!")
print e
sys.exit (1)
@@ -131,7 +131,7 @@ if job_type == 0:
sys.exit (1)
# TODO: Can/Does this change ?
- xauth = home_dir + "/.Xauthority"
+ xauth = home_dir + "/.Xauthority"
check_X (display, xauth)
@@ -147,7 +147,7 @@ if job_type == 0:
# AT
elif (job_type == 1):
display = os.getenv ('DISPLAY')
- xauth = home_dir + "/.Xauthority"
+ xauth = home_dir + "/.Xauthority"
check_X (display, xauth)
sys.exit (0) # All fine
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]