Skip to content

Commit

Permalink
Added Command Line Usage and Parameters
Browse files Browse the repository at this point in the history
Added the option to pass in an alternative config file.
  • Loading branch information
jakewaldron committed Mar 13, 2015
1 parent 375253b commit 4664574
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ sudo virtualenv --python=/usr/local/bin/python2.7 pevenv
~/plexemail/scripts/pevenv/bin/python ~/plexemail/scripts/plexEmail.py
```

## Usage

#### Normal Usage

```
python plexEmail.py
```

#### Alternate Usage

Pass in an alternate config file. For example the default config file sends out a daily email (using Cloudinary), while an alternate config file is set up for a weekly web page.

```
python plexEmail.py -c C:\files\plexEmailWeekly.conf
```

## Config File

The config file is in the scripts folder. Before first run of the script, please update this file with your information.
Expand Down
22 changes: 20 additions & 2 deletions scripts/plexEmail.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sqlite3
import sys
import argparse
import os
import json
import operator
Expand Down Expand Up @@ -465,9 +466,26 @@ def createWebHTML():
</html>"""

return htmlText


#
#
# Main Code
#
#

parser = argparse.ArgumentParser(description='This script aggregates all new TV and movie releases for the past x days then writes to your web directory and sends out an email.')
parser.add_argument('-c','--configfile', help='The path to a config file to be used in the running of this instance of the script.', default=os.path.dirname(os.path.realpath(sys.argv[0])) + os.path.sep + 'config.conf', required=False)
args = vars(parser.parse_args())

if ('configfile' in args):
configFile = args['configfile']

if (not os.path.isfile(configFile)):
print configFile + ' does not exist'
sys.exit()

config = {}
execfile(os.path.dirname(os.path.realpath(sys.argv[0])) + os.path.sep + 'config.conf', config)
execfile(configFile, config)
replaceConfigTokens()

if ('upload_use_cloudinary' in config and config['upload_use_cloudinary']):
Expand Down

0 comments on commit 4664574

Please sign in to comment.