Skip to content

Commit

Permalink
Fix filed python plugin.
Browse files Browse the repository at this point in the history
- Fix repr functions regarding printing format %lld/%ld/%d
- Fix missed conversion of some fields in NativeToPyStatPacket and
  PyStatPacketToNative().
- Fix some debug messages which miss space between text and repr output.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent c1760a0 commit f09ad15
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/plugins/filed/BareosFdPluginBaseclass.py
Expand Up @@ -109,7 +109,7 @@ def end_backup_file(self, context):
return bRCs['bRC_OK'];

def start_restore_file(self, context, cmd):
DebugMessage(context, 100, "start_restore_file() entry point in Python called with" + str(cmd) + "\n")
DebugMessage(context, 100, "start_restore_file() entry point in Python called with " + str(cmd) + "\n")
return bRCs['bRC_OK'];

def end_restore_file(self,context):
Expand All @@ -121,12 +121,12 @@ def restore_object_data(self, context, ROP):
return bRCs['bRC_OK'];

def create_file(self,context, restorepkt):
DebugMessage(context, 100, "create_file() entry point in Python called with" + str(restorepkt) + "\n")
DebugMessage(context, 100, "create_file() entry point in Python called with " + str(restorepkt) + "\n")
restorepkt.create_status = bCFs['CF_EXTRACT'];
return bRCs['bRC_OK'];

def check_file(self,context, fname):
DebugMessage(context, 100, "check_file() entry point in Python called with" + str(fname) + "\n")
DebugMessage(context, 100, "check_file() entry point in Python called with " + str(fname) + "\n")
return bRCs['bRC_OK'];

def handle_backup_file(self,context, savepkt):
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/filed/bareos-fd.py
Expand Up @@ -117,7 +117,7 @@ def plugin_io(context, IOP):
return bRCs['bRC_OK'];

def start_restore_file(context, cmd):
DebugMessage(context, 100, "start_restore_file() entry point in Python called with" + str(cmd) + "\n")
DebugMessage(context, 100, "start_restore_file() entry point in Python called with " + str(cmd) + "\n")

return bRCs['bRC_OK'];

Expand All @@ -127,14 +127,14 @@ def end_restore_file(context):
return bRCs['bRC_OK'];

def create_file(context, restorepkt):
DebugMessage(context, 100, "create_file() entry point in Python called with" + str(restorepkt) + "\n")
DebugMessage(context, 100, "create_file() entry point in Python called with " + str(restorepkt) + "\n")

restorepkt.create_status = bCFs['CF_EXTRACT'];

return bRCs['bRC_OK'];

def check_file(context, fname):
DebugMessage(context, 100, "check_file() entry point in Python called with" + str(fname) + "\n")
DebugMessage(context, 100, "check_file() entry point in Python called with " + str(fname) + "\n")

return bRCs['bRC_OK'];

Expand Down
38 changes: 21 additions & 17 deletions src/plugins/filed/python-fd.c
Expand Up @@ -1216,6 +1216,7 @@ static inline PyStatPacket *NativeToPyStatPacket(struct stat *statp)
pStatp->uid = statp->st_uid;
pStatp->gid = statp->st_gid;
pStatp->rdev = statp->st_rdev;
pStatp->size = statp->st_size;
pStatp->atime = statp->st_atime;
pStatp->mtime = statp->st_mtime;
pStatp->ctime = statp->st_ctime;
Expand All @@ -1231,9 +1232,11 @@ static inline void PyStatPacketToNative(PyStatPacket *pStatp, struct stat *statp
statp->st_dev = pStatp->dev;
statp->st_ino = pStatp->ino;
statp->st_mode = pStatp->mode;
statp->st_nlink = pStatp->nlink;
statp->st_uid = pStatp->uid;
statp->st_gid = pStatp->gid;
statp->st_rdev = pStatp->rdev;
statp->st_size = pStatp->size;
statp->st_atime = pStatp->atime;
statp->st_mtime = pStatp->mtime;
statp->st_ctime = pStatp->ctime;
Expand Down Expand Up @@ -2345,8 +2348,8 @@ static PyObject *PyRestoreObject_repr(PyRestoreObject *self)
POOL_MEM buf(PM_MESSAGE);

Mmsg(buf, "RestoreObject(object_name=\"%s\", object=\"%s\", plugin_name=\"%s\", "
"object_type=%d, object_len=%d, object_full_len=%d, "
"object_index=%d, object_compression=%d, stream=%d, jobid=%d)",
"object_type=%ld, object_len=%ld, object_full_len=%ld, "
"object_index=%ld, object_compression=%ld, stream=%ld, jobid=%ld)",
self->object_name, self->object, self->plugin_name,
self->object_type, self->object_len, self->object_full_len,
self->object_index, self->object_compression, self->stream, self->JobId);
Expand Down Expand Up @@ -2425,9 +2428,9 @@ static PyObject *PyStatPacket_repr(PyStatPacket *self)
PyObject *s;
POOL_MEM buf(PM_MESSAGE);

Mmsg(buf, "StatPacket(dev=%d, ino=%ld, mode=%d, nlink=%d, "
"uid=%d, gid=%d, rdev=%d, size=%ld, "
"atime=%d, mtime=%d, ctime=%d, blksize=%d, blocks=%ld",
Mmsg(buf, "StatPacket(dev=%ld, ino=%lld, mode=%d, nlink=%d, "
"uid=%ld, gid=%ld, rdev=%ld, size=%lld, "
"atime=%ld, mtime=%ld, ctime=%ld, blksize=%ld, blocks=%lld)",
self->dev, self->ino, self->mode, self->nlink,
self->uid, self->gid, self->rdev, self->size,
self->atime, self->mtime, self->ctime, self->blksize, self->blocks);
Expand Down Expand Up @@ -2518,10 +2521,10 @@ static PyObject *PySavePacket_repr(PySavePacket *self)
PyObject *s;
POOL_MEM buf(PM_MESSAGE);

Mmsg(buf, "SavePacket(fname=\"%s\", link=\"%s\", type=%d, flags=%d, "
Mmsg(buf, "SavePacket(fname=\"%s\", link=\"%s\", type=%ld, flags=%ld, "
"no_read=%d, portable=%d, accurate_found=%d, "
"cmd=\"%s\", delta_seq=%d, object_name=\"%s\", "
"object=\"%s\", object_len=%d, object_index=%d)",
"cmd=\"%s\", delta_seq=%ld, object_name=\"%s\", "
"object=\"%s\", object_len=%ld, object_index=%ld)",
PyGetStringValue(self->fname), PyGetStringValue(self->link),
self->type, self->flags, self->no_read, self->portable,
self->accurate_found, self->cmd, self->delta_seq,
Expand Down Expand Up @@ -2621,15 +2624,16 @@ static void PySavePacket_dealloc(PySavePacket *self)
*/
static PyObject *PyRestorePacket_repr(PyRestorePacket *self)
{
PyObject *s;
PyObject *stat_repr, *s;
POOL_MEM buf(PM_MESSAGE);

Mmsg(buf, "RestorPacket(stream=%d, data_stream=%d, type=%d, file_index=%d, "
"linkFI=%d, uid=%d, attrEx=\"%s\", ofname=\"%s\", olname=\"%s\", "
"where=\"%s\", RegexWhere=\"%s\", replace=%d, create_status=%d)",
stat_repr = PyObject_Repr(self->statp);
Mmsg(buf, "RestorePacket(stream=%d, data_stream=%ld, type=%ld, file_index=%ld, "
"linkFI=%ld, uid=%ld, statp=\"%s\", attrEx=\"%s\", ofname=\"%s\", "
"olname=\"%s\", where=\"%s\", RegexWhere=\"%s\", replace=%d, create_status=%d)",
self->stream, self->data_stream, self->type, self->file_index,
self->LinkFI, self->uid, self->attrEx, self->ofname, self->olname,
self->where, self->RegexWhere, self->replace, self->create_status);
self->LinkFI, self->uid, PyGetStringValue(stat_repr), self->attrEx, self->ofname,
self->olname, self->where, self->RegexWhere, self->replace, self->create_status);

s = PyString_FromString(buf.c_str());

Expand Down Expand Up @@ -2717,9 +2721,9 @@ static PyObject *PyIoPacket_repr(PyIoPacket *self)
PyObject *s;
POOL_MEM buf(PM_MESSAGE);

Mmsg(buf, "IoPacket(func=%d, count=%d, flags=%d, mode=%d, "
"buf=\"%s\", fname=\"%s\", status=%d, io_errno=%d, lerror=%d, "
"whence=%d, offset=%d, win32=%d)",
Mmsg(buf, "IoPacket(func=%d, count=%ld, flags=%ld, mode=%ld, "
"buf=\"%s\", fname=\"%s\", status=%ld, io_errno=%ld, lerror=%ld, "
"whence=%ld, offset=%lld, win32=%d)",
self->func, self->count, self->flags, self->mode,
PyGetByteArrayValue(self->buf), self->fname, self->status,
self->io_errno, self->lerror,
Expand Down

0 comments on commit f09ad15

Please sign in to comment.