diff --git a/python/pycryptsetup-test.py b/python/pycryptsetup-test.py index 92ae6ce8..1585f9d4 100755 --- a/python/pycryptsetup-test.py +++ b/python/pycryptsetup-test.py @@ -33,6 +33,9 @@ c = pycryptsetup.CryptSetup( logFunc = log, passwordDialog = askpassword) +# c.debugLevel(-1); +c.debugLevel(0); +c.iterationTime(1) r = c.isLuks() print "isLuks :", r c.askyes(message = "Is there anybody out there?") diff --git a/python/pycryptsetup.c b/python/pycryptsetup.c index 419454bd..2583ebd4 100644 --- a/python/pycryptsetup.c +++ b/python/pycryptsetup.c @@ -554,6 +554,38 @@ static PyObject *CryptSetup_Suspend(CryptSetupObject* self, PyObject *args, PyOb return PyObjectResult(crypt_suspend(self->device, self->activated_as)); } +#define CryptSetup_debugLevel_HELP "Set debug level\n\n\ + debugLevel(level)\n\n\ + level - debug level" + +static PyObject *CryptSetup_debugLevel(CryptSetupObject* self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"level", NULL}; + int level = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &level)) + return NULL; + + crypt_set_debug_level(level); + return PyObjectResult(0); +} + +#define CryptSetup_iterationTime_HELP "Set iteration time\n\n\ + iterationTime(time_ms)\n\n\ + time_ms - time in miliseconds" + +static PyObject *CryptSetup_iterationTime(CryptSetupObject* self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"time_ms", NULL}; + uint64_t time_ms = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "l", kwlist, &time_ms)) + return NULL; + + crypt_set_iterarion_time(self->device, time_ms); + return PyObjectResult(0); +} + static PyMemberDef CryptSetup_members[] = { {"yesDialogCB", T_OBJECT_EX, offsetof(CryptSetupObject, yesDialogCB), 0, "confirmation dialog callback"}, {"cmdLineLogCB", T_OBJECT_EX, offsetof(CryptSetupObject, cmdLineLogCB), 0, "logging callback"}, @@ -587,6 +619,10 @@ static PyMethodDef CryptSetup_methods[] = { {"resume", (PyCFunction)CryptSetup_Resume, METH_VARARGS|METH_KEYWORDS, CryptSetup_Resume_HELP}, {"suspend", (PyCFunction)CryptSetup_Suspend, METH_NOARGS, CryptSetup_Suspend_HELP}, + /* misc */ + {"debugLevel", (PyCFunction)CryptSetup_debugLevel, METH_VARARGS|METH_KEYWORDS, CryptSetup_debugLevel_HELP}, + {"iterationTime", (PyCFunction)CryptSetup_iterationTime, METH_VARARGS|METH_KEYWORDS, CryptSetup_iterationTime_HELP}, + {NULL} /* Sentinel */ };