cancel
Showing results for 
Search instead for 
Did you mean: 
Rob_Wilcox1
Level 6
Partner

 

 

A little while ago I did a 6 week stint in Enterprise Vault QA.  Whilst waiting for data to build, and fleshing out regression testing plans, generally getting all my ducks in a row, I thought it would be good if I could get my Enterprise Vault Server to send tweets when various things happen.

This article walks you through the things that need to be setup on the Enterprise Vault Server, and explains through the example of the running of the Provisioning Task how to send a Tweet.

Internet Needed

Normally all my environments for testing run in host-only mode VMWare.  Of course in order to reach out to Twitter.com, you’ve got to “get around” that and have a connection out to the internet.  For the purposes of these tests I added a second network card, running in a NAT configuration.  Essentially when I open a browser I can get to twitter.com.  If you want this to work you’ll need to be able to do the same.

Installation on the EV server :

Python (2.7 from http://www.python.org/download)

SetupTools (0.6c11 from http://pypi.python.org/pypi/setuptools) From that page choose the 2.7 installer for win32.

Tweepy (https://github.com/tweepy/tweepy)

Download the tweepy 1.7 file, and then extract it to c:\tweepy

Configuration on the EV server

Add the python scripts folder to the path. You can do this permanently as follows (OS dependent, of course – this is Windows 2003):

Open Control Panel

Double click on System

Click the Advanced tab

Click Environment Variables

In System Environment Variables, locate “Path”

Click on, and click Edit

Add c:\python27\scripts to the beginning, followed by a semi-colon and click OK

Click OK again to close the System dialog

You can also just do it temporarily as follows :

  • Open a command prompt
  • Type path=%path%;c:\python27\scripts

Now go in to the Tweepy folder, and “install” it as follows :-

Setup.py install

It should run through something like this :

running install

running bdist_egg

running egg_info

creating tweepy.egg-info

writing tweepy.egg-info\PKG-INFO

writing top-level names to tweepy.egg-info\top_level.txt

writing dependency_links to tweepy.egg-info\dependency_links.txt

writing manifest file 'tweepy.egg-info\SOURCES.txt'

reading manifest file 'tweepy.egg-info\SOURCES.txt'

writing manifest file 'tweepy.egg-info\SOURCES.txt'

installing library code to build\bdist.win32\egg

running install_lib

running build_py

creating build

creating build\lib

creating build\lib\tweepy

copying tweepy\api.py -> build\lib\tweepy

copying tweepy\auth.py -> build\lib\tweepy

copying tweepy\binder.py -> build\lib\tweepy

copying tweepy\cache.py -> build\lib\tweepy

copying tweepy\cursor.py -> build\lib\tweepy

copying tweepy\error.py -> build\lib\tweepy

copying tweepy\models.py -> build\lib\tweepy

copying tweepy\oauth.py -> build\lib\tweepy

copying tweepy\parsers.py -> build\lib\tweepy

copying tweepy\rob.py -> build\lib\tweepy

copying tweepy\streaming.py -> build\lib\tweepy

copying tweepy\utils.py -> build\lib\tweepy

copying tweepy\__init__.py -> build\lib\tweepy

creating build\bdist.win32

creating build\bdist.win32\egg

creating build\bdist.win32\egg\tweepy

copying build\lib\tweepy\api.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\auth.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\binder.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\cache.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\cursor.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\error.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\models.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\oauth.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\parsers.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\rob.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\streaming.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\utils.py -> build\bdist.win32\egg\tweepy

copying build\lib\tweepy\__init__.py -> build\bdist.win32\egg\tweepy

byte-compiling build\bdist.win32\egg\tweepy\api.py to api.pyc

byte-compiling build\bdist.win32\egg\tweepy\auth.py to auth.pyc

byte-compiling build\bdist.win32\egg\tweepy\binder.py to binder.pyc

byte-compiling build\bdist.win32\egg\tweepy\cache.py to cache.pyc

byte-compiling build\bdist.win32\egg\tweepy\cursor.py to cursor.pyc

byte-compiling build\bdist.win32\egg\tweepy\error.py to error.pyc

byte-compiling build\bdist.win32\egg\tweepy\models.py to models.pyc

byte-compiling build\bdist.win32\egg\tweepy\oauth.py to oauth.pyc

byte-compiling build\bdist.win32\egg\tweepy\parsers.py to parsers.pyc

byte-compiling build\bdist.win32\egg\tweepy\rob.py to rob.pyc

byte-compiling build\bdist.win32\egg\tweepy\streaming.py to streaming.pyc

byte-compiling build\bdist.win32\egg\tweepy\utils.py to utils.pyc

byte-compiling build\bdist.win32\egg\tweepy\__init__.py to __init__.pyc

creating build\bdist.win32\egg\EGG-INFO

copying tweepy.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO

copying tweepy.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO

copying tweepy.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO

copying tweepy.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO

copying tweepy.egg-info\zip-safe -> build\bdist.win32\egg\EGG-INFO

creating dist

creating 'dist\tweepy-1.7.1-py2.7.egg' and adding 'build\bdist.win32\egg' to it

removing 'build\bdist.win32\egg' (and everything under it)

Processing tweepy-1.7.1-py2.7.egg

Copying tweepy-1.7.1-py2.7.egg to c:\python27\lib\site-packages

Adding tweepy 1.7.1 to easy-install.pth file

Installed c:\python27\lib\site-packages\tweepy-1.7.1-py2.7.egg

Processing dependencies for tweepy==1.7.1

Finished processing dependencies for tweepy==1.7.1

Twitter Setup

Setup a new Twitter account, for example http://twitter.com/evtest123

Twitter Configuration via Tweepy

You can’t tweet from a command line as easily as you used to be able to, you now have to use OAuth. Here is how to set it up (it can be done on any machine with Tweepy configured, and then the files can be copied to the EV server!)

Get the PIN

Login to Twitter, and then in a new tab, go to http://dev.twitter.com/apps  to register a new API app with Twitter.com.  Click on Register a new application. You might have to log in to the Twitter site first, if you’re not already.

Fill in the registration fields as follows:

Note: whatever you specify for Application Name will be the “via” name your followers see in the details of tweets issued from your command line app:

Also note that for the website, you can put something like http://someplace.com.  It doesn’t have to be a real place.

You can check what has happened so far by going to : http://dev.twitter.com/apps

Check that the application will allow you to post, and that it is not read only.

Put the following in to a python file, and run it :

#!/usr/bin/env python

import tweepy

CONSUMER_KEY = ‘something’

CONSUMER_SECRET = ‘something’

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

auth_url = auth.get_authorization_url()

print 'Please authorize: ' + auth_url

verifier = raw_input('PIN: ').strip()

auth.get_access_token(verifier)

print "ACCESS_KEY = '%s'" % auth.access_token.key

print "ACCESS_SECRET = '%s'" % auth.access_token.secret

You will get the CONSUMER_KEY and CONSUMER_SECRET from the API page after you register the API app, or by going to the link above (http://dev.twitter.com/apps) when logged in.   You need to edit the script you create (eg startme.py) and put in the :

CONSUMER_KEY

CONSUMER_SECRET

.. or it won’t work !

Run the script, and you’ll get a prompt like this :

Paste the URL in to a browser, and it will give you a PIN.   Make sure that the information on the page that is displays says you will be able to post tweets.   Note that the URL changes each time you run the above script, so if you run the above script, and get the PIN wrong when entering it back, you have to run the .py file again, and get a new URL, and a new PIN.

 

Put the PIN in, and press return.

You will get an ACCESS_KEY and ACCESS_SECRET back.

Testing sending a tweet

You can now use a script like this, to send a tweet!

#!/usr/bin/env python

import sys

import tweepy

CONSUMER_KEY = 'something'

CONSUMER_SECRET = ‘something’

ACCESS_KEY = ‘something’

ACCESS_SECRET = 'something’

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)

api.update_status(sys.argv[1])

You run it using :-

  • Save the above text to a file called tweetme.py in the tweepy directory and then from a DOS prompt:
  • Tweetme.py “This is a test tweet”

Monitoring

For this you need to have eventtrigger installed on the EV Server. Refer to this for help :

http://www.symantec.com/connect/articles/using-event-triggers

Once you have it setup, you should then do the following :-

In the c:\tweepy folder create a file called tweepy.cmd

The contents should be something like this :

@echo off

Echo Running….

Set thestring=Provisioning just finished on evault01 %date% %time%

Echo %thestring%

C:\tweepy\tweepy\tweetme.py “%thestring%”

Echo Finished.

Test it by running tweepy.cmd a few times, and checking twitter.

You then configure the “watcher” as follows :

Eventtriggers /create /TR “Tweetme” /l “Symantec Enterprise Vault” /eid 41104 /t Information /tk “c:\tweepy\tweepy.cmd”

Test it a couple of times by running the provisioning task, and checking the event log, and twitter.

References :

http://jmillerinc.com/2010/05/31/twitter-from-the-command-line-in-python-using-oauth/

Comments
JesusWept3
Level 6
Partner Accredited Certified

i can't actually tell if this is a joke or not

Rob_Wilcox1
Level 6
Partner

Alex me old bean..  Why would you think it is a joke?

 

It's not..

 

Some people (crazy as they might be) are well in to Twitter, Facebook, etc, etc.  

 

I just thought that they might want to know that their Enterprise Vault Server(s) are joining the social networking revolution.

teiva-boy
Level 6

You know this is pretty nifty actually...  It opens up other avenues for applications to report to the social sites...

Rob_Wilcox1
Level 6
Partner

Thank you..  When I've got my FSA or Sharepoint Archiving box back online, I'll do some further work to explain how to tweet on those.

Liam_Finn1
Level 6
Employee Accredited Certified

Hmm,

 

Instead of creating a Tweet Maybe it could post to something like a blogging software and that way not onlly could you have a track history of the actions taken like FSA or being put into backup mode but also present that outside so it can be viewed that way you only need to put a front end website into your DMZ that really exposes nothing of any interest to anyone except offering visability to staff outside

 

If not on a website maybe make it send SMTP messages to the same status can be notified to IT

 

This has lots of options if fully explored

Rob_Wilcox1
Level 6
Partner

Good ideas Liam, thanks.   The same principles could be applied I guess, you just need a command line way of posting the data.

Version history
Last update:
‎05-12-2011 10:05 AM
Updated by: