Coder Social home page Coder Social logo

elfpy's Introduction

A Simple Python Script for Downloading EventLogFiles

Pre-requisites

Elf.py is built on the Python Standard Library. Your script will automatically import the following modules:

  • import urllib.request
  • import json
  • import getpass
  • import os
  • import sys
  • import gzip
  • import time
  • from io import BytesIO

As a result, there shouldn't be a need to install any other modules. However, you should verify that you have python. Open a terminal (or cmd in Windows) and type:

  $ python --version

You should see

  Python 3.x or 2.x. If you have 2.x use elf2.py or upgrade.

If you do not, you may need to install it: https://www.python.org/downloads/

If you have multiple versions of python installed, you can declare which version you want on the command line:

  $ python --version

For more information, read the help topic (https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-installed-in-parallel).

Download

To use this script, just click the Download ZIP button in GitHub and store locally on your laptop or desktop.

Run Script

From the terminal, navigate to the directory where you downloaded elf.py. For instance

  $ cd ~/Users/<User>/Desktop

To run the script, type:

  $ python elf.py (or python elf2.py for old python version)

You will be prompted for several inputs:

  1. Username
  2. Password (hidden)
  3. Date range (recommend: Last_n_Days:2 instead of Yesterday)
  4. Output directory

It's possible to change the defaults for these four prompts within the code. I recommend this if you want to test or automate the script.

The output will be an Event Log File CSV (Comma Separated Values) file for each day in the date range with the following file name convention: yyyy-mm-dd-eventtype.csv. For instance:

  2019-10-08-Login.csv

Troubleshooting

I tested this script on Ubuntu Linux, Mac OSX, and Microsoft Windows platform. However, that doesn't mean you won't run into problems.

One issue I did encounter was the use of a security token with your password if you are in a non-whitelisted organization or profile. Many administrators won't encounter this but if you try to log into the API without the token, you'll be blocked.

To reset your token, go to My Settings | Personal | Reset My Security Token.

If you don't see this menu item, then a security token is not required.

When entering your password with a security token, the token follows your password:

If your password = "mypassword" And your security token = "XXXXXXXXXX" You must enter "mypasswordXXXXXXXXXX" in place of your password

You can also read more about this in the help topic (https://help.salesforce.com/htviewhelpdoc?id=user_security_token.htm&siteLang=en_US).

You may also encounter a login error due to the ClientId and ClientSecret. If you do, make sure to change the constants in elf.py to reflect your own ClientId and ClientSecret. You can read more about how to create your own ClientId and ClientSecret in the help topic (https://help.salesforce.com/HTViewHelpDoc?id=connected_app_create.htm&language=en_US).

Supported platforms

Supported platforms: MacOS, Linux, and Windows.

Getting help

tweet to @atorman:

or post a comment to Salesforcehacker.com

elfpy's People

Contributors

atorman avatar tristenmiller avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.