mirror of https://gitlab.com/openlp/packaging.git
31 lines
1.2 KiB
Python
Executable File
31 lines
1.2 KiB
Python
Executable File
#! /usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from optparse import OptionParser
|
|
|
|
from twitter import Api, Status
|
|
|
|
def main():
|
|
parser = OptionParser()
|
|
#parser.add_option("-m", "--message", dest="message", metavar="MESSAGE",
|
|
# help="Status message to post to Twitter", metavar="MESSAGE")
|
|
parser.add_option("-u", "--username", dest="username", metavar="USERNAME",
|
|
help="The username to post as, required for authentication.")
|
|
parser.add_option("-p", "--password", dest="password", metavar="PASSWORD",
|
|
help="The password for the username, required for authentication.")
|
|
(options, args) = parser.parse_args()
|
|
if len(args) == 0:
|
|
parser.error("You haven't provided a message.")
|
|
if not options.username or not options.password:
|
|
parser.error("You need to supply a username and a password.")
|
|
message = args[0]
|
|
api = Api(username=options.username, password=options.password)
|
|
status = api.PostUpdate(message)
|
|
if not status:
|
|
print "There was a problem posting your status."
|
|
else:
|
|
print "Successfully posted your status!"
|
|
|
|
if __name__ == "__main__":
|
|
main()
|