Hello community,
here is the log from the commit of package python-smbc for openSUSE:Factory
checked in at Tue Aug 24 22:43:08 CEST 2010.
--------
--- python-smbc/python-smbc.changes 2010-08-06 17:23:49.000000000 +0200
+++ python-smbc/python-smbc.changes 2010-08-23 10:23:19.000000000 +0200
@@ -1,0 +2,13 @@
+Mon Aug 23 10:22:33 CEST 2010 - dimstar@opensuse.org
+
+- Update to version 1.0.9:
+ + iteration file read
+ + rewrite tests for python nose
+ + fixed stat portability issue
+ + smbc.NoEntryError
+ + smbc.ExistsError
+ + smbc.NotEmptyError
+ + smbc.TimedOutError
+ + File.seek() and File.lseek()
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
pysmbc-1.0.8.tar.bz2
New:
----
pysmbc-1.0.9.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-smbc.spec ++++++
--- /var/tmp/diff_new_pack.gFPHPw/_old 2010-08-24 22:40:43.000000000 +0200
+++ /var/tmp/diff_new_pack.gFPHPw/_new 2010-08-24 22:40:43.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package python-smbc (Version 1.0.8)
+# spec file for package python-smbc (Version 1.0.9)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -22,7 +22,7 @@
%define _name pysmbc
BuildRequires: libsmbclient-devel
BuildRequires: python-devel
-Version: 1.0.8
+Version: 1.0.9
Release: 1
Group: Development/Libraries/Python
License: GPLv2+
++++++ pysmbc-1.0.8.tar.bz2 -> pysmbc-1.0.9.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/Makefile new/pysmbc-1.0.9/Makefile
--- old/pysmbc-1.0.8/Makefile 2010-05-18 15:09:36.000000000 +0200
+++ new/pysmbc-1.0.9/Makefile 2010-06-29 07:18:10.000000000 +0200
@@ -2,13 +2,14 @@
VERSION:=$(shell python setup.py --version)
SDIST_ARGS=--formats=bztar -d.
-smbc.so: $(SOURCES)
+smbc.so: force
python setup.py build
mv build/lib*/$@ .
doc: smbc.so
rm -rf html
epydoc -o html --html $<
+ cd html && zip ../smbc-html.zip *
clean:
-rm -rf build smbc.so *.pyc tests/*.pyc *~ tests/*~
@@ -24,5 +25,5 @@
if [ -n "$$DESTDIR" ]; then ROOT="--root $$DESTDIR"; fi; \
python setup.py install $$ROOT
-.PHONY: doc clean dist install
+.PHONY: doc clean dist install force
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/NEWS new/pysmbc-1.0.9/NEWS
--- old/pysmbc-1.0.8/NEWS 2010-05-23 19:03:13.000000000 +0200
+++ new/pysmbc-1.0.9/NEWS 2010-06-29 07:56:00.000000000 +0200
@@ -1,6 +1,17 @@
NEWS
----
+New in 1.0.9:
+
+* iteration file read
+* rewrite tests for python nose
+* fixed stat portability issue
+* smbc.NoEntryError
+* smbc.ExistsError
+* smbc.NotEmptyError
+* smbc.TimedOutError
+* File.seek() and File.lseek()
+
New in 1.0.8:
* Context.chmod()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/PKG-INFO new/pysmbc-1.0.9/PKG-INFO
--- old/pysmbc-1.0.8/PKG-INFO 2010-05-23 19:27:01.000000000 +0200
+++ new/pysmbc-1.0.9/PKG-INFO 2010-07-05 10:23:10.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: pysmbc
-Version: 1.0.8
+Version: 1.0.9
Summary: Python bindings for libsmbclient
Home-page: http://cyberelk.net/tim/software/pysmbc/
Author: ['Tim Waugh ', 'Tsukasa Hamano ']
@@ -25,13 +25,13 @@
>>> import smbc
>>> import os
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
- >>> file = ctx.open ("smb://SERVER/file.txt", os.O_CREAT | os.O_WRONLY)
+ >>> file = ctx.open ("smb://SERVER/music/file.txt", os.O_CREAT | os.O_WRONLY)
>>> file.write ("hello")
>>> # Read file example:
>>> import smbc
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
- >>> file = ctx.open ("smb://SERVER/file.txt")
+ >>> file = ctx.open ("smb://SERVER/music/file.txt")
>>> print file.read()
hello
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/context.c new/pysmbc-1.0.9/context.c
--- old/pysmbc-1.0.8/context.c 2010-05-23 18:20:35.000000000 +0200
+++ new/pysmbc-1.0.9/context.c 2010-07-01 07:01:39.000000000 +0200
@@ -199,12 +199,14 @@
if (smbc_FileType.tp_init ((PyObject *)file, largs, lkwlist) < 0){
smbc_FileType.tp_dealloc((PyObject *)file);
debugprintf ("%p <- Context_open() EXCEPTION\n", self->context);
+ // already set error
return NULL;
}
fn = smbc_getFunctionOpen (self->context);
+ errno = 0;
file->file = (*fn)(self->context, uri, (int)flags, (mode_t)mode);
if(!file->file){
- PyErr_SetFromErrno(PyExc_RuntimeError);
+ pysmbc_SetFromErrno();
return NULL;
}
Py_DECREF (largs);
@@ -238,9 +240,10 @@
return NULL;
}
fn = smbc_getFunctionCreat(self->context);
+ errno = 0;
file->file = (*fn)(self->context, uri, mode);
if(!file->file){
- PyErr_SetFromErrno(PyExc_RuntimeError);
+ pysmbc_SetFromErrno();
return NULL;
}
Py_DECREF (largs);
@@ -260,7 +263,12 @@
}
fn = smbc_getFunctionUnlink(self->context);
+ errno = 0;
ret = (*fn)(self->context, uri);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(ret);
}
@@ -278,11 +286,16 @@
}
fn = smbc_getFunctionRename(self->context);
+ errno = 0;
if(nctx && nctx->context){
ret = (*fn)(self->context, ouri, nctx->context, nuri);
}else{
ret = (*fn)(self->context, ouri, self->context, nuri);
}
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(ret);
}
@@ -304,7 +317,7 @@
lkwlist = PyDict_New ();
PyDict_SetItemString (lkwlist, "context", (PyObject *) self);
PyDict_SetItemString (lkwlist, "uri", uri);
- dir = PyType_GenericNew (&smbc_DirType, largs, lkwlist);
+ dir = smbc_DirType.tp_new (&smbc_DirType, largs, lkwlist);
if (smbc_DirType.tp_init (dir, largs, lkwlist) < 0)
{
smbc_DirType.tp_dealloc (dir);
@@ -331,7 +344,12 @@
}
fn = smbc_getFunctionMkdir(self->context);
+ errno = 0;
ret = (*fn)(self->context, uri, mode);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(ret);
}
@@ -347,7 +365,12 @@
}
fn = smbc_getFunctionRmdir(self->context);
+ errno = 0;
ret = (*fn)(self->context, uri);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(ret);
}
@@ -364,16 +387,17 @@
}
fn = smbc_getFunctionStat(self->context);
+ errno = 0;
ret = (*fn)(self->context, uri, &st);
if(ret < 0){
- PyErr_SetString(PyExc_RuntimeError, "No such file or directory");
+ pysmbc_SetFromErrno();
return NULL;
}
- return Py_BuildValue("(IkkkIIkkkk)",
+ return Py_BuildValue("(IKKKIIKIII)",
st.st_mode,
- st.st_ino,
- st.st_dev,
- st.st_nlink,
+ (unsigned long long)st.st_ino,
+ (unsigned long long)st.st_dev,
+ (unsigned long long)st.st_nlink,
st.st_uid,
st.st_gid,
st.st_size,
@@ -393,9 +417,13 @@
if(!PyArg_ParseTuple (args, "si", &uri, &mode)) {
return NULL;
}
-
+ errno = 0;
fn = smbc_getFunctionChmod(self->context);
ret = (*fn)(self->context, uri, mode);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(ret);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/dir.c new/pysmbc-1.0.9/dir.c
--- old/pysmbc-1.0.8/dir.c 2010-05-14 08:22:41.000000000 +0200
+++ new/pysmbc-1.0.9/dir.c 2010-07-05 10:01:22.000000000 +0200
@@ -78,16 +78,9 @@
errno = 0;
dir = (*fn) (ctx->context, uri);
if (dir == NULL) {
- if(errno == EPERM){
- PyErr_SetString(PermissionError, "Permission denied.");
- }else if(errno == ENOMEM){
- PyErr_SetFromErrno(PyExc_MemoryError);
- }else{
- PyErr_SetFromErrno(PyExc_RuntimeError);
- }
+ pysmbc_SetFromErrno();
return -1;
}
-
self->dir = dir;
debugprintf ("%p <- Dir_init() = 0\n", self->dir);
return 0;
@@ -136,7 +129,7 @@
debugprintf ("dirlen = %d\n", dirlen);
if (dirlen < 0)
{
- PyErr_SetFromErrno (PyExc_RuntimeError);
+ pysmbc_SetFromErrno();
Py_DECREF (listobj);
debugprintf ("<- Dir_getdents() EXCEPTION\n");
return NULL;
@@ -159,7 +152,7 @@
Py_DECREF (name);
Py_DECREF (comment);
Py_DECREF (type);
- dent = PyType_GenericNew (&smbc_DirentType, largs, lkwlist);
+ dent = smbc_DirentType.tp_new (&smbc_DirentType, largs, lkwlist);
smbc_DirentType.tp_init (dent, largs, lkwlist);
debugprintf ("%p\n", dent);
Py_DECREF (largs);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/file.c new/pysmbc-1.0.9/file.c
--- old/pysmbc-1.0.8/file.c 2010-05-19 05:21:41.000000000 +0200
+++ new/pysmbc-1.0.9/file.c 2010-06-30 09:49:19.000000000 +0200
@@ -30,6 +30,23 @@
// File //
//////////
+/*
+ The size of off_t is potentionally unknown, so try to use the
+ biggest integer type possible when coverting between ptyhon
+ values and off_t.
+
+ In order to communicate offset values between python objects and C
+ types use off_t_long as the C type and OFF_T_FORMAT as the format
+ character for Py_BuildValue, PyArg_Parse, and similar functions.
+*/
+#ifdef HAVE_LONG_LONG
+typedef PY_LONG_LONG off_t_long;
+#define OFF_T_FORMAT "L"
+#else
+typedef PY_LONG off_t_long;
+#define OFF_T_FORMAT "l"
+#endif
+
static PyObject *
File_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
{
@@ -80,7 +97,7 @@
file = (*fn) (ctx->context, uri, (int) flags, (mode_t) mode);
if (file == NULL)
{
- PyErr_SetFromErrno (PyExc_RuntimeError);
+ pysmbc_SetFromErrno();
return -1;
}
self->file = file;
@@ -111,32 +128,6 @@
}
static PyObject *
-File_fstat(File *self, PyObject *args)
-{
- Context *ctx = self->context;
- smbc_fstat_fn fn;
- struct stat st;
- int ret;
-
- fn = smbc_getFunctionFstat(ctx->context);
- ret = (*fn)(ctx->context, self->file, &st);
- if(ret < 0){
- return NULL;
- }
- return Py_BuildValue("(IkkkIIkkkk)",
- st.st_mode,
- st.st_ino,
- st.st_dev,
- st.st_nlink,
- st.st_uid,
- st.st_gid,
- st.st_size,
- st.st_atime,
- st.st_mtime,
- st.st_ctime);
-}
-
-static PyObject *
File_read(File *self, PyObject *args)
{
Context *ctx = self->context;
@@ -164,9 +155,13 @@
return PyErr_NoMemory();
}
len = (*fn)(ctx->context, self->file, buf, size);
+ if(len < 0){
+ pysmbc_SetFromErrno();
+ free(buf);
+ return NULL;
+ }
ret = PyString_FromStringAndSize(buf, len);
free(buf);
-
return ret;
}
@@ -184,11 +179,42 @@
}
fn = smbc_getFunctionWrite(ctx->context);
len = (*fn)(ctx->context, self->file, buf, size);
-
+ if(len < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
return PyInt_FromLong(len);
}
static PyObject *
+File_fstat(File *self, PyObject *args)
+{
+ Context *ctx = self->context;
+ smbc_fstat_fn fn;
+ struct stat st;
+ int ret;
+
+ fn = smbc_getFunctionFstat(ctx->context);
+ errno = 0;
+ ret = (*fn)(ctx->context, self->file, &st);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
+ return Py_BuildValue("(IKKKIIKIII)",
+ st.st_mode,
+ (unsigned long long)st.st_ino,
+ (unsigned long long)st.st_dev,
+ (unsigned long long)st.st_nlink,
+ st.st_uid,
+ st.st_gid,
+ st.st_size,
+ st.st_atime,
+ st.st_mtime,
+ st.st_ctime);
+}
+
+static PyObject *
File_close(File *self, PyObject *args)
{
Context *ctx = self->context;
@@ -203,12 +229,90 @@
return PyInt_FromLong(ret);
}
+static PyObject *
+File_iter(PyObject *self)
+{
+ Py_INCREF(self);
+ return self;
+}
+
+static PyObject *
+File_iternext(PyObject *self)
+{
+ File *file = (File *)self;
+ Context *ctx = file->context;
+ smbc_read_fn fn;
+ char buf[2048];
+ ssize_t len;
+ fn = smbc_getFunctionRead(ctx->context);
+ len = (*fn)(ctx->context, file->file, buf, 2048);
+ if(len > 0){
+ return PyString_FromStringAndSize(buf, len);
+ }else if(len == 0){
+ PyErr_SetNone(PyExc_StopIteration);
+ }else{
+ pysmbc_SetFromErrno();
+ }
+ return NULL;
+}
+
+static PyObject *
+File_lseek(File *self, PyObject *args)
+{
+ Context *ctx = self->context;
+ smbc_lseek_fn fn;
+ off_t_long py_offset;
+ off_t offset;
+ int whence=0;
+ off_t ret;
+
+ if(!PyArg_ParseTuple(args, (OFF_T_FORMAT "|i"), &py_offset, &whence)){
+ return NULL;
+ }
+ offset = py_offset;
+ /* check for data loss from cast */
+ if ((off_t_long)offset != py_offset) {
+ PyErr_SetString(PyExc_OverflowError, "Data loss in casting off_t");
+ }
+ fn = smbc_getFunctionLseek(ctx->context);
+ ret = (*fn)(ctx->context, self->file, offset, whence);
+ if(ret < 0){
+ pysmbc_SetFromErrno();
+ return NULL;
+ }
+ return Py_BuildValue(OFF_T_FORMAT, ret);
+}
+
PyMethodDef File_methods[] =
{
- {"fstat", (PyCFunction)File_fstat, METH_NOARGS, NULL},
- {"read", (PyCFunction)File_read, METH_VARARGS, NULL},
- {"write", (PyCFunction)File_write, METH_VARARGS, NULL},
- {"close", (PyCFunction)File_close, METH_NOARGS, NULL},
+ {"read", (PyCFunction)File_read, METH_VARARGS,
+ "read(size) -> string\n\n"
+ "@type size: int\n"
+ "@param size: size of reading\n"
+ "@return: read data"
+ },
+ {"write", (PyCFunction)File_write, METH_VARARGS,
+ "write(buf) -> int\n\n"
+ "@type buf: string\n"
+ "@param buf: write data\n"
+ "@return: size of written"
+ },
+ {"fstat", (PyCFunction)File_fstat, METH_NOARGS,
+ "fstat() -> tuple\n\n"
+ "@return: fstat information"
+ },
+ {"close", (PyCFunction)File_close, METH_NOARGS,
+ "close() -> int\n\n"
+ "@return: on success, < 0 on error"
+ },
+ {"lseek", (PyCFunction)File_lseek, METH_VARARGS,
+ "lseek(offset, whence=0)\n\n"
+ "@return: on success, current offset location, othwerwise -1"
+ },
+ {"seek", (PyCFunction)File_lseek, METH_VARARGS,
+ "seek(offset, whence=0)\n\n"
+ "@return: on success, current offset location, othwerwise -1"
+ },
{ NULL } /* Sentinel */
};
@@ -238,14 +342,14 @@
"SMBC File\n"
"=========\n\n"
- " A directory object."
+ " A file object."
"", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ File_iter, /* tp_iter */
+ File_iternext, /* tp_iternext */
File_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/setup.py new/pysmbc-1.0.9/setup.py
--- old/pysmbc-1.0.8/setup.py 2010-05-23 19:26:56.000000000 +0200
+++ new/pysmbc-1.0.9/setup.py 2010-07-05 09:44:24.000000000 +0200
@@ -38,13 +38,13 @@
import smbc
import os
ctx = smbc.Context (auth_fn=my_auth_callback_fn)
->>> file = ctx.open ("smb://SERVER/file.txt", os.O_CREAT | os.O_WRONLY)
+>>> file = ctx.open ("smb://SERVER/music/file.txt", os.O_CREAT | os.O_WRONLY)
file.write ("hello")
# Read file example:
import smbc
ctx = smbc.Context (auth_fn=my_auth_callback_fn)
->>> file = ctx.open ("smb://SERVER/file.txt")
+>>> file = ctx.open ("smb://SERVER/music/file.txt")
print file.read()
hello
@@ -52,7 +52,7 @@
from distutils.core import setup, Extension
setup (name="pysmbc",
- version="1.0.8",
+ version="1.0.9",
description="Python bindings for libsmbclient",
long_description=__doc__,
author=["Tim Waugh ",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/smbcmodule.c new/pysmbc-1.0.9/smbcmodule.c
--- old/pysmbc-1.0.8/smbcmodule.c 2010-05-18 15:01:54.000000000 +0200
+++ new/pysmbc-1.0.9/smbcmodule.c 2010-07-05 10:06:51.000000000 +0200
@@ -1,6 +1,10 @@
/* -*- Mode: C; c-file-style: "gnu" -*-
* pysmbc - Python bindings for libsmbclient
- * Copyright (C) 2002, 2005, 2006, 2007, 2008 Tim Waugh
+ * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010 Red Hat, Inc
+ * Copyright (C) 2010 Open Source Solution Technology Corporation
+ * Authors:
+ * Tim Waugh
+ * Tsukasa Hamano
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +33,11 @@
{ NULL, NULL, 0, NULL }
};
+PyObject *NoEntryError;
PyObject *PermissionError;
+PyObject *ExistsError;
+PyObject *NotEmptyError;
+PyObject *TimedOutError;
void
initsmbc (void)
@@ -38,17 +46,13 @@
PyObject *d = PyModule_GetDict (m);
// Context type
- smbc_ContextType.tp_new = PyType_GenericNew;
if (PyType_Ready (&smbc_ContextType) < 0)
return;
-
PyModule_AddObject (m, "Context", (PyObject *) &smbc_ContextType);
// Dir type
- smbc_DirType.tp_new = PyType_GenericNew;
if (PyType_Ready (&smbc_DirType) < 0)
return;
-
PyModule_AddObject (m, "Dir", (PyObject *) &smbc_DirType);
// File type
@@ -57,10 +61,8 @@
PyModule_AddObject (m, "File", (PyObject *) &smbc_FileType);
// Dirent type
- smbc_DirentType.tp_new = PyType_GenericNew;
if (PyType_Ready (&smbc_DirentType) < 0)
return;
-
PyModule_AddObject (m, "Dirent", (PyObject *) &smbc_DirentType);
#define INT_CONSTANT(prefix, name) \
@@ -81,9 +83,55 @@
INT_CONSTANT (SMB_CTX_, FLAG_FALLBACK_AFTER_KERBEROS);
INT_CONSTANT (SMBCCTX_, FLAG_NO_AUTO_ANONYMOUS_LOGON);
+ NoEntryError = PyErr_NewException("smbc.NoEntryError", NULL, NULL);
+ Py_INCREF(NoEntryError);
+ PyModule_AddObject(m, "NoEntryError", NoEntryError);
+
PermissionError = PyErr_NewException("smbc.PermissionError", NULL, NULL);
Py_INCREF(PermissionError);
PyModule_AddObject(m, "PermissionError", PermissionError);
+
+ ExistsError = PyErr_NewException("smbc.ExistsError", NULL, NULL);
+ Py_INCREF(ExistsError);
+ PyModule_AddObject(m, "ExistsError", ExistsError);
+
+ NotEmptyError = PyErr_NewException("smbc.NotEmptyError", NULL, NULL);
+ Py_INCREF(NotEmptyError);
+ PyModule_AddObject(m, "NotEmptyError", NotEmptyError);
+
+ TimedOutError = PyErr_NewException("smbc.TimedOutError", NULL, NULL);
+ Py_INCREF(TimedOutError);
+ PyModule_AddObject(m, "TimedOutError", TimedOutError);
+}
+
+void pysmbc_SetFromErrno()
+{
+ switch(errno){
+ case EPERM:
+ PyErr_SetFromErrno(PermissionError);
+ break;
+ case EEXIST:
+ PyErr_SetFromErrno(ExistsError);
+ break;
+ case ENOTEMPTY:
+ PyErr_SetFromErrno(NotEmptyError);
+ break;
+ case EACCES:
+ PyErr_SetFromErrno(PermissionError);
+ break;
+ case ENOENT:
+ PyErr_SetFromErrno(NoEntryError);
+ break;
+ case ETIMEDOUT:
+ PyErr_SetFromErrno(TimedOutError);
+ break;
+ case ENOMEM:
+ PyErr_SetFromErrno(PyExc_MemoryError);
+ break;
+ default:
+ PyErr_SetFromErrno(PyExc_RuntimeError);
+ }
+ return;
}
///////////////
@@ -109,7 +157,7 @@
debugging_enabled = 1;
}
-
+
{
va_list ap;
va_start (ap, fmt);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/smbcmodule.h new/pysmbc-1.0.9/smbcmodule.h
--- old/pysmbc-1.0.8/smbcmodule.h 2010-05-14 08:21:17.000000000 +0200
+++ new/pysmbc-1.0.9/smbcmodule.h 2010-07-05 10:07:17.000000000 +0200
@@ -1,6 +1,10 @@
/* -*- Mode: C; c-file-style: "gnu" -*-
* pysmbc - Python bindings for libsmbclient
- * Copyright (C) 2002, 2005, 2006, 2007, 2008 Tim Waugh
+ * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010 Red Hat, Inc
+ * Copyright (C) 2010 Open Source Solution Technology Corporation
+ * Authors:
+ * Tim Waugh
+ * Tsukasa Hamano
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +35,12 @@
#endif
extern void debugprintf (const char *fmt, ...) FORMAT ((__printf__, 1, 2));
+extern void pysmbc_SetFromErrno(void);
+extern PyObject *NoEntryError;
extern PyObject *PermissionError;
+extern PyObject *ExistsError;
+extern PyObject *NotEmptyError;
+extern PyObject *TimedOutError;
#endif /* HAVE_SMBCMODULE_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/settings.py new/pysmbc-1.0.9/tests/settings.py
--- old/pysmbc-1.0.8/tests/settings.py 2010-05-23 17:53:38.000000000 +0200
+++ new/pysmbc-1.0.9/tests/settings.py 2010-06-15 13:08:41.000000000 +0200
@@ -1,13 +1,13 @@
# This is setting template.
# You must change these parameter if you perform test.
+# The following configration will create \\server\share\testdir
+# directory, so user should have write permission.
WORKGROUP = "WORKGROUP"
-#SERVER = "hamano21"
-#SHARE = "test"
-#USERNAME = "user1"
-#PASSWORD = "password"
-
-SERVER = "kujira"
-SHARE = "test"
-USERNAME = "test"
+SERVER = "server"
+SHARE = "share"
+USERNAME = "username"
PASSWORD = "password"
+TESTDIR = "testdir"
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/test_all.py new/pysmbc-1.0.9/tests/test_all.py
--- old/pysmbc-1.0.8/tests/test_all.py 2010-05-14 18:34:11.000000000 +0200
+++ new/pysmbc-1.0.9/tests/test_all.py 2010-05-28 06:15:09.000000000 +0200
@@ -3,11 +3,13 @@
import unittest
import test_context
import test_auth
+import test_dir
if __name__ == '__main__':
loader = unittest.TestLoader()
suite1 = loader.loadTestsFromTestCase(test_context.TestContext)
suite2 = loader.loadTestsFromTestCase(test_auth.TestAuth)
- alltests = unittest.TestSuite([suite1, suite2])
+ suite3 = loader.loadTestsFromTestCase(test_dir.TestDir)
+ alltests = unittest.TestSuite([suite1, suite2, suite3])
unittest.TextTestRunner(verbosity=2).run(alltests)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/test_auth.py new/pysmbc-1.0.9/tests/test_auth.py
--- old/pysmbc-1.0.8/tests/test_auth.py 2010-05-14 10:15:49.000000000 +0200
+++ new/pysmbc-1.0.9/tests/test_auth.py 2010-07-05 10:00:51.000000000 +0200
@@ -1,57 +1,70 @@
#!/usr/bin/env python
-import unittest
import smbc
import settings
+import sys
-class TestAuth(unittest.TestCase):
- def setUp(self):
- pass
+def setUp():
+ pass
- def tearDown(self):
- pass
+def tearDown():
+ pass
- def testNoAutoAnonymousLogin(self):
- ctx = smbc.Context()
- ctx.optionNoAutoAnonymousLogin = True
- uri = 'smb://' + settings.SERVER
- try:
- dir = ctx.opendir(uri)
- except smbc.PermissionError:
- pass
- except:
- self.fail()
- else:
- self.fail()
-
- def callback(self, server, share, workgroup, username, password):
- return (workgroup, settings.USERNAME, settings.PASSWORD)
-
- def testAuth(self):
- ctx = smbc.Context()
- ctx.optionNoAutoAnonymousLogin = True
- cb = lambda se, sh, w, u, p: (w, settings.USERNAME, settings.PASSWORD)
- ctx.functionAuthData = cb
- uri = 'smb://' + settings.SERVER
- try:
- dir = ctx.opendir(uri)
- except:
- self.fail()
-
- def testAuthFail(self):
- ctx = smbc.Context()
- ctx.optionNoAutoAnonymousLogin = True
- cb = lambda se, sh, w, u, p: (w, settings.USERNAME, "")
- ctx.functionAuthData = cb
- uri = 'smb://' + settings.SERVER
- try:
- dir = ctx.opendir(uri)
- except smbc.PermissionError:
- pass
- except:
- self.fail()
- else:
- self.fail()
+def test_AuthSuccess():
+ ctx = smbc.Context()
+ ctx.optionNoAutoAnonymousLogin = True
+ cb = lambda se, sh, w, u, p: (w, settings.USERNAME, settings.PASSWORD)
+ ctx.functionAuthData = cb
+ uri = 'smb://' + settings.SERVER + '/' + settings.SHARE
+ try:
+ dir = ctx.opendir(uri)
+ except:
+ assert False
+
+def test_AuthFailNoauth():
+ ctx = smbc.Context()
+ ctx.optionNoAutoAnonymousLogin = True
+ uri = 'smb://' + settings.SERVER + '/' + settings.SHARE
+ try:
+ dir = ctx.opendir(uri)
+ except smbc.PermissionError:
+ pass
+ except:
+ assert False
+ else:
+ assert False
+
+def test_AuthFailNopass():
+ ctx = smbc.Context()
+ ctx.optionNoAutoAnonymousLogin = True
+ cb = lambda se, sh, w, u, p: (w, settings.USERNAME, "")
+ ctx.functionAuthData = cb
+ uri = 'smb://' + settings.SERVER + '/' + settings.SHARE
+ try:
+ dir = ctx.opendir(uri)
+ except smbc.PermissionError:
+ pass
+ except:
+ assert False
+ else:
+ assert False
+
+def test_AuthFailNoname():
+ ctx = smbc.Context()
+ ctx.optionNoAutoAnonymousLogin = True
+ cb = lambda se, sh, w, u, p: (w, "", "")
+ ctx.functionAuthData = cb
+ uri = 'smb://' + settings.SERVER + '/' + settings.SHARE
+ try:
+ dir = ctx.opendir(uri)
+ except smbc.PermissionError:
+ pass
+ except:
+ assert False
+ else:
+ assert False
if __name__ == '__main__':
- unittest.main()
+ import nose
+ result = nose.run()
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/test_context.py new/pysmbc-1.0.9/tests/test_context.py
--- old/pysmbc-1.0.8/tests/test_context.py 2010-05-14 17:01:03.000000000 +0200
+++ new/pysmbc-1.0.9/tests/test_context.py 2010-07-05 10:01:02.000000000 +0200
@@ -1,35 +1,32 @@
#!/usr/bin/env python
-import unittest
import smbc
import settings
-class TestContext(unittest.TestCase):
- def setUp(self):
- self.ctx = smbc.Context()
-
- def tearDown(self):
- del self.ctx
-
- def testWorkgroup(self):
- list = self.ctx.opendir('smb://').getdents()
- assert(len(list) > 0)
- for entry in list:
- assert(entry.smbc_type == 1)
-
- def testServer(self):
- uri = 'smb://' + settings.WORKGROUP
- list = self.ctx.opendir(uri).getdents()
- assert(len(list) > 0)
- for entry in list:
- assert(entry.smbc_type == 2)
-
- def testShare(self):
- uri = 'smb://' + settings.SERVER
- list = self.ctx.opendir(uri).getdents()
- assert(len(list) > 0)
- for entry in list:
- assert(entry.smbc_type == 3 or entry.smbc_type == 6)
-
-if __name__ == '__main__':
- unittest.main()
+def setUp():
+ global ctx
+ ctx = smbc.Context()
+
+def tearDown():
+ global ctx
+ del ctx
+
+def test_Workgroup():
+ list = ctx.opendir('smb://').getdents()
+ assert(len(list) > 0)
+ for entry in list:
+ assert(entry.smbc_type == 1)
+
+def test_Server():
+ uri = 'smb://' + settings.WORKGROUP
+ list = ctx.opendir(uri).getdents()
+ assert(len(list) > 0)
+ for entry in list:
+ assert(entry.smbc_type == 2)
+
+def test_Share():
+ uri = 'smb://' + settings.SERVER
+ list = ctx.opendir(uri).getdents()
+ assert(len(list) > 0)
+ for entry in list:
+ assert(3 <= entry.smbc_type and entry.smbc_type <= 6)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/test_dir.py new/pysmbc-1.0.9/tests/test_dir.py
--- old/pysmbc-1.0.8/tests/test_dir.py 1970-01-01 01:00:00.000000000 +0100
+++ new/pysmbc-1.0.9/tests/test_dir.py 2010-07-05 10:04:46.000000000 +0200
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+
+import unittest
+import smbc
+import settings
+import stat
+
+basedir = 'smb://' + settings.SERVER + '/' + settings.SHARE + '/'
+testdir = basedir + '/' + settings.TESTDIR
+
+def auth_fn(server, share, workgroup, username, password):
+ return (workgroup, settings.USERNAME, settings.PASSWORD)
+
+def setUp():
+ global ctx
+ ctx = smbc.Context()
+ ctx.optionNoAutoAnonymousLogin = True
+ ctx.functionAuthData = auth_fn
+
+def tearDown():
+ global ctx
+ del ctx
+
+def test_Mkdir():
+ ret = ctx.mkdir(testdir, 0)
+ assert(ret == 0)
+
+def test_MkdirFail():
+ print testdir
+ try:
+ ret = ctx.mkdir(testdir)
+ except smbc.ExistsError:
+ pass
+ except:
+ assert False
+ else:
+ assert False
+ assert True
+
+def test_ListDir():
+ list = ctx.opendir(testdir).getdents()
+ assert(len(list) == 2)
+
+def test_Stat():
+ st = ctx.stat(testdir)
+ mode = st[stat.ST_MODE]
+ assert(stat.S_ISDIR(mode))
+ assert(stat.S_ISREG(mode) == False)
+
+def test_Rename():
+ src = testdir + '/dir1'
+ dst = testdir + '/dir2'
+ ret = ctx.mkdir(src)
+ assert(ret == 0)
+ ret = ctx.rename(src, dst)
+ assert(ret == 0)
+
+def test_StatFail():
+ uri = testdir + '/dir1'
+ try:
+ ctx.stat(uri)
+ except smbc.NoEntryError:
+ pass
+ except:
+ assert False
+
+def test_Rmdir():
+ uri = testdir + '/dir2'
+ ret = ctx.rmdir(uri)
+ assert(ret == 0)
+
+def test_Cleanup():
+ ret = ctx.rmdir(testdir)
+ assert(ret == 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysmbc-1.0.8/tests/test_test.py new/pysmbc-1.0.9/tests/test_test.py
--- old/pysmbc-1.0.8/tests/test_test.py 2010-05-17 12:49:21.000000000 +0200
+++ new/pysmbc-1.0.9/tests/test_test.py 2010-06-03 05:23:02.000000000 +0200
@@ -1,22 +1,23 @@
#!/usr/bin/env python
-import unittest
+def setUp():
+ print "setUp"
+ pass
+
+def tearDown():
+ print "tearDown"
+ pass
+
+def test_003():
+ print "003"
+ pass
+
+def test_002():
+ print "002"
+ pass
+
+def test_001():
+ print "001"
+ pass
-class TestTest(unittest.TestCase):
- def setUp(self):
- pass
-
- def tearDown(self):
- pass
-
- def test001(self):
- pass
-
- def test002(self):
- pass
-
- def test003(self):
- pass
-
-if __name__ == '__main__':
- unittest.main()
+print "hello"
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org