Created
January 12, 2010 08:13
-
-
Save akaihola/274995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
VERSION = '0.03' | |
__doc__ = """ | |
SYNOPSIS | |
setskypestatus.py [-h,--help] [-v,--verbose] [--version] [ONLINE|DND|AWAY [mood text]] | |
DESCRIPTION | |
Set the Skype user status and optionally the mood text. | |
EXAMPLES | |
$ setskypestatus.py ONLINE "Feeling good" | |
$ setskypestatus.py AWAY "Back in a bit" | |
$ setskypestatus.py DND | |
AUTHOR | |
Copyright Antti Kaihola 2008-2009 | |
LICENSE | |
GPLv3 | |
VERSION | |
%s | |
""" % VERSION | |
from optparse import OptionParser, TitledHelpFormatter | |
from os import environ | |
def unittest(): | |
from doctest import testmod | |
testmod() | |
def main(status, mood_text): | |
try: | |
import Skype4Py | |
except ImportError: | |
p.exit(1, "The Skype4Py module can't be found\n") | |
skype = Skype4Py.Skype() | |
skype.Timeout = 1000 | |
try: | |
skype.Attach() | |
skype.ChangeUserStatus(status) | |
if mood_text: | |
skype.Profile('MOOD_TEXT', mood_text) | |
except Exception, e: | |
print e | |
if __name__ == '__main__': | |
p = OptionParser(formatter=TitledHelpFormatter(), | |
usage=globals()['__doc__'], | |
version=VERSION) | |
p.add_option('-d', '--display', action='store', default=':0.0') | |
p.add_option('-u', '--unittest', action='store_true') | |
(opts, args) = p.parse_args() | |
if opts.unittest: | |
unittest() | |
else: | |
if len(args) < 1: | |
p.error('one argument expected') | |
environ['DISPLAY'] = opts.display | |
main(args[0], ' '.join(args[1:]).decode('UTF-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment