language namespace for plugins separated

plugin interface changed ("prepareForm" removed)
plugins do not raise exceptions anymore
first part of the partitioning plugin
device-specific stuff moved to CryptoBoxTools
This commit is contained in:
lars 2006-09-14 12:33:01 +00:00
parent f2a7ceb61c
commit de3280806f
26 changed files with 622 additions and 309 deletions

View file

@ -1,26 +1,17 @@
from CryptoBoxExceptions import CBPluginActionError
import subprocess
import os
def prepareForm(hdf, cbox):
date = __getCurrentDate()
hdf["Data.Modules.date.year"] = date.year
hdf["Data.Modules.date.month"] = date.month
hdf["Data.Modules.date.day"] = date.day
hdf["Data.Modules.date.hour"] = date.hour
hdf["Data.Modules.date.minute"] = date.minute
def doAction(cbox, store=None, year=0, month=0, day=0, hour=0, minute=0):
def doAction(hdf, cbox, store=None, year=0, month=0, day=0, hour=0, minute=0):
import datetime
__prepareFormData(hdf, cbox)
if store:
try:
year, month, day = int(year), int(month), int(day)
hour, minute = int(hour), int(minute)
new_date = datetime.datetime(year, month, day, hour, minute)
except ValueError:
raise CBPluginActionError, "InvalidDate"
hdf["Data.Warning"] = "Plugins.date.InvalidDate"
proc = subprocess.Popen(
shell = False,
args = [
@ -33,7 +24,8 @@ def doAction(cbox, store=None, year=0, month=0, day=0, hour=0, minute=0):
if proc.returncode == 0:
return "form_system"
else:
raise CBPluginActionError, "InvalidDate"
hdf["Data.Warning"] = "Plugins.date.InvalidDate"
return "form_date"
else:
return "form_date"
@ -42,6 +34,15 @@ def getStatus(cbox):
return str(__getCurrentDate())
def __prepareFormData(hdf, cbox):
date = __getCurrentDate()
hdf["Data.Plugins.date.year"] = date.year
hdf["Data.Plugins.date.month"] = date.month
hdf["Data.Plugins.date.day"] = date.day
hdf["Data.Plugins.date.hour"] = date.hour
hdf["Data.Plugins.date.minute"] = date.minute
def __getCurrentDate():
import datetime
return datetime.datetime(2000,1,1).now()

View file

@ -1,42 +1,42 @@
<?cs # $Id$ ?>
<h1><?cs var:html_escape(Lang.Title.ConfigDate) ?></h1>
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
<?cs call:print_form_header("module_date") ?>
<?cs call:print_form_header("plugins/date") ?>
<p><label for="date"><?cs var:html_escape(Lang.Text.Date) ?>: </label><br/>
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>
<select name="day" size="0"><?cs
loop: x = #1, #31, #1 ?>
<?cs if:x == Data.Modules.date.day ?><option selected="selected"><?cs
<?cs if:x == Data.Plugins.date.day ?><option selected="selected"><?cs
else ?><option><?cs /if ?><?cs var:x ?></option><?cs /loop ?>
</select>
<select name="month" size="0"><?cs
loop: x = #1, #12, #1 ?>
<?cs if:x == Data.Modules.date.month ?><option selected="selected" <?cs
<?cs if:x == Data.Plugins.date.month ?><option selected="selected" <?cs
else ?><option <?cs /if ?>value="<?cs var:x ?>"><?cs
var:html_escape(Lang.Text.Months[x]) ?></option><?cs /loop ?>
var:html_escape(Lang.Plugins.date.Text.Months[x]) ?></option><?cs /loop ?>
</select>
<select name="year" size="0"><?cs
loop: x = #2006, #2025, #1 ?>
<?cs if:x == Data.Modules.date.year ?><option selected="selected"><?cs
<?cs if:x == Data.Plugins.date.year ?><option selected="selected"><?cs
else ?><option><?cs /if ?><?cs var:x ?></option><?cs /loop ?>
</select></p>
<p><label for="time"><?cs var:html_escape(Lang.Text.Time) ?>: </label><br/>
<p><label for="time"><?cs var:html_escape(Lang.Plugins.date.Text.Time) ?>: </label><br/>
<select name="hour" size="0"><?cs
loop: x = #0, #23, #1 ?>
<?cs if:x == Data.Modules.date.hour ?><option selected="selected"><?cs
<?cs if:x == Data.Plugins.date.hour ?><option selected="selected"><?cs
else ?><option><?cs /if ?><?cs if:x<10 ?>0<?cs /if ?><?cs var:x ?></option><?cs /loop ?>
</select>&nbsp;:&nbsp;
<select name="minute" size="0"><?cs
loop: x = #0, #59, #1 ?>
<?cs if:x == Data.Modules.date.minute ?><option selected="selected"><?cs
<?cs if:x == Data.Plugins.date.minute ?><option selected="selected"><?cs
else ?><option><?cs /if ?><?cs if:x<10 ?>0<?cs /if ?><?cs var:x ?></option><?cs /loop ?>
</select></p>
<input type="hidden" name="store" value="yes" />
<button type="submit"><?cs var:html_escape(Lang.Button.ConfigDate) ?></button>
<button type="submit"><?cs var:html_escape(Lang.Plugins.date.Button.ConfigDate) ?></button>
</form>

View file

@ -1,35 +1,29 @@
Lang {
Name = Change date and time
Link = Set date/time
Rank = 10
Title.ConfigDate = Date and time setting
Title.ConfigDate = Date and time setting
Button.ConfigDate = Set date and time
Text.Date = Date
Text.Time = Time
Text.Months {
1 = January
2 = February
3 = March
4 = April
5 = May
6 = June
7 = July
8 = August
9 = September
10 = October
11 = November
12 = December
}
Modules.date {
Name = Change date and time
Link = Set date/time
Rank = 10
}
WarningMessage.InvalidDate {
Title = Invalid value
Text = An invalid value for date or time was supplied. Please try again.
}
Button.ConfigDate = Set date and time
Text.Date = Date
Text.Time = Time
Text.Months {
1 = January
2 = February
3 = March
4 = April
5 = May
6 = June
7 = July
8 = August
9 = September
10 = October
11 = November
12 = December
}
WarningMessage.InvalidDate {
Title = Invalid value
Text = An invalid value for date or time was supplied. Please try again.
}