cryptonas-branches/pythonrewrite/plugins/date/date.py
lars de3280806f 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
2006-09-14 12:33:01 +00:00

49 lines
1.3 KiB
Python

import subprocess
import os
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:
hdf["Data.Warning"] = "Plugins.date.InvalidDate"
proc = subprocess.Popen(
shell = False,
args = [
cbox.prefs["Programs"]["super"],
cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin",
os.path.join(os.path.dirname(__file__), "root_action.py"),
"%02d%02d%02d%02d%d" % (month, day, hour, minute, year)])
proc.communicate()
if proc.returncode == 0:
return "form_system"
else:
hdf["Data.Warning"] = "Plugins.date.InvalidDate"
return "form_date"
else:
return "form_date"
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()