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()