1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#!/usr/bin/env python
## Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010, 2011, 2012 Red Hat, Inc
## Copyright (C) 2010 Open Source Solution Technology Corporation
## Authors:
## Tim Waugh <twaugh@redhat.com>
## Tsukasa Hamano <hamano@osstech.co.jp>
## 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
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""This is a set of Python bindings for the libsmbclient library
from the samba project.
>>> # Directory listing example:
>>> import smbc
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
>>> entries = ctx.opendir ("smb://SERVER").getdents ()
>>> for entry in entries:
... print entry
<smbc.Dirent object "music" (File share) at 0x7fbd7c42b3a0>
<smbc.Dirent object "IPC$" (IPC share) at 0x7fbd7c42b148>
<smbc.Dirent object "Charlie" (Printer share) at 0x7fbd7c42b3c8>
>>> d = ctx.open ("smb://SERVER/music")
>>> # Write file example:
>>> import smbc
>>> import os
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
>>> 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/music/file.txt")
>>> print file.read()
hello
"""
from distutils.core import setup, Extension
import subprocess
def pkgconfig_I (pkg):
dirs = []
c = subprocess.Popen (["pkg-config", "--cflags", pkg],
stdout=subprocess.PIPE)
(stdout, stderr) = c.communicate ()
for p in stdout.decode ('ascii').split ():
if p.startswith ("-I"):
dirs.append (p[2:])
return dirs
setup (name="pysmbc",
version="1.0.15.3",
description="Python bindings for libsmbclient",
long_description=__doc__,
author=["Tim Waugh <twaugh@redhat.com>",
"Tsukasa Hamano <hamano@osstech.co.jp>",
"Roberto Polli <rpolli@babel.it>" ],
url="http://cyberelk.net/tim/software/pysmbc/",
download_url="http://cyberelk.net/tim/data/pysmbc/",
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Development Status :: 5 - Production/Stable",
"Operating System :: Unix",
"Programming Language :: C",
],
license="GPLv2+",
packages=["smbc"],
ext_modules=[Extension("_smbc",
["smbc/smbcmodule.c",
"smbc/context.c",
"smbc/dir.c",
"smbc/file.c",
"smbc/smbcdirent.c"],
libraries=["smbclient"],
include_dirs=pkgconfig_I("smbclient"))])
|