tabs/ final newlines
This commit is contained in:
parent
cadcf0b48a
commit
44869cbd4f
4 changed files with 749 additions and 748 deletions
|
@ -9,34 +9,34 @@ print "Devices: %d\n" % devices
|
||||||
allMethods = telldus.TELLDUS_TURNON | telldus.TELLDUS_TURNOFF | telldus.TELLDUS_BELL | telldus.TELLDUS_DIM
|
allMethods = telldus.TELLDUS_TURNON | telldus.TELLDUS_TURNOFF | telldus.TELLDUS_BELL | telldus.TELLDUS_DIM
|
||||||
|
|
||||||
for i in xrange(devices):
|
for i in xrange(devices):
|
||||||
deviceid = telldus.tdGetDeviceId(i)
|
deviceid = telldus.tdGetDeviceId(i)
|
||||||
name = telldus.tdGetName(deviceid)
|
name = telldus.tdGetName(deviceid)
|
||||||
|
|
||||||
print "%s - %s\n" % (deviceid, name)
|
print "%s - %s\n" % (deviceid, name)
|
||||||
|
|
||||||
methods = telldus.tdMethods(deviceid, allMethods)
|
methods = telldus.tdMethods(deviceid, allMethods)
|
||||||
|
|
||||||
if methods & telldus.TELLDUS_TURNON:
|
if methods & telldus.TELLDUS_TURNON:
|
||||||
print " * TurnOn\n"
|
print " * TurnOn\n"
|
||||||
telldus.tdTurnOn(deviceid)
|
telldus.tdTurnOn(deviceid)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if methods & telldus.TELLDUS_TURNOFF:
|
if methods & telldus.TELLDUS_TURNOFF:
|
||||||
print " * TurnOff\n"
|
print " * TurnOff\n"
|
||||||
telldus.tdTurnOff(deviceid)
|
telldus.tdTurnOff(deviceid)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if methods & telldus.TELLDUS_BELL:
|
if methods & telldus.TELLDUS_BELL:
|
||||||
echo " * Bell\n"
|
echo " * Bell\n"
|
||||||
telldus.tdBell(deviceid)
|
telldus.tdBell(deviceid)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if methods & telldus.TELLDUS_TOGGLE:
|
if methods & telldus.TELLDUS_TOGGLE:
|
||||||
print " * Toggle\n"
|
print " * Toggle\n"
|
||||||
|
|
||||||
if methods & telldus.TELLDUS_DIM:
|
if methods & telldus.TELLDUS_DIM:
|
||||||
print " * Dim\n"
|
print " * Dim\n"
|
||||||
telldus.tdDim(deviceid, 128)
|
telldus.tdDim(deviceid, 128)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
telldus.tdClose()
|
telldus.tdClose()
|
|
@ -7,337 +7,337 @@ PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win')
|
||||||
|
|
||||||
if PLATFORM_IS_WINDOWS:
|
if PLATFORM_IS_WINDOWS:
|
||||||
|
|
||||||
__doc__="""This is a distutils setup-script for the telldus extension
|
__doc__="""This is a distutils setup-script for the telldus extension
|
||||||
|
|
||||||
To build the telldus extensions, simply execute:
|
To build the telldus extensions, simply execute:
|
||||||
python setup.py -q build
|
python setup.py -q build
|
||||||
or
|
or
|
||||||
python setup.py -q install
|
python setup.py -q install
|
||||||
to build and install into your current Python installation.
|
to build and install into your current Python installation.
|
||||||
|
|
||||||
These extensions require a number of libraries to build, some of which may
|
These extensions require a number of libraries to build, some of which may
|
||||||
require you to install special SDKs or toolkits. This script will attempt
|
require you to install special SDKs or toolkits. This script will attempt
|
||||||
to build as many as it can, and at the end of the build will report any
|
to build as many as it can, and at the end of the build will report any
|
||||||
extension modules that could not be built and why.
|
extension modules that could not be built and why.
|
||||||
|
|
||||||
This has got complicated due to the various different versions of
|
This has got complicated due to the various different versions of
|
||||||
Visual Studio used - some VS versions are not compatible with some SDK
|
Visual Studio used - some VS versions are not compatible with some SDK
|
||||||
versions. Below are the Windows SDK versions required (and the URL - although
|
versions. Below are the Windows SDK versions required (and the URL - although
|
||||||
these are subject to being changed by MS at any time:)
|
these are subject to being changed by MS at any time:)
|
||||||
|
|
||||||
Python 2.6+:
|
Python 2.6+:
|
||||||
|
|
||||||
Build using Microsoft Visual Studio 2008 Express Edition:
|
Build using Microsoft Visual Studio 2008 Express Edition:
|
||||||
http://www.microsoft.com/en-us/download/details.aspx?id=6506
|
http://www.microsoft.com/en-us/download/details.aspx?id=6506
|
||||||
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/
|
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/
|
||||||
http://www.cppblog.com/Files/xcpp/VCE64BIT_WIN7SDK.zip
|
http://www.cppblog.com/Files/xcpp/VCE64BIT_WIN7SDK.zip
|
||||||
|
|
||||||
For 32bit build:
|
For 32bit build:
|
||||||
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5
|
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5
|
||||||
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b
|
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b
|
||||||
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars32.bat to
|
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars32.bat to
|
||||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
||||||
|
|
||||||
For 64bit build:
|
For 64bit build:
|
||||||
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (ISO) GRMSDKX_EN_DVD.iso
|
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (ISO) GRMSDKX_EN_DVD.iso
|
||||||
http://www.microsoft.com/en-us/download/details.aspx?id=18950
|
http://www.microsoft.com/en-us/download/details.aspx?id=18950
|
||||||
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars64.bat to
|
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars64.bat to
|
||||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
||||||
|
|
||||||
Python 2.3->2.5:
|
Python 2.3->2.5:
|
||||||
|
|
||||||
Microsoft Windows Software Development Kit Update for Windows Vista (version 6.0)
|
Microsoft Windows Software Development Kit Update for Windows Vista (version 6.0)
|
||||||
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065
|
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065
|
||||||
** If you want to build Python 2.3, be sure to install the SDK compilers
|
** If you want to build Python 2.3, be sure to install the SDK compilers
|
||||||
too - although we don't use them, this setup option installs some .lib
|
too - although we don't use them, this setup option installs some .lib
|
||||||
files we do need.
|
files we do need.
|
||||||
**
|
**
|
||||||
|
|
||||||
If you multiple SDK versions on a single machine, set the MSSDK environment
|
If you multiple SDK versions on a single machine, set the MSSDK environment
|
||||||
variable to point at the one you want to use. Note that using the SDK for
|
variable to point at the one you want to use. Note that using the SDK for
|
||||||
a particular platform (eg, Windows 7) doesn't force you to use that OS as your
|
a particular platform (eg, Windows 7) doesn't force you to use that OS as your
|
||||||
build environment. If the links above don't work, use google to find them.
|
build environment. If the links above don't work, use google to find them.
|
||||||
|
|
||||||
Building:
|
Building:
|
||||||
---------
|
---------
|
||||||
|
|
||||||
To install the telldus extension, execute:
|
To install the telldus extension, execute:
|
||||||
python setup.py -q install
|
python setup.py -q install
|
||||||
|
|
||||||
This will install the built extensions into your site-packages directory,
|
This will install the built extensions into your site-packages directory,
|
||||||
create an appropriate .pth file, and should leave everything ready to use.
|
create an appropriate .pth file, and should leave everything ready to use.
|
||||||
There is no need to modify the registry.
|
There is no need to modify the registry.
|
||||||
|
|
||||||
To build or install debug (_d) versions of these extensions, ensure you have
|
To build or install debug (_d) versions of these extensions, ensure you have
|
||||||
built or installed a debug version of Python itself, then pass the "--debug"
|
built or installed a debug version of Python itself, then pass the "--debug"
|
||||||
flag to the build command - eg:
|
flag to the build command - eg:
|
||||||
python setup.py -q build --debug
|
python setup.py -q build --debug
|
||||||
or to build and install a debug version:
|
or to build and install a debug version:
|
||||||
python setup.py -q build --debug install
|
python setup.py -q build --debug install
|
||||||
|
|
||||||
To build 64bit versions of this:
|
To build 64bit versions of this:
|
||||||
|
|
||||||
* py2.5 and earlier - sorry, I've given up in disgust. Using VS2003 with
|
* py2.5 and earlier - sorry, I've given up in disgust. Using VS2003 with
|
||||||
the Vista SDK is just too painful to make work, and VS2005 is not used for
|
the Vista SDK is just too painful to make work, and VS2005 is not used for
|
||||||
any released versions of Python. See revision 1.69 of this file for the
|
any released versions of Python. See revision 1.69 of this file for the
|
||||||
last version that attempted to support and document this process.
|
last version that attempted to support and document this process.
|
||||||
|
|
||||||
* 2.6 and later: On a 64bit OS, just build as you would on a 32bit platform.
|
* 2.6 and later: On a 64bit OS, just build as you would on a 32bit platform.
|
||||||
On a 32bit platform (ie, to cross-compile), you must use VS2008 to
|
On a 32bit platform (ie, to cross-compile), you must use VS2008 to
|
||||||
cross-compile Python itself. Note that by default, the 64bit tools are not
|
cross-compile Python itself. Note that by default, the 64bit tools are not
|
||||||
installed with VS2008, so you may need to adjust your VS2008 setup (see "For 64bit build"). Then
|
installed with VS2008, so you may need to adjust your VS2008 setup (see "For 64bit build"). Then
|
||||||
use:
|
use:
|
||||||
vcs
|
vcs
|
||||||
setup.py build --plat-name=win-amd64
|
setup.py build --plat-name=win-amd64
|
||||||
|
|
||||||
see the distutils cross-compilation documentation for more details.
|
see the distutils cross-compilation documentation for more details.
|
||||||
"""
|
"""
|
||||||
# Originally by Thomas Heller, started in 2000 or so.
|
# Originally by Thomas Heller, started in 2000 or so.
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
is_py3k = sys.version_info > (3,) # get this out of the way early on...
|
is_py3k = sys.version_info > (3,) # get this out of the way early on...
|
||||||
# We have special handling for _winreg so our setup3.py script can avoid
|
# We have special handling for _winreg so our setup3.py script can avoid
|
||||||
# using the 'imports' fixer and therefore start much faster...
|
# using the 'imports' fixer and therefore start much faster...
|
||||||
if is_py3k:
|
if is_py3k:
|
||||||
import winreg as _winreg
|
import winreg as _winreg
|
||||||
else:
|
else:
|
||||||
import _winreg
|
import _winreg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from distutils import log
|
from distutils import log
|
||||||
except ImportError:
|
except ImportError:
|
||||||
class Log:
|
class Log:
|
||||||
def debug(self, msg, *args):
|
def debug(self, msg, *args):
|
||||||
print msg % args
|
print msg % args
|
||||||
def info(self, msg, *args):
|
def info(self, msg, *args):
|
||||||
print msg % args
|
print msg % args
|
||||||
log = Log()
|
log = Log()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
this_file = __file__
|
this_file = __file__
|
||||||
except NameError:
|
except NameError:
|
||||||
this_file = sys.argv[0]
|
this_file = sys.argv[0]
|
||||||
|
|
||||||
this_file = os.path.abspath(this_file)
|
this_file = os.path.abspath(this_file)
|
||||||
# We get upset if the cwd is not our source dir, but it is a PITA to
|
# We get upset if the cwd is not our source dir, but it is a PITA to
|
||||||
# insist people manually CD there first!
|
# insist people manually CD there first!
|
||||||
if os.path.dirname(this_file):
|
if os.path.dirname(this_file):
|
||||||
os.chdir(os.path.dirname(this_file))
|
os.chdir(os.path.dirname(this_file))
|
||||||
|
|
||||||
|
|
||||||
# We need to know the platform SDK dir before we can list the extensions.
|
# We need to know the platform SDK dir before we can list the extensions.
|
||||||
def find_platform_sdk_dir():
|
def find_platform_sdk_dir():
|
||||||
# Finding the Platform SDK install dir is a treat. There can be some
|
# Finding the Platform SDK install dir is a treat. There can be some
|
||||||
# dead ends so we only consider the job done if we find the "windows.h"
|
# dead ends so we only consider the job done if we find the "windows.h"
|
||||||
# landmark.
|
# landmark.
|
||||||
landmark = "include\\windows.h"
|
landmark = "include\\windows.h"
|
||||||
# 1. The use might have their current environment setup for the
|
# 1. The use might have their current environment setup for the
|
||||||
# SDK, in which case the "MSSdk" env var is set.
|
# SDK, in which case the "MSSdk" env var is set.
|
||||||
sdkdir = os.environ.get("MSSdk")
|
sdkdir = os.environ.get("MSSdk")
|
||||||
if sdkdir:
|
if sdkdir:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "PSDK: try %%MSSdk%%: '%s'" % sdkdir
|
print "PSDK: try %%MSSdk%%: '%s'" % sdkdir
|
||||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||||
return sdkdir
|
return sdkdir
|
||||||
# 2. The "Install Dir" value in the
|
# 2. The "Install Dir" value in the
|
||||||
# HKLM\Software\Microsoft\MicrosoftSDK\Directories registry key
|
# HKLM\Software\Microsoft\MicrosoftSDK\Directories registry key
|
||||||
# sometimes points to the right thing. However, after upgrading to
|
# sometimes points to the right thing. However, after upgrading to
|
||||||
# the "Platform SDK for Windows Server 2003 SP1" this is dead end.
|
# the "Platform SDK for Windows Server 2003 SP1" this is dead end.
|
||||||
try:
|
try:
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||||
r"Software\Microsoft\MicrosoftSDK\Directories")
|
r"Software\Microsoft\MicrosoftSDK\Directories")
|
||||||
sdkdir, ignore = _winreg.QueryValueEx(key, "Install Dir")
|
sdkdir, ignore = _winreg.QueryValueEx(key, "Install Dir")
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
||||||
"\Directories\Install Dir': '%s'" % sdkdir
|
"\Directories\Install Dir': '%s'" % sdkdir
|
||||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||||
return sdkdir
|
return sdkdir
|
||||||
# 3. Each installed SDK (not just the platform SDK) seems to have GUID
|
# 3. Each installed SDK (not just the platform SDK) seems to have GUID
|
||||||
# subkey of HKLM\Software\Microsoft\MicrosoftSDK\InstalledSDKs and
|
# subkey of HKLM\Software\Microsoft\MicrosoftSDK\InstalledSDKs and
|
||||||
# it *looks* like the latest installed Platform SDK will be the
|
# it *looks* like the latest installed Platform SDK will be the
|
||||||
# only one with an "Install Dir" sub-value.
|
# only one with an "Install Dir" sub-value.
|
||||||
try:
|
try:
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||||
r"Software\Microsoft\MicrosoftSDK\InstalledSDKs")
|
r"Software\Microsoft\MicrosoftSDK\InstalledSDKs")
|
||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
guid = _winreg.EnumKey(key, i)
|
guid = _winreg.EnumKey(key, i)
|
||||||
guidkey = _winreg.OpenKey(key, guid)
|
guidkey = _winreg.OpenKey(key, guid)
|
||||||
try:
|
try:
|
||||||
sdkdir, ignore = _winreg.QueryValueEx(guidkey, "Install Dir")
|
sdkdir, ignore = _winreg.QueryValueEx(guidkey, "Install Dir")
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
||||||
"\InstallSDKs\%s\Install Dir': '%s'"\
|
"\InstallSDKs\%s\Install Dir': '%s'"\
|
||||||
% (guid, sdkdir)
|
% (guid, sdkdir)
|
||||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||||
return sdkdir
|
return sdkdir
|
||||||
i += 1
|
i += 1
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
pass
|
pass
|
||||||
# 4. Vista's SDK
|
# 4. Vista's SDK
|
||||||
try:
|
try:
|
||||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||||
r"Software\Microsoft\Microsoft SDKs\Windows")
|
r"Software\Microsoft\Microsoft SDKs\Windows")
|
||||||
sdkdir, ignore = _winreg.QueryValueEx(key, "CurrentInstallFolder")
|
sdkdir, ignore = _winreg.QueryValueEx(key, "CurrentInstallFolder")
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDKs"\
|
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDKs"\
|
||||||
"\Windows\CurrentInstallFolder': '%s'" % sdkdir
|
"\Windows\CurrentInstallFolder': '%s'" % sdkdir
|
||||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||||
return sdkdir
|
return sdkdir
|
||||||
|
|
||||||
# 5. Failing this just try a few well-known default install locations.
|
# 5. Failing this just try a few well-known default install locations.
|
||||||
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
||||||
defaultlocs = [
|
defaultlocs = [
|
||||||
os.path.join(progfiles, "Microsoft Platform SDK"),
|
os.path.join(progfiles, "Microsoft Platform SDK"),
|
||||||
os.path.join(progfiles, "Microsoft SDK"),
|
os.path.join(progfiles, "Microsoft SDK"),
|
||||||
]
|
]
|
||||||
for sdkdir in defaultlocs:
|
for sdkdir in defaultlocs:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "PSDK: try default location: '%s'" % sdkdir
|
print "PSDK: try default location: '%s'" % sdkdir
|
||||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||||
return sdkdir
|
return sdkdir
|
||||||
|
|
||||||
|
|
||||||
# Some nasty hacks to prevent most of our extensions using a manifest, as
|
# Some nasty hacks to prevent most of our extensions using a manifest, as
|
||||||
# the manifest - even without a reference to the CRT assembly - is enough
|
# the manifest - even without a reference to the CRT assembly - is enough
|
||||||
# to prevent the extension from loading. For more details, see
|
# to prevent the extension from loading. For more details, see
|
||||||
# http://bugs.python.org/issue7833 - that issue has a patch, but it is
|
# http://bugs.python.org/issue7833 - that issue has a patch, but it is
|
||||||
# languishing and will probably never be fixed for Python 2.6...
|
# languishing and will probably never be fixed for Python 2.6...
|
||||||
if sys.version_info > (2,6):
|
if sys.version_info > (2,6):
|
||||||
from distutils.spawn import spawn
|
from distutils.spawn import spawn
|
||||||
from distutils.msvc9compiler import MSVCCompiler
|
from distutils.msvc9compiler import MSVCCompiler
|
||||||
MSVCCompiler._orig_spawn = MSVCCompiler.spawn
|
MSVCCompiler._orig_spawn = MSVCCompiler.spawn
|
||||||
MSVCCompiler._orig_link = MSVCCompiler.link
|
MSVCCompiler._orig_link = MSVCCompiler.link
|
||||||
|
|
||||||
# We need to override this method for versions where issue7833 *has* landed
|
# We need to override this method for versions where issue7833 *has* landed
|
||||||
# (ie, 2.7 and 3.2+)
|
# (ie, 2.7 and 3.2+)
|
||||||
def manifest_get_embed_info(self, target_desc, ld_args):
|
def manifest_get_embed_info(self, target_desc, ld_args):
|
||||||
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
||||||
if not _want_assembly_kept:
|
if not _want_assembly_kept:
|
||||||
return None
|
return None
|
||||||
for arg in ld_args:
|
for arg in ld_args:
|
||||||
if arg.startswith("/MANIFESTFILE:"):
|
if arg.startswith("/MANIFESTFILE:"):
|
||||||
orig_manifest = arg.split(":", 1)[1]
|
orig_manifest = arg.split(":", 1)[1]
|
||||||
if target_desc==self.EXECUTABLE:
|
if target_desc==self.EXECUTABLE:
|
||||||
rid = 1
|
rid = 1
|
||||||
else:
|
else:
|
||||||
rid = 2
|
rid = 2
|
||||||
return orig_manifest, rid
|
return orig_manifest, rid
|
||||||
return None
|
return None
|
||||||
# always monkeypatch it in even though it will only be called in 2.7
|
# always monkeypatch it in even though it will only be called in 2.7
|
||||||
# and 3.2+.
|
# and 3.2+.
|
||||||
MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info
|
MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info
|
||||||
|
|
||||||
def monkeypatched_spawn(self, cmd):
|
def monkeypatched_spawn(self, cmd):
|
||||||
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
|
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
|
||||||
is_mt = cmd[0].endswith("mt.exe") or cmd[0].endswith('"mt.exe"')
|
is_mt = cmd[0].endswith("mt.exe") or cmd[0].endswith('"mt.exe"')
|
||||||
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
||||||
if not _want_assembly_kept and is_mt:
|
if not _want_assembly_kept and is_mt:
|
||||||
# We don't want mt.exe run...
|
# We don't want mt.exe run...
|
||||||
return
|
return
|
||||||
if not _want_assembly_kept and is_link:
|
if not _want_assembly_kept and is_link:
|
||||||
# remove /MANIFESTFILE:... and add MANIFEST:NO
|
# remove /MANIFESTFILE:... and add MANIFEST:NO
|
||||||
# (but note that for winxpgui, which specifies a manifest via a
|
# (but note that for winxpgui, which specifies a manifest via a
|
||||||
# .rc file, this is ignored by the linker - the manifest specified
|
# .rc file, this is ignored by the linker - the manifest specified
|
||||||
# in the .rc file is still added)
|
# in the .rc file is still added)
|
||||||
for i in range(len(cmd)):
|
for i in range(len(cmd)):
|
||||||
if cmd[i].startswith("/MANIFESTFILE:"):
|
if cmd[i].startswith("/MANIFESTFILE:"):
|
||||||
cmd[i] = "/MANIFEST:NO"
|
cmd[i] = "/MANIFEST:NO"
|
||||||
break
|
break
|
||||||
if _want_assembly_kept and is_mt:
|
if _want_assembly_kept and is_mt:
|
||||||
# We want mt.exe run with the original manifest
|
# We want mt.exe run with the original manifest
|
||||||
for i in range(len(cmd)):
|
for i in range(len(cmd)):
|
||||||
if cmd[i] == "-manifest":
|
if cmd[i] == "-manifest":
|
||||||
cmd[i+1] = cmd[i+1] + ".orig"
|
cmd[i+1] = cmd[i+1] + ".orig"
|
||||||
break
|
break
|
||||||
self._orig_spawn(cmd)
|
self._orig_spawn(cmd)
|
||||||
if _want_assembly_kept and is_link:
|
if _want_assembly_kept and is_link:
|
||||||
# We want a copy of the original manifest so we can use it later.
|
# We want a copy of the original manifest so we can use it later.
|
||||||
for i in range(len(cmd)):
|
for i in range(len(cmd)):
|
||||||
if cmd[i].startswith("/MANIFESTFILE:"):
|
if cmd[i].startswith("/MANIFESTFILE:"):
|
||||||
mfname = cmd[i][14:]
|
mfname = cmd[i][14:]
|
||||||
shutil.copyfile(mfname, mfname + ".orig")
|
shutil.copyfile(mfname, mfname + ".orig")
|
||||||
break
|
break
|
||||||
|
|
||||||
def monkeypatched_link(self, target_desc, objects, output_filename, *args, **kw):
|
def monkeypatched_link(self, target_desc, objects, output_filename, *args, **kw):
|
||||||
# no manifests for 3.3+
|
# no manifests for 3.3+
|
||||||
self._want_assembly_kept = sys.version_info < (3,3) and \
|
self._want_assembly_kept = sys.version_info < (3,3) and \
|
||||||
(os.path.basename(output_filename).startswith("PyISAPI_loader.dll") or \
|
(os.path.basename(output_filename).startswith("PyISAPI_loader.dll") or \
|
||||||
os.path.basename(output_filename).startswith("perfmondata.dll") or \
|
os.path.basename(output_filename).startswith("perfmondata.dll") or \
|
||||||
os.path.basename(output_filename).startswith("win32ui.pyd") or \
|
os.path.basename(output_filename).startswith("win32ui.pyd") or \
|
||||||
target_desc==self.EXECUTABLE)
|
target_desc==self.EXECUTABLE)
|
||||||
try:
|
try:
|
||||||
return self._orig_link(target_desc, objects, output_filename, *args, **kw)
|
return self._orig_link(target_desc, objects, output_filename, *args, **kw)
|
||||||
finally:
|
finally:
|
||||||
delattr(self, '_want_assembly_kept')
|
delattr(self, '_want_assembly_kept')
|
||||||
MSVCCompiler.spawn = monkeypatched_spawn
|
MSVCCompiler.spawn = monkeypatched_spawn
|
||||||
MSVCCompiler.link = monkeypatched_link
|
MSVCCompiler.link = monkeypatched_link
|
||||||
|
|
||||||
def find_telldus_dev_dir():
|
def find_telldus_dev_dir():
|
||||||
landmark = "telldus-core.h"
|
landmark = "telldus-core.h"
|
||||||
dev_dir = os.environ.get("TELLDUS_DEVDIR")
|
dev_dir = os.environ.get("TELLDUS_DEVDIR")
|
||||||
if dev_dir:
|
if dev_dir:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "Telldus dev dir:" % dev_dir
|
print "Telldus dev dir:" % dev_dir
|
||||||
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
||||||
return dev_dir
|
return dev_dir
|
||||||
|
|
||||||
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
||||||
defaultlocs = [
|
defaultlocs = [
|
||||||
os.path.join(progfiles + ' (x86)', "Telldus", "Development"),
|
os.path.join(progfiles + ' (x86)', "Telldus", "Development"),
|
||||||
os.path.join(progfiles, "Telldus", "Development"),
|
os.path.join(progfiles, "Telldus", "Development"),
|
||||||
]
|
]
|
||||||
for dev_dir in defaultlocs:
|
for dev_dir in defaultlocs:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "Telldus dev dir: '%s'" % dev_dir
|
print "Telldus dev dir: '%s'" % dev_dir
|
||||||
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
||||||
return dev_dir
|
return dev_dir
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "Telldus dev dir not found, make sure dev code is installed. Or set TELLDUS_DEVDIR."
|
print "Telldus dev dir not found, make sure dev code is installed. Or set TELLDUS_DEVDIR."
|
||||||
|
|
||||||
sdk_dir = find_platform_sdk_dir()
|
sdk_dir = find_platform_sdk_dir()
|
||||||
sdk_include_dir = os.path.join(sdk_dir, 'Include')
|
sdk_include_dir = os.path.join(sdk_dir, 'Include')
|
||||||
|
|
||||||
telldus_dev_dir = find_telldus_dev_dir()
|
telldus_dev_dir = find_telldus_dev_dir()
|
||||||
telldus_platform = os.environ.get("TELLDUS_PLATFORM", 'x86_64')
|
telldus_platform = os.environ.get("TELLDUS_PLATFORM", 'x86_64')
|
||||||
telldus_library_dir = os.path.join(telldus_dev_dir, telldus_platform)
|
telldus_library_dir = os.path.join(telldus_dev_dir, telldus_platform)
|
||||||
|
|
||||||
include_dirs = [sdk_include_dir, os.path.dirname(this_file)]
|
include_dirs = [sdk_include_dir, os.path.dirname(this_file)]
|
||||||
library_dirs = [telldus_library_dir]
|
library_dirs = [telldus_library_dir]
|
||||||
libraries = ['python%i%i' % (sys.version_info[0], sys.version_info[1]) , 'TelldusCore']
|
libraries = ['python%i%i' % (sys.version_info[0], sys.version_info[1]) , 'TelldusCore']
|
||||||
define_macros = [('_WINDOWS', 1)]
|
define_macros = [('_WINDOWS', 1)]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
include_dirs = ['/usr/include', '/usr/local/include']
|
include_dirs = ['/usr/include', '/usr/local/include']
|
||||||
library_dirs = ['/usr/lib', '/usr/local/lib']
|
library_dirs = ['/usr/lib', '/usr/local/lib']
|
||||||
libraries = ['telldus-core']
|
libraries = ['telldus-core']
|
||||||
define_macros = []
|
define_macros = []
|
||||||
|
|
||||||
telldus = Extension(
|
telldus = Extension(
|
||||||
'telldus',
|
'telldus',
|
||||||
include_dirs = include_dirs,
|
include_dirs = include_dirs,
|
||||||
libraries = libraries,
|
libraries = libraries,
|
||||||
library_dirs = library_dirs,
|
library_dirs = library_dirs,
|
||||||
define_macros = define_macros,
|
define_macros = define_macros,
|
||||||
sources = ['telldus.c']
|
sources = ['telldus.c']
|
||||||
)
|
)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'telldus',
|
name = 'telldus',
|
||||||
version = '1.0',
|
version = '1.0',
|
||||||
description = 'Python bindings for telldus',
|
description = 'Python bindings for telldus',
|
||||||
author='Oyvind Saltvik',
|
author='Oyvind Saltvik',
|
||||||
author_email='oyvind.saltvik@gmail.com',
|
author_email='oyvind.saltvik@gmail.com',
|
||||||
url='http://github.com/fivethreeo/telldus/',
|
url='http://github.com/fivethreeo/telldus/',
|
||||||
ext_modules = [telldus]
|
ext_modules = [telldus]
|
||||||
)
|
)
|
|
@ -10,7 +10,7 @@
|
||||||
*
|
*
|
||||||
* estrdup returns a copy of its argument, located in memory
|
* estrdup returns a copy of its argument, located in memory
|
||||||
* allocated from the heap. If it is unable to allocate the
|
* allocated from the heap. If it is unable to allocate the
|
||||||
* necessary memory, estrdup executes error("no memory").
|
* necessary memory, estrdup executes PyErr_NoMemory();
|
||||||
* (Generally, the routine error is not expected to return,
|
* (Generally, the routine error is not expected to return,
|
||||||
* but if it does, estrdup will return NULL.)
|
* but if it does, estrdup will return NULL.)
|
||||||
*/
|
*/
|
||||||
|
@ -18,610 +18,611 @@
|
||||||
char *
|
char *
|
||||||
estrdup(char *s)
|
estrdup(char *s)
|
||||||
{
|
{
|
||||||
register char *t;
|
register char *t;
|
||||||
|
|
||||||
if (NULL == (t = malloc(strlen(s)+1))) {
|
if (NULL == (t = malloc(strlen(s)+1))) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
strcpy(t, s);
|
strcpy(t, s);
|
||||||
return(t);
|
return(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdInit(PyObject *self)
|
telldus_tdInit(PyObject *self)
|
||||||
{
|
{
|
||||||
/* PyEval_InitThreads(); */
|
tdInit();
|
||||||
tdInit();
|
Py_INCREF(Py_None);
|
||||||
Py_INCREF(Py_None);
|
return Py_None;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdClose(PyObject *self)
|
telldus_tdClose(PyObject *self)
|
||||||
{
|
{
|
||||||
tdClose();
|
tdClose();
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdTurnOn(PyObject *self, PyObject *args)
|
telldus_tdTurnOn(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdTurnOn(id));
|
return PyBool_FromLong((long) tdTurnOn(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdTurnOff(PyObject *self, PyObject *args)
|
telldus_tdTurnOff(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdTurnOff(id));
|
return PyBool_FromLong((long) tdTurnOff(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdBell(PyObject *self, PyObject *args)
|
telldus_tdBell(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdBell(id));
|
return PyBool_FromLong((long) tdBell(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdDim(PyObject *self, PyObject *args)
|
telldus_tdDim(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
unsigned char level;
|
unsigned char level;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "lb", &id, &level))
|
if (!PyArg_ParseTuple(args, "lb", &id, &level))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (level < 0 || level > 255)
|
if (level < 0 || level > 255)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdDim(id, level));
|
return PyBool_FromLong((long) tdDim(id, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdLearn(PyObject *self, PyObject *args)
|
telldus_tdLearn(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdLearn(id));
|
return PyBool_FromLong((long) tdLearn(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdMethods(PyObject *self, PyObject *args)
|
telldus_tdMethods(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
long supportedmethods;
|
long supportedmethods;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdMethods(id, supportedmethods));
|
return PyLong_FromLong((long) tdMethods(id, supportedmethods));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdLastSentCommand(PyObject *self, PyObject *args)
|
telldus_tdLastSentCommand(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
long supportedmethods;
|
long supportedmethods;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdLastSentCommand(id, supportedmethods));
|
return PyLong_FromLong((long) tdLastSentCommand(id, supportedmethods));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdLastSentValue(PyObject *self, PyObject *args)
|
telldus_tdLastSentValue(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* value;
|
char* value;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
value = tdLastSentValue(id);
|
value = tdLastSentValue(id);
|
||||||
retval = estrdup(value);
|
retval = estrdup(value);
|
||||||
tdReleaseString(value);
|
tdReleaseString(value);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetNumberOfDevices(PyObject *self)
|
telldus_tdGetNumberOfDevices(PyObject *self)
|
||||||
{
|
{
|
||||||
return PyLong_FromLong((long) tdGetNumberOfDevices());
|
return PyLong_FromLong((long) tdGetNumberOfDevices());
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetDeviceId(PyObject *self, PyObject *args)
|
telldus_tdGetDeviceId(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long index;
|
long index;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &index))
|
if (!PyArg_ParseTuple(args, "l", &index))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdGetDeviceId(index));
|
return PyLong_FromLong((long) tdGetDeviceId(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetDeviceType(PyObject *self, PyObject *args)
|
telldus_tdGetDeviceType(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdGetDeviceType(id));
|
return PyLong_FromLong((long) tdGetDeviceType(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetErrorString(PyObject *self, PyObject *args)
|
telldus_tdGetErrorString(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long errorno;
|
long errorno;
|
||||||
char* errorString;
|
char* errorString;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &errorno))
|
if (!PyArg_ParseTuple(args, "l", &errorno))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
errorString = tdGetErrorString(errorno);
|
errorString = tdGetErrorString(errorno);
|
||||||
retval = estrdup(errorString);
|
retval = estrdup(errorString);
|
||||||
tdReleaseString(errorString);
|
tdReleaseString(errorString);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetName(PyObject *self, PyObject *args)
|
telldus_tdGetName(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = tdGetName(id);
|
name = tdGetName(id);
|
||||||
retval = estrdup(name);
|
retval = estrdup(name);
|
||||||
tdReleaseString(name);
|
tdReleaseString(name);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdSetName(PyObject *self, PyObject *args)
|
telldus_tdSetName(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &name))
|
if (!PyArg_ParseTuple(args, "ls", &id, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdSetName(id, name));
|
return PyBool_FromLong((long) tdSetName(id, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetProtocol(PyObject *self, PyObject *args)
|
telldus_tdGetProtocol(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* protocol;
|
char* protocol;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
protocol = tdGetProtocol(id);
|
protocol = tdGetProtocol(id);
|
||||||
retval = estrdup(protocol);
|
retval = estrdup(protocol);
|
||||||
tdReleaseString(protocol);
|
tdReleaseString(protocol);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdSetProtocol(PyObject *self, PyObject *args)
|
telldus_tdSetProtocol(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* protocol;
|
char* protocol;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &protocol))
|
if (!PyArg_ParseTuple(args, "ls", &id, &protocol))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdSetProtocol(id, protocol));
|
return PyBool_FromLong((long) tdSetProtocol(id, protocol));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetModel(PyObject *self, PyObject *args)
|
telldus_tdGetModel(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* model;
|
char* model;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
model = tdGetModel(id);
|
model = tdGetModel(id);
|
||||||
retval = estrdup(model);
|
retval = estrdup(model);
|
||||||
tdReleaseString(model);
|
tdReleaseString(model);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdSetModel(PyObject *self, PyObject *args)
|
telldus_tdSetModel(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* model;
|
char* model;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "ls", &id, &model))
|
if (!PyArg_ParseTuple(args, "ls", &id, &model))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdSetProtocol(id, model));
|
return PyBool_FromLong((long) tdSetProtocol(id, model));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdGetDeviceParameter(PyObject *self, PyObject *args)
|
telldus_tdGetDeviceParameter(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
char* defaultValue;
|
char* defaultValue;
|
||||||
char* param;
|
char* param;
|
||||||
char* retval;
|
char* retval;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &defaultValue))
|
if (!PyArg_ParseTuple(args, "lss", &id, &name, &defaultValue))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
param = tdGetDeviceParameter(id, name, defaultValue);
|
param = tdGetDeviceParameter(id, name, defaultValue);
|
||||||
retval = estrdup(param);
|
retval = estrdup(param);
|
||||||
tdReleaseString(param);
|
tdReleaseString(param);
|
||||||
return PyString_FromString(retval);
|
return PyString_FromString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdSetDeviceParameter(PyObject *self, PyObject *args)
|
telldus_tdSetDeviceParameter(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
char* name;
|
char* name;
|
||||||
char* value;
|
char* value;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &value))
|
if (!PyArg_ParseTuple(args, "lss", &id, &name, &value))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdSetDeviceParameter(id, name, value));
|
return PyBool_FromLong((long) tdSetDeviceParameter(id, name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdAddDevice(PyObject *self)
|
telldus_tdAddDevice(PyObject *self)
|
||||||
{
|
{
|
||||||
return PyLong_FromLong((long) tdAddDevice());
|
return PyLong_FromLong((long) tdAddDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdRemoveDevice(PyObject *self, PyObject *args)
|
telldus_tdRemoveDevice(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l", &id))
|
if (!PyArg_ParseTuple(args, "l", &id))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyBool_FromLong((long) tdRemoveDevice(id));
|
return PyBool_FromLong((long) tdRemoveDevice(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdSendRawCommand(PyObject *self, PyObject *args)
|
telldus_tdSendRawCommand(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *command;
|
char *command;
|
||||||
long reserved = 0;
|
long reserved = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s|l", &command, &reserved));
|
if (!PyArg_ParseTuple(args, "s|l", &command, &reserved));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdSendRawCommand(command, reserved));
|
return PyLong_FromLong((long) tdSendRawCommand(command, reserved));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Work in progress event callbacks
|
Work in progress event callbacks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void
|
void
|
||||||
telldus_deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *pyfunc)
|
telldus_deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *pyfunc)
|
||||||
{
|
{
|
||||||
PyObject * arglist;
|
PyObject * arglist;
|
||||||
PyObject * result;
|
PyObject * result;
|
||||||
PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
// prepare the arg list to pass into the Python callback function
|
// prepare the arg list to pass into the Python callback function
|
||||||
arglist = Py_BuildValue("llsl", deviceId, method, data, callbackId);
|
arglist = Py_BuildValue("llsl", deviceId, method, data, callbackId);
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyEval_CallObject(pyfunc, arglist);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_DECREF(arglist);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
|
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
telldus_deviceChangeEventCallback(int deviceId, int changeEvent, int changeType, int callbackId, void *pyfunc)
|
telldus_deviceChangeEventCallback(int deviceId, int changeEvent, int changeType, int callbackId, void *pyfunc)
|
||||||
{
|
{
|
||||||
PyObject * arglist;
|
PyObject * arglist;
|
||||||
PyObject * result;
|
PyObject * result;
|
||||||
PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
// prepare the arg list to pass into the Python callback function
|
// prepare the arg list to pass into the Python callback function
|
||||||
arglist = Py_BuildValue("llll", deviceId, changeEvent, changeType, callbackId);
|
arglist = Py_BuildValue("llll", deviceId, changeEvent, changeType, callbackId);
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyEval_CallObject(pyfunc, arglist);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_DECREF(arglist);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
|
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
telldus_rawDeviceEventCallback(const char *data, int controllerId, int callbackId, void *pyfunc)
|
telldus_rawDeviceEventCallback(const char *data, int controllerId, int callbackId, void *pyfunc)
|
||||||
{
|
{
|
||||||
PyObject * arglist;
|
PyObject * arglist;
|
||||||
PyObject * result;
|
PyObject * result;
|
||||||
PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
// prepare the arg list to pass into the Python callback function
|
// prepare the arg list to pass into the Python callback function
|
||||||
arglist = Py_BuildValue("sll", data, controllerId, callbackId);
|
arglist = Py_BuildValue("sll", data, controllerId, callbackId);
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyEval_CallObject(pyfunc, arglist);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_DECREF(arglist);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
|
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
telldus_sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *pyfunc)
|
telldus_sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *pyfunc)
|
||||||
{
|
{
|
||||||
PyObject * arglist;
|
PyObject * arglist;
|
||||||
PyObject * result;
|
PyObject * result;
|
||||||
PyGILState_STATE gstate;
|
PyGILState_STATE gstate;
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
gstate = PyGILState_Ensure();
|
||||||
|
|
||||||
// prepare the arg list to pass into the Python callback function
|
// prepare the arg list to pass into the Python callback function
|
||||||
arglist = Py_BuildValue("ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
|
arglist = Py_BuildValue("ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
|
||||||
|
|
||||||
// now call the Python callback function
|
// now call the Python callback function
|
||||||
result = PyEval_CallObject(pyfunc, arglist);
|
result = PyEval_CallObject(pyfunc, arglist);
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
// something went wrong so print to stderr
|
// something went wrong so print to stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of reference handling
|
// take care of reference handling
|
||||||
Py_DECREF(arglist);
|
Py_DECREF(arglist);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
|
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdRegisterDeviceEvent(PyObject *self, PyObject *args)
|
telldus_tdRegisterDeviceEvent(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &func));
|
if (!PyArg_ParseTuple(args, "O", &func));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdRegisterDeviceEvent((TDDeviceEvent) telldus_deviceEventCallback, &func));
|
return PyLong_FromLong((long) tdRegisterDeviceEvent((TDDeviceEvent) telldus_deviceEventCallback, &func));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdRegisterDeviceChangeEvent(PyObject *self, PyObject *args)
|
telldus_tdRegisterDeviceChangeEvent(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &func));
|
if (!PyArg_ParseTuple(args, "O", &func));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdRegisterDeviceChangeEvent((TDDeviceChangeEvent) telldus_deviceChangeEventCallback, &func));
|
return PyLong_FromLong((long) tdRegisterDeviceChangeEvent((TDDeviceChangeEvent) telldus_deviceChangeEventCallback, &func));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdRegisterRawDeviceEvent(PyObject *self, PyObject *args)
|
telldus_tdRegisterRawDeviceEvent(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &func));
|
if (!PyArg_ParseTuple(args, "O", &func));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdRegisterRawDeviceEvent((TDRawDeviceEvent) telldus_rawDeviceEventCallback, &func));
|
return PyLong_FromLong((long) tdRegisterRawDeviceEvent((TDRawDeviceEvent) telldus_rawDeviceEventCallback, &func));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdRegisterSensorEvent(PyObject *self, PyObject *args)
|
telldus_tdRegisterSensorEvent(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &func));
|
if (!PyArg_ParseTuple(args, "O", &func));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong((long) tdRegisterSensorEvent((TDSensorEvent) telldus_sensorEventCallback, &func));
|
return PyLong_FromLong((long) tdRegisterSensorEvent((TDSensorEvent) telldus_sensorEventCallback, &func));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyMethodDef telldus_methods[] = {
|
static PyMethodDef telldus_methods[] = {
|
||||||
/* The cast of the function is necessary since PyCFunction values
|
/* The cast of the function is necessary since PyCFunction values
|
||||||
* only take two PyObject* parameters, and keywdarg_parrot() takes
|
* only take two PyObject* parameters, and keywdarg_parrot() takes
|
||||||
* three.
|
* three.
|
||||||
*/
|
*/
|
||||||
{"tdInit", (PyCFunction) telldus_tdInit, METH_NOARGS, "Initiate telldus."},
|
{"tdInit", (PyCFunction) telldus_tdInit, METH_NOARGS, "Initiate telldus."},
|
||||||
{"tdClose", (PyCFunction) telldus_tdClose, METH_NOARGS, "Close telldus."},
|
{"tdClose", (PyCFunction) telldus_tdClose, METH_NOARGS, "Close telldus."},
|
||||||
{"tdTurnOn", (PyCFunction) telldus_tdTurnOn, METH_VARARGS, "Turn on device."},
|
{"tdTurnOn", (PyCFunction) telldus_tdTurnOn, METH_VARARGS, "Turn on device."},
|
||||||
{"tdTurnOff", (PyCFunction) telldus_tdTurnOff, METH_VARARGS, "Turn off device."},
|
{"tdTurnOff", (PyCFunction) telldus_tdTurnOff, METH_VARARGS, "Turn off device."},
|
||||||
{"tdBell", (PyCFunction) telldus_tdBell, METH_VARARGS, "Bell device."},
|
{"tdBell", (PyCFunction) telldus_tdBell, METH_VARARGS, "Bell device."},
|
||||||
{"tdDim", (PyCFunction) telldus_tdDim, METH_VARARGS, "Dim device."},
|
{"tdDim", (PyCFunction) telldus_tdDim, METH_VARARGS, "Dim device."},
|
||||||
{"tdLearn", (PyCFunction) telldus_tdLearn, METH_VARARGS, "Learn device."},
|
{"tdLearn", (PyCFunction) telldus_tdLearn, METH_VARARGS, "Learn device."},
|
||||||
{"tdMethods", (PyCFunction) telldus_tdMethods, METH_VARARGS, "Methods comment."},
|
{"tdMethods", (PyCFunction) telldus_tdMethods, METH_VARARGS, "Methods comment."},
|
||||||
{"tdLastSentCommand", (PyCFunction) telldus_tdLastSentCommand, METH_VARARGS, "LastSentCommand comment."},
|
{"tdLastSentCommand", (PyCFunction) telldus_tdLastSentCommand, METH_VARARGS, "LastSentCommand comment."},
|
||||||
{"tdLastSentValue", (PyCFunction) telldus_tdLastSentValue, METH_VARARGS, "LastSentValue comment."},
|
{"tdLastSentValue", (PyCFunction) telldus_tdLastSentValue, METH_VARARGS, "LastSentValue comment."},
|
||||||
{"tdGetNumberOfDevices", (PyCFunction) telldus_tdGetNumberOfDevices, METH_VARARGS, "GetNumberOfDevices comment."},
|
{"tdGetNumberOfDevices", (PyCFunction) telldus_tdGetNumberOfDevices, METH_VARARGS, "GetNumberOfDevices comment."},
|
||||||
{"tdGetDeviceId", (PyCFunction) telldus_tdGetDeviceId, METH_VARARGS, "GetDeviceId comment."},
|
{"tdGetDeviceId", (PyCFunction) telldus_tdGetDeviceId, METH_VARARGS, "GetDeviceId comment."},
|
||||||
{"tdGetDeviceType", (PyCFunction) telldus_tdGetDeviceType, METH_VARARGS, "GetDeviceType comment."},
|
{"tdGetDeviceType", (PyCFunction) telldus_tdGetDeviceType, METH_VARARGS, "GetDeviceType comment."},
|
||||||
{"tdGetErrorString", (PyCFunction) telldus_tdGetErrorString, METH_VARARGS, "GetErrorString comment."},
|
{"tdGetErrorString", (PyCFunction) telldus_tdGetErrorString, METH_VARARGS, "GetErrorString comment."},
|
||||||
{"tdGetName", (PyCFunction) telldus_tdGetName, METH_VARARGS, "GetName comment."},
|
{"tdGetName", (PyCFunction) telldus_tdGetName, METH_VARARGS, "GetName comment."},
|
||||||
{"tdSetName", (PyCFunction) telldus_tdSetName, METH_VARARGS, "SetName comment."},
|
{"tdSetName", (PyCFunction) telldus_tdSetName, METH_VARARGS, "SetName comment."},
|
||||||
{"tdGetProtocol", (PyCFunction) telldus_tdGetProtocol, METH_VARARGS, "GetProtocol comment."},
|
{"tdGetProtocol", (PyCFunction) telldus_tdGetProtocol, METH_VARARGS, "GetProtocol comment."},
|
||||||
{"tdSetProtocol", (PyCFunction) telldus_tdSetProtocol, METH_VARARGS, "SetProtocol comment."},
|
{"tdSetProtocol", (PyCFunction) telldus_tdSetProtocol, METH_VARARGS, "SetProtocol comment."},
|
||||||
{"tdGetModel", (PyCFunction) telldus_tdGetModel, METH_VARARGS, "GetModel comment."},
|
{"tdGetModel", (PyCFunction) telldus_tdGetModel, METH_VARARGS, "GetModel comment."},
|
||||||
{"tdSetModel", (PyCFunction) telldus_tdSetModel, METH_VARARGS, "SetModel comment."},
|
{"tdSetModel", (PyCFunction) telldus_tdSetModel, METH_VARARGS, "SetModel comment."},
|
||||||
{"tdGetDeviceParameter", (PyCFunction) telldus_tdGetDeviceParameter, METH_VARARGS, "GetDeviceParameter comment."},
|
{"tdGetDeviceParameter", (PyCFunction) telldus_tdGetDeviceParameter, METH_VARARGS, "GetDeviceParameter comment."},
|
||||||
{"tdSetDeviceParameter", (PyCFunction) telldus_tdSetDeviceParameter, METH_VARARGS, "SetDeviceParameter comment."},
|
{"tdSetDeviceParameter", (PyCFunction) telldus_tdSetDeviceParameter, METH_VARARGS, "SetDeviceParameter comment."},
|
||||||
{"tdAddDevice", (PyCFunction) telldus_tdAddDevice, METH_NOARGS, "AddDevice comment."},
|
{"tdAddDevice", (PyCFunction) telldus_tdAddDevice, METH_NOARGS, "AddDevice comment."},
|
||||||
{"tdRemoveDevice", (PyCFunction) telldus_tdRemoveDevice, METH_VARARGS, "RemoveDevice comment."},
|
{"tdRemoveDevice", (PyCFunction) telldus_tdRemoveDevice, METH_VARARGS, "RemoveDevice comment."},
|
||||||
{"tdSendRawCommand", (PyCFunction) telldus_tdSendRawCommand, METH_VARARGS, "SendRawCommand comment."},
|
{"tdSendRawCommand", (PyCFunction) telldus_tdSendRawCommand, METH_VARARGS, "SendRawCommand comment."},
|
||||||
/*
|
/*
|
||||||
{"tdRegisterDeviceEvent", (PyCFunction) telldus_tdRegisterDeviceEvent, METH_VARARGS, "RegisterDeviceEvent comment."},
|
{"tdRegisterDeviceEvent", (PyCFunction) telldus_tdRegisterDeviceEvent, METH_VARARGS, "RegisterDeviceEvent comment."},
|
||||||
{"tdRegisterDeviceChangeEvent", (PyCFunction) telldus_tdRegisterDeviceChangeEvent, METH_VARARGS, "RegisterDeviceChangeEvent comment."},
|
{"tdRegisterDeviceChangeEvent", (PyCFunction) telldus_tdRegisterDeviceChangeEvent, METH_VARARGS, "RegisterDeviceChangeEvent comment."},
|
||||||
{"tdRegisterRawDeviceEvent", (PyCFunction) telldus_tdRegisterRawDeviceEvent, METH_VARARGS, "RegisterRawDeviceEvent comment."},
|
{"tdRegisterRawDeviceEvent", (PyCFunction) telldus_tdRegisterRawDeviceEvent, METH_VARARGS, "RegisterRawDeviceEvent comment."},
|
||||||
{"tdRegisterSensorEvent", (PyCFunction) telldus_tdRegisterSensorEvent, METH_VARARGS, "RegisterSensorEvent comment."},
|
{"tdRegisterSensorEvent", (PyCFunction) telldus_tdRegisterSensorEvent, METH_VARARGS, "RegisterSensorEvent comment."},
|
||||||
|
|
||||||
*/
|
*/
|
||||||
{NULL, NULL, 0, NULL} /* sentinel */
|
{NULL, NULL, 0, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
inittelldus(void)
|
inittelldus(void)
|
||||||
{
|
{
|
||||||
PyObject *module;
|
PyObject *module;
|
||||||
|
|
||||||
PyObject *TELLSTICK_TURNON_GLUE;
|
PyObject *TELLSTICK_TURNON_GLUE;
|
||||||
PyObject *TELLSTICK_TURNOFF_GLUE;
|
PyObject *TELLSTICK_TURNOFF_GLUE;
|
||||||
PyObject *TELLSTICK_BELL_GLUE;
|
PyObject *TELLSTICK_BELL_GLUE;
|
||||||
PyObject *TELLSTICK_TOGGLE_GLUE;
|
PyObject *TELLSTICK_TOGGLE_GLUE;
|
||||||
PyObject *TELLSTICK_DIM_GLUE;
|
PyObject *TELLSTICK_DIM_GLUE;
|
||||||
PyObject *TELLSTICK_LEARN_GLUE;
|
PyObject *TELLSTICK_LEARN_GLUE;
|
||||||
PyObject *TELLSTICK_SUCCESS_GLUE;
|
PyObject *TELLSTICK_SUCCESS_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_NOT_FOUND_GLUE;
|
PyObject *TELLSTICK_ERROR_NOT_FOUND_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_PERMISSION_DENIED_GLUE;
|
PyObject *TELLSTICK_ERROR_PERMISSION_DENIED_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE;
|
PyObject *TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE;
|
PyObject *TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_COMMUNICATION_GLUE;
|
PyObject *TELLSTICK_ERROR_COMMUNICATION_GLUE;
|
||||||
PyObject *TELLSTICK_ERROR_UNKNOWN_GLUE;
|
PyObject *TELLSTICK_ERROR_UNKNOWN_GLUE;
|
||||||
PyObject *TELLSTICK_TYPE_DEVICE_GLUE;
|
PyObject *TELLSTICK_TYPE_DEVICE_GLUE;
|
||||||
PyObject *TELLSTICK_TYPE_GROUP_GLUE;
|
PyObject *TELLSTICK_TYPE_GROUP_GLUE;
|
||||||
|
|
||||||
/* Create the module and add the functions */
|
/* Create the module and add the functions */
|
||||||
|
|
||||||
module = Py_InitModule("telldus", telldus_methods);
|
/* PyEval_InitThreads(); */
|
||||||
|
|
||||||
TELLSTICK_TURNON_GLUE = PyLong_FromLong((long) TELLSTICK_TURNON);
|
module = Py_InitModule("telldus", telldus_methods);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_TURNON", TELLSTICK_TURNON_GLUE);
|
|
||||||
Py_DECREF(TELLSTICK_TURNON_GLUE);
|
|
||||||
|
|
||||||
TELLSTICK_TURNOFF_GLUE = PyLong_FromLong((long) TELLSTICK_TURNOFF);
|
TELLSTICK_TURNON_GLUE = PyLong_FromLong((long) TELLSTICK_TURNON);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_TURNOFF", TELLSTICK_TURNOFF_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_TURNON", TELLSTICK_TURNON_GLUE);
|
||||||
Py_DECREF(TELLSTICK_TURNOFF_GLUE);
|
Py_DECREF(TELLSTICK_TURNON_GLUE);
|
||||||
|
|
||||||
TELLSTICK_BELL_GLUE = PyLong_FromLong((long) TELLSTICK_BELL);
|
TELLSTICK_TURNOFF_GLUE = PyLong_FromLong((long) TELLSTICK_TURNOFF);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_BELL", TELLSTICK_BELL_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_TURNOFF", TELLSTICK_TURNOFF_GLUE);
|
||||||
Py_DECREF(TELLSTICK_BELL_GLUE);
|
Py_DECREF(TELLSTICK_TURNOFF_GLUE);
|
||||||
|
|
||||||
TELLSTICK_TOGGLE_GLUE = PyLong_FromLong((long) TELLSTICK_TOGGLE);
|
TELLSTICK_BELL_GLUE = PyLong_FromLong((long) TELLSTICK_BELL);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_TOGGLE", TELLSTICK_TOGGLE_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_BELL", TELLSTICK_BELL_GLUE);
|
||||||
Py_DECREF(TELLSTICK_TOGGLE_GLUE);
|
Py_DECREF(TELLSTICK_BELL_GLUE);
|
||||||
|
|
||||||
TELLSTICK_DIM_GLUE = PyLong_FromLong((long) TELLSTICK_DIM);
|
TELLSTICK_TOGGLE_GLUE = PyLong_FromLong((long) TELLSTICK_TOGGLE);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_DIM", TELLSTICK_DIM_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_TOGGLE", TELLSTICK_TOGGLE_GLUE);
|
||||||
Py_DECREF(TELLSTICK_DIM_GLUE);
|
Py_DECREF(TELLSTICK_TOGGLE_GLUE);
|
||||||
|
|
||||||
TELLSTICK_LEARN_GLUE = PyLong_FromLong((long) TELLSTICK_LEARN);
|
TELLSTICK_DIM_GLUE = PyLong_FromLong((long) TELLSTICK_DIM);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_LEARN", TELLSTICK_LEARN_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_DIM", TELLSTICK_DIM_GLUE);
|
||||||
Py_DECREF(TELLSTICK_LEARN_GLUE);
|
Py_DECREF(TELLSTICK_DIM_GLUE);
|
||||||
|
|
||||||
TELLSTICK_SUCCESS_GLUE = PyLong_FromLong((long) TELLSTICK_SUCCESS);
|
TELLSTICK_LEARN_GLUE = PyLong_FromLong((long) TELLSTICK_LEARN);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_SUCCESS", TELLSTICK_SUCCESS_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_LEARN", TELLSTICK_LEARN_GLUE);
|
||||||
Py_DECREF(TELLSTICK_SUCCESS_GLUE);
|
Py_DECREF(TELLSTICK_LEARN_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_NOT_FOUND);
|
TELLSTICK_SUCCESS_GLUE = PyLong_FromLong((long) TELLSTICK_SUCCESS);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_NOT_FOUND", TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_SUCCESS", TELLSTICK_SUCCESS_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
Py_DECREF(TELLSTICK_SUCCESS_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_PERMISSION_DENIED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_PERMISSION_DENIED);
|
TELLSTICK_ERROR_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_NOT_FOUND);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_PERMISSION_DENIED", TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_NOT_FOUND", TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_DEVICE_NOT_FOUND);
|
TELLSTICK_ERROR_PERMISSION_DENIED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_PERMISSION_DENIED);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_DEVICE_NOT_FOUND", TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_PERMISSION_DENIED", TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_METHOD_NOT_SUPPORTED);
|
TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_DEVICE_NOT_FOUND);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_METHOD_NOT_SUPPORTED", TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_DEVICE_NOT_FOUND", TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_COMMUNICATION_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_COMMUNICATION);
|
TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_METHOD_NOT_SUPPORTED);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_COMMUNICATION", TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_METHOD_NOT_SUPPORTED", TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
||||||
|
|
||||||
TELLSTICK_ERROR_UNKNOWN_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_UNKNOWN);
|
TELLSTICK_ERROR_COMMUNICATION_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_COMMUNICATION);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_UNKNOWN", TELLSTICK_ERROR_UNKNOWN_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_COMMUNICATION", TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
||||||
Py_DECREF(TELLSTICK_ERROR_UNKNOWN_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
||||||
|
|
||||||
TELLSTICK_TYPE_DEVICE_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_DEVICE);
|
TELLSTICK_ERROR_UNKNOWN_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_UNKNOWN);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_TYPE_DEVICE", TELLSTICK_TYPE_DEVICE_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_ERROR_UNKNOWN", TELLSTICK_ERROR_UNKNOWN_GLUE);
|
||||||
Py_DECREF(TELLSTICK_TYPE_DEVICE_GLUE);
|
Py_DECREF(TELLSTICK_ERROR_UNKNOWN_GLUE);
|
||||||
|
|
||||||
TELLSTICK_TYPE_GROUP_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_GROUP);
|
TELLSTICK_TYPE_DEVICE_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_DEVICE);
|
||||||
PyObject_SetAttrString(module, "TELLSTICK_TYPE_GROUP", TELLSTICK_TYPE_GROUP_GLUE);
|
PyObject_SetAttrString(module, "TELLSTICK_TYPE_DEVICE", TELLSTICK_TYPE_DEVICE_GLUE);
|
||||||
Py_DECREF(TELLSTICK_TYPE_GROUP_GLUE);
|
Py_DECREF(TELLSTICK_TYPE_DEVICE_GLUE);
|
||||||
|
|
||||||
|
TELLSTICK_TYPE_GROUP_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_GROUP);
|
||||||
|
PyObject_SetAttrString(module, "TELLSTICK_TYPE_GROUP", TELLSTICK_TYPE_GROUP_GLUE);
|
||||||
|
Py_DECREF(TELLSTICK_TYPE_GROUP_GLUE);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue