Skip to main content

Skype API wrapper for Python.

Project description

Introduction

Skype4Py is a Python library which allows you to control Skype client application.

It works on Windows, OSX and Linux platforms with Python 2.x versions.

Community

Support and issues on Github. Skype4Py is not a Skype™, not associated with Microsoft or Skype. For questions you can also use stackoveflow.com with skype4py tag. Do not go for developer.skype.com for support.

Orignal author: Arkadiusz Wahlig

Maintainer: Mikko Ohtamaa

Usage

Everything that you should ever need is available as aliases in the Skype4Py package. Import it using the standard form of the import statement:

import Skype4Py

Importing the whole package into your script’s namespace using from Skype4Py import * is generally discouraged. You should also not access the modules in the package directly as they are considered an implementation detail and may change in future versions without notice.

The package provides the following:

  • Classes

Skype4Py.Skype, an alias for Skype4Py.skype.Skype

Skype4Py.CallChannelManager, an alias for Skype4Py.callchannel.CallChannelManager

  • Constants

Everything from the Skype4Py.enums module.

platform, either 'windows', 'posix' or 'darwin' depending on the current platform (Windows, Linux, Mac OS X).

  • Errors

Skype4Py.SkypeError, an alias for Skype4Py.errors.SkypeError

Skype4Py.SkypeAPIError, an alias for Skype4Py.errors.SkypeAPIError

The two classes exposed by the Skype4Py package are the only ones that are to be instantiated directly. They in turn provide means of instantiating the remaining ones. They are also the only classes that provide event handlers (for more information about events and how to use them, see the EventHandlingBase class.

Every Skype4Py script instantiates at least the Skype4Py.Skype class which gives access to the Skype client running currently in the system. Follow the Skype4Py.skype.Skype reference to see what you can do with it.

Warning! While reading this documentation, it is important to keep in mind that everything needed is in the top package level because the documentation refers to all objects in the places they actually live.

Quick example

This short example connects to Skype client and prints the user’s full name and the names of all the contacts from the contacts list:

import Skype4Py

# Create an instance of the Skype class.
skype = Skype4Py.Skype()

# Connect the Skype object to the Skype client.
skype.Attach()

# Obtain some information from the client and print it out.
print 'Your full name:', skype.CurrentUser.FullName
print 'Your contacts:'
for user in skype.Friends:
    print '    ', user.FullName

Note on the naming convention

Skype4Py uses two different naming conventions. The first one applies to interfaces derived from Skype4COM, a COM library which was an inspiration for Skype4Py. This convention uses the CapCase scheme for class names, properties, methods and their arguments. The constants use the mixedCase scheme.

The second naming convention is more “Pythonic” and is used by all other parts of the package including internal objects. It uses mostly the same CapCase scheme for class names (including exception names) with a small difference in abbreviations. Where the first convention would use a SkypeApiError name, the second one uses SkypeAPIError. Other names including properties, methods, arguments, variables and module names use lowercase letters with underscores.

Projects using Skype4Py

See Sevabot - A Skype bot supporting integration with external services

Troubleshooting

Segfaults

If you get segfault on OSX make sure you are using 32-bit Python.

Debugging segmentation faults with Python.

Related gdb dump:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000001243b68
0x00007fff8c12d878 in CFRetain ()
(gdb) bt
#0  0x00007fff8c12d878 in CFRetain ()
#1  0x00000001007e07ec in ffi_call_unix64 ()
#2  0x00007fff5fbfbb50 in ?? ()
(gdb) c
Continuing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000001243b68
0x00007fff8c12d878 in CFRetain ()

Skype4Py on for OSX 64-bit (all new OSX versions)

Currently Skype4Py must be installed and run using arch command to force compatibility with 32-bit Skype client application.

To install:

arch -i386 pip install Skype4Py

Also when you run your application using Skype4Py prefix the run command with:

arch -i386

Crashing on a startup on Ubuntu server

Segfault when starting up the bot:

  File "build/bdist.linux-i686/egg/Skype4Py/skype.py", line 250, in __init__
  File "build/bdist.linux-i686/egg/Skype4Py/api/posix.py", line 40, in SkypeAPI
  File "build/bdist.linux-i686/egg/Skype4Py/api/posix_x11.py", line 254, in __in                                    it__
Skype4Py.errors.SkypeAPIError: Could not open XDisplay
Segmentation fault (core dumped)

This usually means that your DISPLAY environment variable is wrong.

Try:

export DISPLAY=:1

or:

export DISPLAY=:0

depending on your configuration before running Sevabot.

Running unit tests

Here is an example:

virtualenv-2.7 venv  # Create venv
source venv/bin/activate
python setup.py develop  # Install Skype4Py in development mode
cd unittests
python skype4pytest.py  # Execute tests

Making a release

Use zest.releaser

Example:

virtualenv-2.7 venv  # Create venv
source venv/bin/activate
# Bump version in setup.py
python setup.py develop  # Install Skype4Py in development mode
pip install collective.checkdocs
pthon setup.py checkdocs # Check .rst syntax
easy_install zest.releaser
fullrelease

Trademark notification

Skype™, associated trademarks and logos and the “S” logo are trademarks of Skype. Skype4Py Python project is not affiliate of Skype or Microsoft corporation.

Changelog

1.0.35 (2013-05-25)

  • Fixed Issue #16 [prajna-pranab]

    The Skype API generally responds to ALTER commands by echoing back the command, including any id associated with the command e.g.

    -> ALTER VOICEMAIL <id> action <- ALTER VOICEMAIL <id> action

    For some reason the API strips the chat id from the ALTER CHAT command when it responds but the code in the chat.py _Alter() method was expecting the command to be echoed back just as it had been sent.

  • Updated Skype main window classname under Windows for Skype versions 5 and higher, to detect whether Skype is running [suurjaak]

1.0.34 (2013-01-30)

  • Reworked release system and egg structure to follow the best practices [miohtama]

  • Merged all fixed done in a fork https://github.com/stigkj/Skype4Py [miohtama]

  • Use standard pkg_distribution mechanism to expose the version numebr [miohtama]

  • Skype4Py.platform

    Easy detection of what platform code Skype4Py is using currently. May be one of ‘posix’, ‘windows’ or ‘darwin’.

  • DBus is now a default Linux (posix) platform

    Both DBus and X11 transports have been improved to work better in GUI environments. This revealed, that a special initialization code must be executed if the X11 transport is combined with the PyGTK GUI framework and possible other similar libraries. The DBus transport on the other hand, requires enabling only a single option. That and the fact, that DBus is a newer technology created to replace such old IPC techniques like X11 messaging, forced me to make it the default transport.

  • RunMainLoop option for DBus transport and Mac OS X (darwin) platform

  • Fixed CHANGES syntax so that zest.releaser understands it [miohtama]

1.0.33 (2013-01-30)

  • were removed and replaced by a single “RunMainLoop” option. The same option has been added to Mac OS X platform transport.

  • The default value (if option is not specified) is True which means that the transport will run an events loop on a separate thread to be able to receive and process messages from Skype (which result in Skype4Py event handlers being fired up).

  • This option has to be set to False if the events loop is going to be run somewhere else - the primary example are GUI applications which use the events loop to process messages from the user interfaces.

  • Trying to run two loops (one by the GUI framework and another one by Skype4Py) causes a lot of problems and unexpected behavior. When set to False, this option will tell Skype4Py to reuse the already running loop.

  • Note that if no other loop is running and this option is False, Skype4Py will remain to function (commands may be send to Skype and replies are returned) but it won’t receive notifications from the client and their corresponding events will never be fired up.

  • unittests for the common parts

    Unittests were written for parts of Skype4Py code shared by all platforms and transports. This is roughly 80% of the codebase and include all classes and the code translating object methods/properties calls to Skype API commands.

  • Call and Voicemail device methods support simultaneous devices correctly

    The CaptureMicDevice(), InputDevice() and OutputDevice() methods trio of Call and Voicemail objects support enabling of multiple devices at the same time. Previously, enabling one device disabled all the other.

  • Collections

    Almost all collection types used by Skype4COM are now supported by Skype4Py too. Collection types were initially skipped as Python provides a comprehensive set of its own container types. However, since most objects are represented by Handles or Ids, it makes a lot of sense to create a custom container type holding the handles only and creating the objects on-the-fly as they are accessed. This is the main reason for introduction of collection types. They also support methods provided by their counterparts in Skype4COM world.

  • Code cleanup and naming conventions

    The whole codebase has been reviewed and cleaned up. The naming convention for all objects (modules, classes, etc.) has been defined and implemented. It still is a mixed convention (uses two different conventions applied to different objects) but at least there is a standard now.

  • String type policy

    Skype4Py now returns unicode only when it is needed. For example, Skypenames are plain strings now while chat messages (their bodies) remain in unicode.

    Also, if Skype4Py expects a unicode string from the user and a plain string is passed instead, it tries to decode it using the UTF-8 codec (as opposed to ASCII codec which was used previously).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Skype4Py-1.0.35.zip (173.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page